How to make a Simple calculator with Python
In this blog we are making a simple calculator with python that can add, subtract, multiply, divide according to the user's Input.
Output:
Welcome to my Calculator
Type 1 for subtraction , 2 for addition , 3 for multiplication , 4 for Division
3
Enter 1st No.
21314
Enter 2nd No.
098035
Multiplication of 21314 and 98035 = 2089517990
Let's Make it..
# Making a simple Calculator
print('Welcome to my Calculator')
# Make several Functions
def subtract():
print('Enter 1st No.')
ans = int(input())
print('Enter 2nd No.')
ans1 = int(input())
# Calculate the Number
print(f'Subtraction of {ans} and {ans1} = ', int(ans) - int(ans1))
def add():
print('Enter 1st No.')
ans2 = int(input())
print('Enter 2nd No.')
ans3 = int(input())
# Calculate the Number
print(f'Addition of {ans2} and {ans3} = ', int(ans2) + int(ans3))
def multiply():
print('Enter 1st No.')
ans4 = int(input())
print('Enter 2nd No.')
ans5 = int(input())
# Calculate the Number
print(f'Multiplication of {ans4} and {ans5} = ', int(ans4) * int(ans5))
def divide():
print('Enter 1st No.')
ans6 = int(input())
print('Enter 2nd No.')
ans7 = int(input())
# Calculate the Number
print(f'Division of {ans6} and {ans7} = ', int(ans6) - int(ans7))
if __name__ == "__main__":
print("Type 1 for subtraction , 2 for addition , 3 for multiplication , 4 for Division")
ans10 = int(input())
if ans10 == 1:
subtract()
if ans10 == 2:
add()
if ans10 == 3:
multiply()
if ans10 == 4:
divide()
Output:
Welcome to my Calculator
Type 1 for subtraction , 2 for addition , 3 for multiplication , 4 for Division
3
Enter 1st No.
21314
Enter 2nd No.
098035
Multiplication of 21314 and 98035 = 2089517990
0 Comments
If You Guys Have Any Doubt So, Please Comment Down Below !