Hello all. 

I recently starting taking Python in my state college. I joined the Python.org 
users group and I posted a couple of codes examples that I was having problems 
with, and I am wondering if there is anyone in this community that can help me. 
I did get some great advice on my previous posts however my code is still not 
working. I have two problems that I have to write code for. 

The first problem is a program that will take a list of ten grades from a user 
and then calculate the average of the ten numbers entered. The user can only 
use the numbers 1-10. Example. "The total average of the grades you entered in 
was 5" which would be the average using number 1-10 in a sequence, but it needs 
to calculate an average no matter if the user puts in 3 "5's" and 7 "10's". The 
average must be calculated. 

I did get some help in the python forums with this and I have come up the 
following, but I am getting a syntax error on the line that calls out "total" 
as a variable. Here is the code:

value = [ ]

for i in range(10):
    range += 1
    print (int(float(raw_input("Please enter a grade, use numbers 1 - 10: ")))  
     
     
# getting a syntax error on this line    
total = sum(value)

average = total/10.0    
       
print "The average sum of all of the grades that you entered is ", ("%.2f" %  
average)


raw_input("\nPlease hit enter to quit.")

///The code does not work. 


The next problem is supposed to use the while loop. A user is supposed to enter 
some grade values. The user will continue to be prompted to enter grade values 
until the user has entered in "9999" as  a grade value. Then the program is 
supposed to calculate the average of all of the grades entered including the 
9999. 

Here is my code, This code is not working either:

target = 9999

value = [ ]

while i in value < or not == target:
      i += 1
      print grade (int(float(raw_input("Please enter a grade: ")))
     
                  
total = sum(value)

average = total/target

print "The average grade that you entered is ", ("%.2f" % average)
        
raw_input("Please hit enter to exit.")


///Can anyone tell me what I am doing wrong on either of these problems? I know 
it is a logic error, but I am new to this so please bare with me. Again, thanks 
for your help. I am new to this forum so please have patience with me when I am 
posting. 

Thank you, 



Thomas Mundahl



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to