[Tutor] Help With Python Tasks

Ruth Hardy ruth.e.hardy at btinternet.com
Tue Sep 5 14:25:15 EDT 2017


Dear Sir or Madam 

I was wondering if you can help me please with these computer science tasks as I don’t know where to start:

First Task

Write code do the following things involving strings.  Wherever possible, you should try to incorporate functions/procedures, although they are not appropriate for all tasks.

Print a list of 20 random numbers one after the other vertically on the screen.  Half way through, use a user input request to pause printing until input is received.

Ask a user to enter two numbers, one after the other.  Your code should validate that you receive numbers and prompt the user appropriately.  For the:

first number, use try-except to ensure you have a floating point number; place a comment in you code about how this works
second number, use .isnumeric() to check you have an integer; place a comment in your code to explain why this only works for integers
Use a forced type conversion to turn both numbers into floats, divided one by the other and print the answer to 2 d.p.  You code should keep on asking for numbers until two have been received.

Ask the user to input a true/false value and convert the input to a Boolean (hint: I don’t think you can do a forced type conversion for this…)



Second Task 

Write a menu system based on functions where the main program loop is only 2 lines long

Write a simple calculator program based around a menu loop.  You should be able to enter ‘number 1’ and ‘number 2’ which will be displayed on the screen every time the menu is redisplayed’; there should also be a clear screen function used to avoid the screen getting too cluttered.

The calculator menu should allow the user to:

enter values for ‘number 1’ and ‘number 2’
add ‘number 1’ and ‘number 2’
subtract ‘number 2’ from ‘number 1’
multiply ‘number 1’ and ‘number 2’
divide ‘number 1’ by ‘number 2’
exit cleanly 
You program must display an answer that the user can read after each calculation.


I would appreciate your help so much as I need to have a finished copy  of this code by tomorrow late morning !

Kind Regards 
Miss Hardy 


More information about the Tutor mailing list