Sep-15-2024, 05:39 PM
(This post was last modified: Sep-16-2024, 02:21 AM by deanhystad.)
Hi everyone,
I am a neophyte and am still studying the basics. I am following a tutorial online about how using while to create a calculator software. The teacher suggested this code:
_________
Could someone please help me?? I am getting crazy!
Thanks
I am a neophyte and am still studying the basics. I am following a tutorial online about how using while to create a calculator software. The teacher suggested this code:
_________
hello_mex = """Hi! I am your virtual calculator! Here are the available functions: - if you want to perform an addition, select 1, - if you want to perform a subtraction, select 2, - if you want to perform multiplication, select 3, - if you want to perform division, select 4, - if you want to perform an exponential calculation, select 5, - if you want to perform a square root, select 6. - To exit the programme you can press Esc. while True: print(hello_mex) action = input("Enter the number corresponding to the operation to be performed: ") if action == "1": print("\n You chose: addition.\n") add_1 = float(input("Write the first number. ")) add_2 = float(input("Write the second number ")) print("The result is " str(add_1 + add_2)) new_action = input("\nDo you want to proceed with another function? Y?N ") if new_action == "Y" or new_action == "y": print("I am coming back to the menu'") continue else: print("See you!\n") breakUnfortunately, everything stops when I have to insert the number related to the function to be selected and if I press number 1, it starts again with hello_mex.
Could someone please help me?? I am getting crazy!
Thanks
Larz60+ write Sep-15-2024, 09:10 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
tags added for you this time. Please use BBCode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
tags added for you this time. Please use BBCode tags on future posts.