• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 Python Basic Calculator jamie Developer   Posts: 63 Threads: 63 Joined: Jul 2018 Reputation: 0 06/07/2018, 05:02 PM (This post was last modified: 07/07/2018, 11:56 PM by jamie.) Code:```# #4/7/2018 #name print("******************************") print(" ") print("******************************") print("\n\n") def add(x, y):   return x + y def subtract(x, y):   return x - y def multiply(x, y):   return x * y def divide(x, y):   return x / y print("Select symbol.") print("1.add\n2.sub\n3.mul\n4.div")   choice = input("Enter choice (1,2,3 or 4):") num1 = int(input("Enter first number: ")) num2 = int(input("Enter 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,"*",num2,"=", multiply(num1,num2)) elif choice == '4':   print(num1,"/",num2,"=", divide(num1,num2)) else:   print("Invalid symbol")``` Disclaimer: Don't be misguided looking at my usergroup and assume whatever I say is official. When I speak in community I am just a member with personal opinions. « Next Oldest | Next Newest »

Forum Jump:

Users browsing this thread: 1 Guest(s)  