[Tutor] problem

boB Stepp robertvstepp at gmail.com
Sun Aug 30 18:55:49 EDT 2020


On Sun, Aug 30, 2020 at 05:26:47PM -0400, Dianna Wotherspoon wrote:
>can you help me with this problem please?

Hello!  What is the problem with your problem?  What have you tried?  We
will help you figure this out, but we won't do it for you.

Can you break up your problem below into conceptual steps (or pseudocode)?

>Write a program that repeatedly prompts a user for integer numbers until
>the user enters done.

"repeatedly" suggest the use of a loop.  Perhaps a "while True:"?

"the user enters done" suggests using a conditional statement to check for
whatever you have the user to enter to indicate done, perhaps a "q" for
quit.  So perhaps something like "if user_input == 'q':" then "break" out
of your loop?

What Python statement can you use to collect "input" from the user?  What
will be the data type of the user input?  Will you need to convert it?
What Python statements will do the conversion?

> ...Once Donna entered print out the largest and smallest
>of the numbers. If the user enters anything other than a valid number catch
>it with a try accept and put out an appropriate message and ignore the
>number. Enter 7, too, Bob, 10, and 4 and match the output below.

How will you determine if the number is valid?  Hints:  Try in the
interpreter "int('a')".  What happens?  Do you get an exception?  If yes,
how can you use that in a try/except structure?

What data structure will you store all of the correctly entered numbers
into?  Does that data structure have a convenient method for determining
the minimum/maximum values contained in that structure?

Hopefully there are enough hints to get you to the point of writing some
code.  Suggestion:  Write out the steps the program must perform in the
correct order in natural language and see if you can translate that process
of ordered steps into Python.

Good luck!  If you run into problems copy-and-paste your code into a plain
text email along with the copy-and-paste of any tracebacks and someone will
try to help you out.

-- 
Wishing you only the best,

boB Stepp


More information about the Tutor mailing list