Make a Calculator using Python

Published: 27 July 2021
on channel: Programmer Krishn
46
10

Hi Subscribers,
In this video I have shown you how you can make a basic Calculator. Hope you have got helped with it.
If you found video informative then make sure to like share and subscribe.
Thankyou Subscribers....

.......................................................................................................................

Here is the program,

#program to make simple caculator
#define the function

def add(x,y):
""""This function adds 2 numbers"""
return x + y

def subtract(x,y):
"""""This function subtract 2 numbers"""
return x - y

def multiply(x,y):
""""This function multiplies 2 numbers"""
return x * y

def divide(x,y):
""""This function divides 2 numbers"""
return x/y

def power(x,y):
""""This gives power"""

return pow(x,y)

#take input from user
print("Select operation")
print ("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")
print("5.Power")
choice=input("Enter choice 1/2/3/4/5:")

num1 = int(input("Enter the first number"))
num2 = int(input("Enter the second number"))

if choice == '1':
print(num1, "+", num2,"=", add(num1,num2))

elif choice == '2':
print(num1, "-", num2,"=", subtract(num1,num2))

elif choice == '3':
print(num1, "x", num2,"=", multiply(num1,num2))

elif choice == '4':
print(num1, "/", num2,"=", divide(num1,num2))

elif choice == '5':
print(num1, "^", num2,"=", power(num1,num2))

else:
print("Invalid Input")


On this page of the site you can watch the video online Make a Calculator using Python with a duration of hours minute second in good quality, which was uploaded by the user Programmer Krishn 27 July 2021, share the link with friends and acquaintances, this video has already been watched 46 times on youtube and it was liked by 10 viewers. Enjoy your viewing!