In [ ]:
### This code WILL NOT RUN: Just a template to show you how to set things up
## Import statements at the top of your code
from random import randrange
## Define classes before defining functions
class Die:
def main():
main()
In [ ]:
from random import randrange
class Die:
def __init__(self, sides):
self.sides = sides
self.value = 1
def roll(self):
self.value = randrange(1, self.sides+1)
def getValue(self):
return self.value
def setValue(self, value):
self.value = value
def getSides(self):
return self.sides
def main():
d20 = Die(20)
for i in range(5):
d20.roll()
print d20.getValue()
main()
In [ ]:
class Student:
def __init__(self, name, hours, qpoints):
self.name = name
self.hours = float(hours)
self.qpoints = float(qpoints)
def getName(self):
return self.name
def getHours(self):
return self.hours
def getQPoints(self):
return self.qpoints
def gpa(self):
return self.qpoints/self.hours
def makeStudents():
henry = Student("Henry", 127, 288)
print henry.gpa()
makeStudents()