-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOctober10.py
More file actions
78 lines (56 loc) · 1.41 KB
/
October10.py
File metadata and controls
78 lines (56 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# This is the grading program we looked at earlier
# 4) Grading program - if score is > 90 you get an A,
## > 80 < 90 you get a B
## > 70 < 80 a C
## > 60 < 70 a D
## anything else you flunk
grade = 55
if grade >= 90:
print("A")
elif grade >= 80:
print("B")
elif grade >= 70:
print("C")
elif grade >= 60:
print("D")
else:
print("You Flunked!")
# We changed it to a Function:
def grader(grade):
if grade >= 90:
return "A"
elif grade >= 80:
return "B"
elif grade >= 70:
return "C"
elif grade >= 60:
return "D"
else:
return "You Flunked!"
g = grader(60)
print(g)
grades = [75,80,90,60,65,85]
def term_grader(grade):
term = sum(grade) / len(grade)
return grader(term)
print(term_grader(grades))
## Note, I cheated with the sum function:
#
# Here is a home grown one
#
def sum_list(items):
sum_numbers = 0
for x in items:
sum_numbers += x
return sum_numbers
def term_grader2(grade):
term = sum_list(grade) / len(grade)
return grader(term)
print(term_grader2(grades))
# 1. Write a program to multiply the numbers in a list.
## Hint *= is a thing
# 2. Write a program to get the largest number in a list
# 3. Assume: law_class = ["Matthew", "Hunter", "Marianna", "Brittany", "Harrison", "James","Bradley"]
# Print "Hunter"
# 4. Print out each name in law_class
# 5. Put the law_class in alphabetical order