I realized that I have been tagging each day in accordance with the 100 days of python course. Now, I am one day behind (it is day 10 of the 365 days of code but day 9 on the python course I am taking right now) because I made sure to review unclear exercises yesterday.
It is fine regardless.
On day 9 of the python course, we looked at
dictionaries, its table-likeness (2 columned)
One tiny forgotten comma leads to 4 different
errors and 1 warning, the prominent one being the SyntaxError.
But shouldn’t it highlight line 3 instead of
line 4??
Comma added, Error fixed.
My Grading Program Code:
student_scores = {
'Harry': 88,
'Ron': 78,
'Hermione': 95,
'Draco': 75,
'Neville': 60
}
student_grades = {}
for key in student_scores:
if
student_scores[key] > 90:
student_scores[key] = "Outstanding"
elif student_scores[key] > 80:
student_scores[key] = "Exceeds Expectations"
elif student_scores[key] > 70:
student_scores[key] = "Acceptable"
else:
student_scores[key] = "Fail"
student_grades = student_scores
print(student_grades)
Each key in a dictionary can only have 1
value. So, to store multiple values in a key, we have to nest it (i.e., using a
list or another dictionary).
Yayy


Comments
Post a Comment