I need to write a program as following: Write, test and debug a program to calculate and output the minimum, maximum, and
average of a list of positive test scores. Ask the user how many scores s/he intends to enter.
Assume exactly that many scores will be entered one per line. Prompt for each score. Here is the
example program dialog:
Enter the total number of scores: 4
Enter the scores:
Score 1 10
Score 2 36
Score 3 5.5
Score 4 0.5
The minimum is: 0.5

I've been trying to write the program to calculate the average of a user's input of test scores. Please help me, my professor won't explain sh**. to us .

That's what I have so far. Now the problem I'm facing is how to print the min and the max numer out of the user's input.

n=eval(raw_input("Enter the total number of scores: "))
sum = 0.0
sn =1 
for i in range (0,n):
   x = (input("Enter score " + str(sn) + " : " ))
   sn = sn+1 
   sum = sum + x
average = sum / n
print "Total = " + str(sum)
print "Average = " + str(average) 

Edited 3 Years Ago by pyTony: code block not marked as such by indent

Put two variables(min and max) equal to the first input.
For the second and subsequent inputs test
if in < min,==>min=in
if in > max,==>max=in
At the end min will contain the minimum input and max the maximum input.
Success!

i'm sorry for being difficult. I saw and understood your reply, I just don't know how to write it in my program. I just began learning Python a week ago and don't have enough skills to pull this off.
In the program i wrte, what do you think the best way to implement your solution? also, I would love to hear your feedback about my program writing. (even though it's very basic.)

You are close. Just a reminder, don't use sum, min, max as variable names since they are functions in Python. I like to prefix with 'my'. Start with a high mymin value (let's say 100) and make it x if x is lower. With mymax you start low (zero) and make it x if x is higher.

Once you learn about lists then you can apply methods sum(), min() and max() and your life will be simpler. For example ...

n = int(raw_input("Enter the total number of scores: "))
mylist = []
sn = 1
for i in range(n):
    x = int(raw_input("Enter score " + str(sn) + " : " ))
    mylist.append(x)
    sn += 1

mysum = sum(mylist)
# mysum needs to be a float
# or you get integer division in Python2
average = 1.0*mysum / n

print "Total = " + str(mysum)
print "Average = " + str(average)
print "Minimum = " + str(min(mylist))
print "Maximum = " + str(max(mylist))

Once you get better with Python27, you will actually code this way ...

n = int(raw_input("Enter the total number of scores: "))
mylist = []
for ix, k in enumerate(range(n)):
    x = int(raw_input("Enter score {} :".format(ix+1)))
    mylist.append(x)

# mysum needs to be a float
# or you get integer division in Python2
mysum = float(sum(mylist))
average = mysum / n

print("Total = {}".format(mysum))
print("Average = {}".format(average))
print("Minimum = {}".format(min(mylist)))
print("Maximum = {}".format(max(mylist)))

Edited 3 Years Ago by vegaseat

Comments
He! Your answer also helped me!

I need your help again. The professor said not to use a list to solve this. this is what Ihave so far:
x = int(raw_input("Enter the total number of scores: "))

minimum = 100
maximum = 1
sn = 0
ts = 0
for score in range(sn,x):

    sc = float(raw_input("Score " + str(sn+1) + ": "))


ts+=sc
if sc < 0:
    print ("Invalid entry - this number will be ignored :")
    ts = ts
    sn -= 1 
elif sc < minimum:
  minimum = sc
  sn += 1
  ts +=sc
elif sc > maximum:
  maximum = sc
  sn += 1
  ts +=sc

average = ts/(sn-1)
print "Total score = " + str(ts)
print "Average = " + str(average)
print "The minimum is:" + str (minimum)

print "The maximum is:" + str (maximum)

My main problem now is how to calculate the average (while ignoring the negative user input). Thanks in advance for your help. I'll repost the question exactly how he wrote it so you'll see what I'm trying to do.

Here's the question:
Part1- Write, test and debug a program to calculate and output the minimum, maximum, and
average of a list of positive test scores. Ask the user how many scores s/he intends to enter.
Assume exactly that many scores will be entered one per line. Prompt for each score. Here is the
example program dialog:

Enter the total number of scores: 4
Enter the scores:
Score 1 10
Score 2 36
Score 3 5.5
Score 4 0.5

The minimum is: 0.5
The maximum is: 36 The average is: 26

When your program is working correctly, run it with this set of seven values: 89, 78, 90, 76, 70,
88, 79

This question has already been answered. Start a new discussion instead.