Make a Calculator using Python

Publicado em: 27 Julho 2021
no canal de: 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")


Nesta página do site você pode assistir ao vídeo on-line Make a Calculator using Python duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Programmer Krishn 27 Julho 2021, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 46 vezes e gostou 10 espectadores. Boa visualização!