0% found this document useful (0 votes)
2 views2 pages

Python Calculator with Menu Options

The document contains a Python script that implements a simple calculator with options for addition, subtraction, multiplication, division, calculating the hypotenuse, and modulo operations. It prompts the user to enter two values and select an operation from a menu, then displays the result. The program also allows the user to restart the calculation process if desired.

Uploaded by

kineme
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Python Calculator with Menu Options

The document contains a Python script that implements a simple calculator with options for addition, subtraction, multiplication, division, calculating the hypotenuse, and modulo operations. It prompts the user to enter two values and select an operation from a menu, then displays the result. The program also allows the user to restart the calculation process if desired.

Uploaded by

kineme
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

def main():

​ num1 = float(input("Enter the first value:"))


​ num2 = float (input("Enter the first value:"))
​ print(" ")
​ print("Menu")
​ print("[Link]")
​ print("[Link]")
​ print("[Link]")
​ print("[Link]")
​ print("[Link]")
​ print("[Link]")
​ print(" ")

​ name = int(input("Enter your choice:"))
​ if name == 1:
​ ​ add = num1 + num2;
​ ​ print('Your Final Output is: ',add)
​ ​
​ elif name==2:
​ ​ sub = num1 - num2;
​ ​ print('Your Final Output is: ',sub)

​ elif name==3:
​ ​ multi = num1 * num2;
​ ​ print('Your Final Output is: ',multi)
​ ​ ​ ​
​ elif name==4:
​ ​ div = num1 /num2;
​ ​ print('Your Final Output is: ',div)
​ ​
​ elif name==5:
​ ​ hyp= num1 * num1 +num2 * num2;
​ ​ print('Your Final Output is: ',hyp)
​ ​
​ elif name==6:
​ ​ mod= num1 % num2;
​ ​ print('Your Final Output is: ',mod)
​ ​
​ else:
​ print("invalid")

​ restart=input("Would you like to try again (yes or no) ")


​ if restart == "yes":
​ ​ main ()
​ else:
​ ​ exit()
​ ​
main()

You might also like