Win a copy of Securing DevOps this week in the Security forum!
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# Python Calculator: Several options, changing the number

Greenhorn
Posts: 19
Hello I am new to python and I am trying to do an assignment but I couldn't get the needed output I am supposed to
get. Can any one suggest me what I am missing? Thank you!
Assignment:
The last exercise in this chapter continues with the exercise from the last chapter, the calculator. In this exercise, expand the existing code by implementing the following new features: (A) Calculator does not automatically quit when the result is given, allowing user to do new calculations. The user has to select "6" in the menu to exit the program. (B) The calculator shows the selected numbers in the main menu by printing "Current numbers:" and the user-given input. By selecting "5" in the calculator menu, the user can change the given numbers. When implemented correctly, the program prints out following:
Again, implement the program within one large while True-segment, which is terminated with break if the user selects the option "6".
Example output

Calculator
Give the first number: 100
Give the second number: 25
(1) +
(2) -
(3) *
(4) /
(5)Change numbers
(6)Quit
Current numbers: 100 25
Give the first number: 10
Give the second number: 30
(1) +
(2) -
(3) *
(4) /
(5)Change numbers
(6)Quit
Current numbers: 10 30
The result is: 40
(1) +
(2) -
(3) *
(4) /
(5)Change numbers
(6)Quit
Current numbers: 10 30
Thank you!

My code's output:
Calculator
Give the first number: 100
Give the second number: 25
(1) +
(2) -
(3) *
(4) /
(5)Change numbers
(6)Quit
Current numbers: 100 25
Change numbers
Give the first number: 10
Give the second number: 30
(1) +
(2) -
(3) *
(4) /
(5)Change numbers
(6)Quit
Current numbers: 10 30