POST
|
I have been taking an online python course and figured I'd try to create a grade calculator to apply what I have learned so far. I got my calculator to work, but I am stuck on one part. I want to call the "exams" list seen in bold to the def get_average function. I want to replace the bolded part of the function to something that calls the "exams" list and does the same thing as the current bolded portion of the function. I guess the question is how to do I call a list from a dictionary to a function? tay = { "name": "Taylor", "attendance": [100.0, 0.0, 100.0, 100.0, 0.0, 100.0, 100.0, 100.0, 100.0, 100.0], "labs": [75.0, 80.0, 95.0, 95.0, 100.0], "exams": [84.0, 88.0, 91.0, 95.0], } #if you know anyway to make this a shorter script please let me know... call in list "exams"? #I would also like to dump grades and weights of grades into a text file and call them into the script... not top priority though. def average(numbers): total = sum(numbers) total = float(total) return total/len(numbers) def get_average(student): attendance = average(student["attendance"]) labs = average(student["labs"]) return 0.05 * attendance + 0.15 * labs + 0.20 * tay["exams"][0] + 0.20 * tay["exams"][1] + 0.20 * tay["exams"][2] + 0.20 * tay["exams"][3] def get_letter_grade(score): if score >= 90: return "A " elif score >=80: return "B" elif score >=70: return "C" elif score >=60: return "D" else: return "F" print get_letter_grade(get_average(tay))
... View more
07-25-2019
12:24 PM
|
0
|
1
|
406
|
POST
|
I have some rasters that take forever to draw when I zoom in or out. I am trying to build pyramids to speed up raster rendering. I keep getting this error message. Any thoughts?
... View more
06-05-2019
07:37 AM
|
0
|
2
|
348
|
Online Status |
Offline
|
Date Last Visited |
08-24-2021
03:18 PM
|