Skip to content

Instantly share code, notes, and snippets.

@sjehutch
Created June 20, 2017 03:23
Show Gist options
  • Save sjehutch/547c2ccfb4b3d7f673bc5d888108cea2 to your computer and use it in GitHub Desktop.
Save sjehutch/547c2ccfb4b3d7f673bc5d888108cea2 to your computer and use it in GitHub Desktop.
classes=py
lottery_player = {
"name" : "scott",
"numbers" : (1,2,3,4,5,6)
}
print (lottery_player["numbers"])
class LotterPlayer :
def __init__(self):
self.name = "Tom"
self.numbers = (1,2,3,4,5)
def total(self):
return sum (self.numbers)
player1 = LotterPlayer()
print (player1.name)
print (player1.numbers)
print (player1.total())
class Student:
def __init__(self , name , school ):
self.name = name
self.school = school
self.grades = []
def average (self):
return sum(self.grades) / len (self.grades)
scott = Student("Scott" , "MIT" )
scott.grades = [60,60,70,90,100]
print (scott.average())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment