Make a Calculator using Python

Pubblicato il: 27 luglio 2021
sul canale di: 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")


In questa pagina del sito puoi guardare il video online Make a Calculator using Python della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Programmer Krishn 27 luglio 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 46 volte e gli è piaciuto 10 spettatori. Buona visione!