0% found this document useful (0 votes)
45 views11 pages

Python Calculator Project Updated2

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
45 views11 pages

Python Calculator Project Updated2

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 11

COMPUTER SCIENCE Python Calculator

NAME: ROHAN ANIL JAVALEKAR


CLASS 12
Index
1. Introduction 2

2. Source Code 3-4

3. Output 5-6

4. Concepts Used 7

5. Future Enhancements 8

6. Advantages and Limitations 9

7. Bibliography 10

1
1. Introduction:

This project is a simple calculator developed using


Python, a popular and versatile programming
language. The calculator is designed to perform
basic arithmetic operations such as addition,
subtraction, multiplication, and division. By
leveraging the fundamental concepts of Python,
this project aims to provide a hands-on experience
in programming logic, function implementation,
and input/output operations. The project
demonstrates Python's capability in creating user-
friendly applications that can solve every day
computational problems efficiently. This project is
a simple calculator developed using Python. The
calculator can perform basic arithmetic
operations such as addition, subtraction,
multiplication, and division. It is designed to be
user-friendly and efficient, demonstrating the
application of Python in solving real-world
problems.

2
2. Source Code:
# Python Calculator

def add(a, b):


return a + b

def subtract(a, b):


return a - b

def multiply(a, b):


return a * b

def divide(a, b):


if b == 0:
return "Error: Division by zero is not allowed."
return a / b

def calculator():
print("Select operation:")
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")
3
choice = input("Enter choice (1/2/3/4): ")

if choice in ['1', '2', '3', '4']:


num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))

if choice == '1':
print(f"Result: {add(num1, num2)}")
elif choice == '2':
print(f"Result: {subtract(num1, num2)}")
elif choice == '3':
print(f"Result: {multiply(num1, num2)}")
elif choice == '4':
print(f"Result: {divide(num1, num2)}")
else:
print("Invalid Input")

calculator()

4
3. Output:
The output of the project is demonstrated below:

#Output 1:
Select operation:
1. Addition
2. Subtraction
3. Multiplication
4. Division
Enter choice (1/2/3/4): 1
Enter first number: 10
Enter second number: 5
Result: 15.0
#Output 2:
Select operation:
1. Addition
2. Subtraction
3. Multiplication
4. Division
Enter choice (1/2/3/4): 2
Enter first number: 48
Enter second number: 5
Result: 43.0

5
#Output 3:
Select operation:
1. Addition
2. Subtraction
3. Multiplication
4. Division
Enter choice (1/2/3/4): 4
Enter first number: 36
Enter second number: 0
Result: Error: Division by zero is not allowed.
#Output 4:
Select operation:
1. Addition
2. Subtraction
3. Multiplication
4. Division
Enter choice (1/2/3/4): 3
Enter first number: 34
Enter second number: 12
Result: 408.0

6
4. Concepts Used:

1. Functions: Modular code design is achieved


through functions for addition, subtraction,
multiplication, and division.
2. Conditional Statements: They are used to
determine which operation to perform based on
the user's choice.
3. Error Handling: The project includes a
mechanism to prevent division by zero, ensuring
robust and error-free execution.
4. Input and Output: The program captures user
input and displays the result, providing an
interactive experience.
5. Looping Constructs: Although not currently
implemented, loops could be incorporated for
continuous operation without restarting.

7
5. Future Enhancements:

1. Advanced Mathematical Operations: Future


versions could include operations like
exponentiation, square root, and trigonometric
functions.

2. Graphical User Interface (GUI): A GUI can


enhance user experience by providing a more
intuitive and visually appealing interface.

3. History and Logs: Maintain a record of all


calculations for user reference.

4. Multi-language Support: Introduce options for


multiple languages to cater to a diverse user base.

5. Mobile Compatibility: A mobile version of the


calculator could be developed for on-the-go use.

8
6. Advantages and Limitations:

Advantages:

1. Ease of Use: The simple interface ensures that


users can perform calculations with minimal
effort.
2. Efficiency: Quickly performs essential
arithmetic operations.
3. Educational Value: Helps learners understand
core programming concepts in Python.

Limitations:

1. Limited Functionality: Restricted to basic


operations in its current form.
2. Text-based Interface: Not as user-friendly as a
graphical interface.
3. No Persistent Data: The program does not
retain a history of calculations or allow for saving
results.

9
7. Bibliography:

1. Python Official Documentation:


https://docs.python.org

2. Geeks for Geeks Python Tutorials:


https://www.geeksforgeeks.org/python-
programming-language

3. W3Schools Python:
https://www.w3schools.com/python

10

You might also like