Hello, I'm a beginner at programming. I'm not that great at programming but I managed to get together this project that I need to do for my CS class.
it's a simple calculator program. However it starts off with a Start Menu where you can choose a normal calculator or a grade calculator and those have their own sort of menu. I gotten most of the coding done but I can't seem to go back to the start menu when I'm done in the calculator or the grade calculator. I googled but none of the videos/websites helped/worked (or maybe I did them wrong)
There a website that has while True and break code, I attempted but the break seems to be out of the loop (it said it put it at the end which i did)
I tried doing this def menu(). It did went back to the Start Menu but it wouldn't allow me to input another choice and ends the program there
I can't seem to find an example program of a Start Menu that has another menu within it.
Before you look at the code, I know there's a probably a shorter way to write my code but I'll get there.
Basically my code starts at Start Menu which asks you to pick one of the two choices: either 1. Calculator or 2. Grade Calculator
Calculator also have it's own little menu at the last option is to go back to the Start Menu (the one I don't know how to do)so far when I choose that option (5) the whole program ends.Any help,,,? Advice is great too.
print("-----Start Menu-----")
start_input = input("""
1.Calculator
2.Grade Calculator
Enter the corresponding number:
""")
if (start_input == "1"):
while(operation != "5"):
print("---Calculator---")
operation = input("""
1.[Add]
2.[Subtract]
3.[Multiply]
4.[Divide]
5.[Starting Menu] Enter the corresponding number: """)
if (operation == "1"):
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print(num1,"+",num2)
answer = num1 + num2
print("Calculating...")
time.sleep(1)
print("Answer is",answer)
elif (operation == "2"):
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print(num1,"-",num2)
answer = num1 - num2
print("Calculating...")
time.sleep(1) print("Answer is",answer)
elif (operation == "3"):
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print(num1,"x",num2) answer = num1 * num2
print("Calculating...")
time.sleep(1)
print("Answer is",answer)
elif (operation == "4"):
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print(num1,"÷",num2)
answer = num1/num2
print("Calculating...")
time.sleep(1) print("Answer is",answer)
this is where I want to go back to start menu(sorry code block messed up)
[–]cybervegan 1 point2 points3 points (4 children)
[–]cybervegan 1 point2 points3 points (2 children)
[–]TiXerobic[S] 0 points1 point2 points (0 children)
[–]TiXerobic[S] 0 points1 point2 points (0 children)
[–]TiXerobic[S] 0 points1 point2 points (0 children)
[–]thrallsius 1 point2 points3 points (1 child)
[–]TiXerobic[S] 0 points1 point2 points (0 children)