In [6]:
quizzes = [5,5,4,2,2,4,5,3]
In [2]:
# definiate loop
for quiz in quizzes:
print("Grade:", quiz)
In [3]:
# definite loop with indexes
print(len(quizzes))
for i in range(len(quizzes)):
print("Quiz %d Grade: %d" %( i, quizzes[i]))
In [7]:
# indexes
#print(quizzes[0]) # first
#print(quizzes[-1]) # last
print(quizzes)
# mutable
quizzes[1] = 0
print(quizzes)
#slices
print(quizzes[0:3])
print(quizzes[3:])
In [8]:
# aggregations
print("Count",len(quizzes))
print("Total", sum(quizzes))
print("Average", sum(quizzes)/len(quizzes))
In [9]:
grades = ["A", "B+", "A", "C+", "B-"]
grades[:2]
Out[9]:
In [10]:
print(grades)
In [ ]:
grades.append('')