[Tutor] Basic Python help

Alan Gauld alan.gauld at yahoo.co.uk
Fri Sep 4 12:05:45 EDT 2020


On 04/09/2020 16:40, Mason Jordan wrote:
> Hi all,
> I am in a basic COMP SCI course and I am struggling to do this project.
> 
We won;t do it for you but we can help with suggestions and critique.
But, we need to see your code, or for you to ask specic questions.
Just saying you are struggling doesn't tell us much.

> Write a Python program that calculates summary statistics about a class
> assignment. 

> First, prompt the user for the number scores to be entered,

Do you know how to read input from a user?


> which should be a positive integer. 

Do you know how to convert that input to an integer...
... and test whether it is positive?

> Reprompt for 0 or negative integers.

This suggests repetition, probably some kind of loop?
Do you know how to write loops in Python, maybe a while loop?

> Then prompt for each score, 

Again some repetition.
How many times should you repeat? If you know you could use a for loop.
Do you know how to loop a fixed number of times in Python?

Do you know how to store multiple values, in a list say?

> re-prompting for values outside the range 0 - 100, inclusive. 

This is just  like the original prompt, so repeat that code
inside your for loop(a nested loop).

> Finally, display 

Do you know how to display output?

> the minimum, maximum and average scores.

Do you know how to find the min and max values of a collection?
Can you calculate the average of a list of numbers?
Hint: there is a sum() function in Python

> I have a little bit of the code written. Can anyone offer any help?

Show us the code. ask specific questions.
Show us any error messages in full.

Consider the questions above to decide which bits you are
struggling with.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list