print("Calculator")
print ("1 - Addition")
print ("2 - Subtraction")
print ("3 - Multiplication")
print ("4 - Division")
func = None
func = int(input())
def function():
if (func == 1):
print ("Addition")
print ("Enter first number")
x= int(input())
print ("Enter second number")
y = int(input())
print (x+y)
elif(func == 2):
print ("Subtraction")
print ("Enter first number from which second number should be subtracted")
x= int(input())
print ("Enter second number")
y = int(input())
print (x-y)
elif(func == 3):
print ("Multiplication")
print ("Enter first number")
x= int(input())
print ("Enter second number")
y = int(input())
print (x*y)
elif(func == 4):
print ("Division")
print ("Enter first number")
x= int(input())
print ("Enter second number")
y = int(input())
print (x/y)
else:
print ("Please enter corrent number for function")
func = int(input())
function()
function()
As you can see in my code I want to make a python simple calculator and when I input any other number greater than four. I want my application to restart the function.
Aucun commentaire:
Enregistrer un commentaire