Created
June 20, 2017 03:23
-
-
Save sjehutch/547c2ccfb4b3d7f673bc5d888108cea2 to your computer and use it in GitHub Desktop.
classes=py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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