Retirement Calculator Python Program

Posted on by admin
Programming

Need to add a loop to my calculator by giving the user an option to restart the calculator by putting the code in a while loop with the condition that the input from user should be, 'y' or 'Y'.

Feb-10-2019, 05:57 PM (This post was last modified: Feb-10-2019, 05:59 PM by missus_brown.)
I'm super new to Python and I'm really having a hard time with this assignment. The previous assignment was a basic calculator. This assignment builds on that calculator by adding a while loop and adding the option to quit. The calculator is supposed to repeatedly loop back to the beginning and ask for a new character until the user types Q to quit. The first basic calculator was working perfectly, but adding the while statement changed that.
Here's what I've got. It doesn't work right and it doesn't like the break at the bottom. I'm grateful for any guidance.
Thanks in advance for any help!
Feb-10-2019, 06:21 PM (This post was last modified: Feb-10-2019, 06:25 PM by Larz60+.)
Better to start thusly:
also change at bottom
To (no indentation):
Final code should look like:
Feb-10-2019, 06:41 PM
It works!
Also, what does 'char.lower()' do?
I've been pulling my hair out on this one. Thank you so much!!
Feb-10-2019, 08:19 PM
char.lower() returns the text of char in lower case. This allows you to test against 'q' and 'Q' with one test. This gets past this problem:
which is a misuse of the 'or' operator. It is equivalent to:
Since non-empty strings evaluate as True, 'q' is always True and the loop condition is always True.
Also, break can't be used outside of a loop, that's why it was working for you.
Craig 'Ichabod' O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Python sample program
Possibly Related Threads…
ThreadAuthorRepliesViewsLast Post
Calculator Loop Helpdock192631,763Jun-23-2021, 10:05 PM
Last Post: HereweareSwole
Python calculator help but not using while loop with true, any flags variable ,breakkirt6405131,265Jun-08-2021, 06:39 AM
Last Post: Larz60+
Weight loss calculator loop errordrogers1094077,896Feb-14-2021, 12:36 AM
Last Post: Larz60+
CalculatorRetirement Calculator Python ProgramRetirement Calculator Python Program online
Users browsing this thread: 1 Guest(s)

Retirement Calculator Python Programs

  • Retirement Calculator Python Program Using Functions Retirement Calculator Python Programiz Introduction The Python programming language is a great tool to use when working with numbers and evaluating mathematical expressions.
  • So let’s move further to create a simple python calculator. Python offers a lot of options to develop GUI applications, but Tkinter is the most usable module for developing GUI(Graphical User Interface). Since Tkinter is cross-platform so it works on both windows and Linux. So here i am using Tkinter module to create a simple python.