Python Forum
calculating and accumulating scores
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
calculating and accumulating scores
#1
I am trying to accumulate the numbers from the question and then print a reply based on whether the total is above or below 7, but I keep getting syntax errors. Any ideas? I need to have a float, loop, one operator symbol (+,-,*) an accumulation pattern,and a conditional statement comparing numbers.



score=0
questions = ['How long can your assignment wait until its done?', 'How good are the conditions?','Will you have time to study after you ski?']

#rate each question on a scale of 1-5
for question in questions:
  rating=float(input(question))
score += rating

if score is >= 7:
  print("")
elif rating is (<=7):
  print("")
else:
  print("")

#calculate the weighted average score 


#If score is 7 or above, print you should study, if score is below 7, pring you should ski
Reply
#2
Please use python tags in your post for the code. Otherwise the indentation is difficult to see.

is is a type of python comparison and > (and similar) is a type of comparison. You don't use them together, so is > will not make sense. Fix that (and the odd parentheses on the elif line) and you should be a lot closer.
Reply
#3
Line 7 needs to be indented to be inside the loop
Put something inside the quotes on your print statements so you can see the result
Your if comparison in line 9 compares (once you fix as above) score with 7. The elif compares rating with 7 (once you again fix). I don't think you mean that.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Find Average of User Input Defined number of Scores DustinKlent 1 4,328 Oct-25-2019, 12:40 AM
Last Post: Larz60+
  [NLTK] How to calculate lexical diversity scores in Jupyter? vanicci 4 11,445 Sep-01-2018, 09:43 AM
Last Post: vanicci

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020