Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pdpinch
Created November 10, 2012 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdpinch/4051746 to your computer and use it in GitHub Desktop.
Save pdpinch/4051746 to your computer and use it in GitHub Desktop.
# ********** Exercise 2.8 **********
import math
def report_card():
##### YOUR CODE HERE #####
count_classes = int(input("How many classes did you take? "))
grade_book = {}
total = 0
for i in range(count_classes):
name = input("What was the name of this class? ")
grade = input("What was your grade? ")
grade_book[name] = grade
total += grade
# print total
print "REPORT CARD:"
for course in grade_book:
print course, "-", grade_book[course]
print "Overall GPA ", round(float(total)/count_classes,2)
# report_card()
# Test Cases
## In comments, show the output of one run of your function.
##How many classes did you take? 3.01
##What was the name of this class? 18.01
##What was your grade? 97
##What was the name of this class? 18.02
##What was your grade? 97
##What was the name of this class? 18.03
##What was your grade? 98
##REPORT CARD:
##18.01 - 97
##18.02 - 97
##18.03 - 98
##Overall GPA 97.33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment