Python Forum
Calculator: several options, changing the number
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculator: several options, changing the number
#1
Hi, I'm a beginner to Python and have been struggling with this assignment since yesterday: the user gives 2 numbers and then selects an action (1-6). If the selection is 5 then the user can change the given numbers and that's where I don't know how to proceed because the whole structure needs to be displayed again.

Here's my code:
print("Calculator")
def Loop():
	number1 = int(input("Give the first number: "))
	number2 = int(input("Give the second number: "))
	print("(1) +")
	print("(2) -")
	print("(3) *")
	print("(4) /")
	print("(5)Change numbers")
	print("(6)Quit")
	print("Current numbers: ",number1,number2)
	
	select = int(input("Please select something (1-6): "))
	if select == 5:
		Loop()
	if select == 1:
		print("The result is:", number1 + number2)	
	elif select == 2:
		print("The result is:", (number1 - number2))
	elif select == 3:
		print("The result is:", number1 * number2)
	elif select == 4:
		print("The result is:", number1 / number2)
	else:
		print("Selection was not correct.")
Loop()
When running this and selecting 5, the paragraphs "(1) + \n(2) -\n(3) *\n(4) /" and the rest are no longer shown
Reply


Messages In This Thread
Calculator: several options, changing the number - by gus17 - Dec-28-2019, 08:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  list all the different options that are filled in oog70 1 1,903 Sep-13-2019, 03:33 PM
Last Post: ichabod801
  python age calculator need to find the number of years before they turn 100 not using orangevalley 4 10,003 Mar-26-2018, 04:44 AM
Last Post: PyMan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020