88 lines
1.5 KiB
Python
88 lines
1.5 KiB
Python
|
# SLIDE 2
|
||
|
|
||
|
# Create a list of grades
|
||
|
grades = [10,20,30,40]
|
||
|
|
||
|
#print grades
|
||
|
print(grades)
|
||
|
|
||
|
# SLIDE 3
|
||
|
|
||
|
# Concatenate grades
|
||
|
grades = grades + [50,60,70]
|
||
|
|
||
|
# Print grades
|
||
|
print("After concatenation: " + str(grades))
|
||
|
|
||
|
#SLIDE 4
|
||
|
|
||
|
# Append to grades
|
||
|
grades.extend([50,60,70,70])
|
||
|
print("After extending the list: " + str(grades))
|
||
|
|
||
|
# Find the count, total, min, max average grade
|
||
|
print("Count of grades: " + str(len(grades)))
|
||
|
|
||
|
# SLIDE 5
|
||
|
|
||
|
# Print min & Max
|
||
|
print("Min of grades: " + str(min(grades)))
|
||
|
print("Max of grades: " + str(max(grades)))
|
||
|
|
||
|
# SLIDE 6
|
||
|
|
||
|
# Print total
|
||
|
total = 0
|
||
|
for item in grades:
|
||
|
total += item
|
||
|
|
||
|
print("Total of grades is: " + str(total))
|
||
|
|
||
|
# SLIDE 7
|
||
|
|
||
|
# Average of grades
|
||
|
|
||
|
avg_grade = total / len(grades)
|
||
|
print("Average grade: " + str(round(avg_grade, 2)))
|
||
|
|
||
|
# SLIDE 8
|
||
|
|
||
|
from statistics import *
|
||
|
# Simple average
|
||
|
print("Simple average: " + str(round(mean(grades), 2)))
|
||
|
# Simple total
|
||
|
print("Simple sum is: " + str(round(sum(grades), 2)))
|
||
|
|
||
|
# SLIDE 9
|
||
|
|
||
|
superbowl_teams = ["Patriots", "Patriots", "Steelers", "Steelers", "Ravens", "Chiefs", "Packers"]
|
||
|
|
||
|
print("Superbowl Champions:")
|
||
|
for teams in superbowl_teams:
|
||
|
print("\t" + teams)
|
||
|
|
||
|
# SLIDE 10
|
||
|
|
||
|
unique = []
|
||
|
dupes = []
|
||
|
|
||
|
for j in superbowl_teams:
|
||
|
if j not in unique:
|
||
|
unique.append(j)
|
||
|
else:
|
||
|
dupes.append(j)
|
||
|
|
||
|
# SLIDE 11
|
||
|
|
||
|
if len(dupes) != 0:
|
||
|
print("Teams that have won multiple championships: ")
|
||
|
|
||
|
for i in dupes:
|
||
|
print(i)
|
||
|
|
||
|
# Check unique teams
|
||
|
if len(unique) != 0:
|
||
|
print("These teams have all won a super bowl: ")
|
||
|
|
||
|
for k in unique:
|
||
|
print(k)
|