Professional Documents
Culture Documents
Project Report On Simple Calculator Python: Academic Year: 2022-2023 Class: XI-A Subject Code: 083
Project Report On Simple Calculator Python: Academic Year: 2022-2023 Class: XI-A Subject Code: 083
Apart from my efforts, the success of any project depends largely on the encouragement and
guidelines of many others. I take this opportunity to express my gratitude to the people who have
been instrumental in the successful completion of this project.
I gratefully acknowledge the contribution of the individuals who contributed in bringing this
project up to this level, who continue to look after me despite my flaws.
I would like to thank our computer faculty, who always guided me in our proceeding. I am also
thankful to my friends who helped me.
Index
1. Synopsis
2. Source Code
3.Reference
SYNOPSIS
Creating a simple calculator which can perform basic arithmetic operations like
addition, subtraction, multiplication, or division depending upon the user input.
Approach:
User chooses the desired operation. Options 1, 2, 3, and 4 are valid.
Two numbers are taken and an if…elif…else branching is used to execute a
particular section.
Using functions add(),subtract(),multiply() and divide() evaluate respective
operations.
If any other input is given, invalid input is displayed and the loop continues until a
valid option is selected.
Two numbers are taken and an if…elif…else branching is used to execute a
particular section. User-defined functions add(), subtract(), multiply() and divide
() evaluate respective operations and display the output.
SOURCE CODE:
while True:
choice = input("Enter choice(1/2/3/4): ")
if choice in ('1', '2', '3', '4'):
try:
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
except ValueError:
print("Invalid input. Please enter a number.")
continue
if choice == '1':
print(num1, "+", num2, "=", add(num1, num2))
elif choice == '2':
print(num1, "-", num2, "=", subtract(num1, num2))
elif choice == '3':
print(num1, "*", num2, "=", multiply(num1, num2))
elif choice == '4':
print(num1, "/", num2, "=", divide(num1, num2))
next_calculation = input("Let's do next calculation? (yes/no): ")
if next_calculation == "no":
break
else:
print("Invalid Input")
OUTPUT:
Select operation:
1.Add
2.Subtract
3.Multiply
4.Divide
Enter choice (1/2/3/4): 1
Enter first number: 22
Enter second number: 10
22.0 + 10.0 = 32.0
Let's do next calculation? (yes/no): yes
Enter choice (1/2/3/4): 2
Enter first number: 10
Enter second number: 10
10.0 - 10.0 = 0.0
Let's do next calculation? (yes/no): yes
Enter choice (1/2/3/4): 3
Enter first number: 13
Enter second number: 1
13.0 * 1.0 = 13.0
Let's do next calculation? (yes/no): yes
Enter choice (1/2/3/4): 4
Enter first number: 50
Enter second number: 10
50.0 / 10.0 = 5.0
Let's do next calculation? (yes/no): no