for i in range(turns): t.setheading(randint(0, 360)) t.________________
#the entry point of execution main()
47
New cards
Turtle, randint
""" Purpose: Take a random walk and leave the track in random colors """ from turtle import ______ from random import _______
def main(): '''The main function of the program''' #create a turtle goody = Turtle()
#hide the turtle's body goody.hideturtle()
#set the color (RGB) mode to true color system goody.screen.colormode(255)
#start walking randomly randomWalk(goody, 30, 50)
def randomWalk(t, turns, distance): '''Walk randomly''' for i in range(turns): t.pencolor(randint(0,255), randint(0,255), randint(0,255)) t.setheading(randint(0,360)) t.forward(distance)
#the entry point of execution main()
48
New cards
Turtle()
""" Purpose: Take a random walk and leave the track in random colors """ from turtle import Turtle from random import randint
def main(): '''The main function of the program''' #create a turtle goody = _______
#hide the turtle's body goody.hideturtle()
#set the color (RGB) mode to true color system goody.screen.colormode(255)
#start walking randomly randomWalk(goody, 30, 50)
def randomWalk(t, turns, distance): '''Walk randomly''' for i in range(turns): t.pencolor(randint(0,255), randint(0,255), randint(0,255)) t.setheading(randint(0,360)) t.forward(distance)
#the entry point of execution main()
49
New cards
goody.hideturtle()
""" Purpose: Take a random walk and leave the track in random colors """ from turtle import Turtle from random import randint
def main(): '''The main function of the program''' #create a turtle goody = Turtle()
#hide the turtle's body __________________
#set the color (RGB) mode to true color system goody.screen.colormode(255)
#start walking randomly randomWalk(goody, 30, 50)
def randomWalk(t, turns, distance): '''Walk randomly''' for i in range(turns): t.pencolor(randint(0,255), randint(0,255), randint(0,255)) t.setheading(randint(0,360)) t.forward(distance)
#the entry point of execution main()
50
New cards
screen.colormode(255)
""" Purpose: Take a random walk and leave the track in random colors """ from turtle import Turtle from random import randint
def main(): '''The main function of the program''' #create a turtle goody = Turtle()
#hide the turtle's body goody.hideturtle()
#set the color (RGB) mode to true color system goody._________________
#start walking randomly randomWalk(goody, 30, 50)
def randomWalk(t, turns, distance): '''Walk randomly''' for i in range(turns): t.pencolor(randint(0,255), randint(0,255), randint(0,255)) t.setheading(randint(0,360)) t.forward(distance)
#the entry point of execution main()
51
New cards
pencolor
""" Purpose: Take a random walk and leave the track in random colors """ from turtle import Turtle from random import randint
def main(): '''The main function of the program''' #create a turtle goody = Turtle()
#hide the turtle's body goody.hideturtle()
#set the color (RGB) mode to true color system goody.screen.colormode(255)
#start walking randomly randomWalk(goody, 30, 50)
def randomWalk(t, turns, distance): '''Walk randomly''' for i in range(turns): t.________(randint(0,255), randint(0,255), randint(0,255)) t.setheading(randint(0,360)) t.forward(distance)
#the entry point of execution main()
52
New cards
randint(0,255), randint(0,255), randint(0,255)
""" Purpose: Take a random walk and leave the track in random colors """ from turtle import Turtle from random import randint
def main(): '''The main function of the program''' #create a turtle goody = Turtle()
#hide the turtle's body goody.hideturtle()
#set the color (RGB) mode to true color system goody.screen.colormode(255)
#start walking randomly randomWalk(goody, 30, 50)
def randomWalk(t, turns, distance): '''Walk randomly''' for i in range(turns): t.pencolor(________________________________________) t.setheading(randint(0,360)) t.forward(distance)
#the entry point of execution main()
53
New cards
setheading(randint(0,360))
""" Purpose: Take a random walk and leave the track in random colors """ from turtle import Turtle from random import randint
def main(): '''The main function of the program''' #create a turtle goody = Turtle()
#hide the turtle's body goody.hideturtle()
#set the color (RGB) mode to true color system goody.screen.colormode(255)
#start walking randomly randomWalk(goody, 30, 50)
def randomWalk(t, turns, distance): '''Walk randomly''' for i in range(turns): t.pencolor(randint(0,255), randint(0,255), randint(0,255)) t._______________________ t.forward(distance)
#the entry point of execution main()
54
New cards
t.forward(distance)
""" Purpose: Take a random walk and leave the track in random colors """ from turtle import Turtle from random import randint
def main(): '''The main function of the program''' #create a turtle goody = Turtle()
#hide the turtle's body goody.hideturtle()
#set the color (RGB) mode to true color system goody.screen.colormode(255)
#start walking randomly randomWalk(goody, 30, 50)
def randomWalk(t, turns, distance): '''Walk randomly''' for i in range(turns): t.pencolor(randint(0,255), randint(0,255), randint(0,255)) t.setheading(randint(0,360)) ___________________
#the entry point of execution main()
55
New cards
main()
""" Purpose: Take a random walk and leave the track in random colors """ from turtle import Turtle from random import randint
def main(): '''The main function of the program''' #create a turtle goody = Turtle()
#hide the turtle's body goody.hideturtle()
#set the color (RGB) mode to true color system goody.screen.colormode(255)
#start walking randomly randomWalk(goody, 30, 50)
def randomWalk(t, turns, distance): '''Walk randomly''' for i in range(turns): t.pencolor(randint(0,255), randint(0,255), randint(0,255)) t.setheading(randint(0,360)) t.forward(distance)
#the entry point of execution _______
56
New cards
turtle, Turtle
''' Purpose: Draw a colorful donut ''' from _____ import _______ from random import randint
def donut(): '''The main function of the program''' #create a turtle goofy = Turtle()
#hide the turtle's body goofy.hideturtle()
#set RGB mode goofy.screen.colormode(255)
#draw the donut for i in range(20): #randomize pen color goofy.pencolor(randint(0,255), randint(0,255), randint(0,255)) #draw a circle of radius 20 goofy.circle(20) goofy.left(18) #18*20 = 360 goofy.forward(20)
#the entry point of execution donut()
57
New cards
goofy.screen.colormode(255)
''' Purpose: Draw a colorful donut ''' from turtle import Turtle from random import randint
def donut(): '''The main function of the program''' #create a turtle goofy = Turtle()
#hide the turtle's body goofy.hideturtle()
#set RGB mode __________________________
#draw the donut for i in range(20): #randomize pen color goofy.pencolor(randint(0,255), randint(0,255), randint(0,255)) #draw a circle of radius 20 goofy.circle(20) goofy.left(18) #18*20 = 360 goofy.forward(20)
''' Purpose: Draw a colorful donut ''' from turtle import Turtle from random import randint
def donut(): '''The main function of the program''' #create a turtle goofy = Turtle()
#hide the turtle's body goofy.hideturtle()
#set RGB mode goofy.screen.colormode(255)
#draw the donut for i in range(20): #randomize pen color ______________________________________________________ #draw a circle of radius 20 goofy.circle(20) goofy.left(18) #18*20 = 360 goofy.forward(20)
#the entry point of execution donut()
59
New cards
circle(20)
''' Purpose: Draw a colorful donut ''' from turtle import Turtle from random import randint
def donut(): '''The main function of the program''' #create a turtle goofy = Turtle()
#hide the turtle's body goofy.hideturtle()
#set RGB mode goofy.screen.colormode(255)
#draw the donut for i in range(20): #randomize pen color goofy.pencolor(randint(0,255), randint(0,255), randint(0,255)) #draw a circle of radius 20 goofy.__________ goofy.left(18) #18*20 = 360 goofy.forward(20)
#the entry point of execution donut()
60
New cards
left(18)
''' Purpose: Draw a colorful donut ''' from turtle import Turtle from random import randint
def donut(): '''The main function of the program''' #create a turtle goofy = Turtle()
#hide the turtle's body goofy.hideturtle()
#set RGB mode goofy.screen.colormode(255)
#draw the donut for i in range(20): #randomize pen color goofy.pencolor(randint(0,255), randint(0,255), randint(0,255)) #draw a circle of radius 20 goofy.circle(20) goofy.______ #18*20 = 360 goofy.forward(20)
#the entry point of execution donut()
61
New cards
forward(20)
''' Purpose: Draw a colorful donut ''' from turtle import Turtle from random import randint
def donut(): '''The main function of the program''' #create a turtle goofy = Turtle()
#hide the turtle's body goofy.hideturtle()
#set RGB mode goofy.screen.colormode(255)
#draw the donut for i in range(20): #randomize pen color goofy.pencolor(randint(0,255), randint(0,255), randint(0,255)) #draw a circle of radius 20 goofy.circle(20) goofy.left(18) #18*20 = 360 goofy.__________
#the entry point of execution donut()
62
New cards
donut()
''' Purpose: Draw a colorful donut ''' from turtle import Turtle from random import randint
def donut(): '''The main function of the program''' #create a turtle goofy = Turtle()
#hide the turtle's body goofy.hideturtle()
#set RGB mode goofy.screen.colormode(255)
#draw the donut for i in range(20): #randomize pen color goofy.pencolor(randint(0,255), randint(0,255), randint(0,255)) #draw a circle of radius 20 goofy.circle(20) goofy.left(18) #18*20 = 360 goofy.forward(20)
#the entry point of execution ________
63
New cards
object
""" Purpose: Represent a student by a class type """
class Student(______): '''Represents a student''' def __init__(self, initName, initScore): '''The constructor to instantiate a student object''' self.name = initName self.score = initScore
def getName(self): '''returns the student's name''' return self.name
def setName(self, newName): '''resets/changes the student's name''' self.name = newName
def getScore(self): '''returns the student's score''' return self.score
def setScore(self, newScore): '''resets/changes the student's score''' self.score = newScore
def __str__(self): '''the string representation of the current student''' return "Name: " + self.name + ", Score: " + str(self.score)
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent.setName("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
64
New cards
__init__
""" Purpose: Represent a student by a class type """
class Student(object): '''Represents a student''' def [______](self, initName, initScore): '''The constructor to instantiate a student object''' self.name = initName self.score = initScore
def getName(self): '''returns the student's name''' return self.name
def setName(self, newName): '''resets/changes the student's name''' self.name = newName
def getScore(self): '''returns the student's score''' return self.score
def setScore(self, newScore): '''resets/changes the student's score''' self.score = newScore
def __str__(self): '''the string representation of the current student''' return "Name: " + self.name + ", Score: " + str(self.score)
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent.setName("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
65
New cards
self.name = initName
""" Purpose: Represent a student by a class type """
class Student(object): '''Represents a student''' def __init__(self, initName, initScore): '''The constructor to instantiate a student object''' __________________ self.score = initScore
def getName(self): '''returns the student's name''' return self.name
def setName(self, newName): '''resets/changes the student's name''' self.name = newName
def getScore(self): '''returns the student's score''' return self.score
def setScore(self, newScore): '''resets/changes the student's score''' self.score = newScore
def __str__(self): '''the string representation of the current student''' return "Name: " + self.name + ", Score: " + str(self.score)
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent.setName("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
66
New cards
self.score = initScore
""" Purpose: Represent a student by a class type """
class Student(object): '''Represents a student''' def __init__(self, initName, initScore): '''The constructor to instantiate a student object''' self.name = initName ____________________
def getName(self): '''returns the student's name''' return self.name
def setName(self, newName): '''resets/changes the student's name''' self.name = newName
def getScore(self): '''returns the student's score''' return self.score
def setScore(self, newScore): '''resets/changes the student's score''' self.score = newScore
def __str__(self): '''the string representation of the current student''' return "Name: " + self.name + ", Score: " + str(self.score)
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent.setName("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
67
New cards
self.name
""" Purpose: Represent a student by a class type """
class Student(object): '''Represents a student''' def __init__(self, initName, initScore): '''The constructor to instantiate a student object''' self.name = initName self.score = initScore
def getName(self): '''returns the student's name''' return __________
def setName(self, newName): '''resets/changes the student's name''' self.name = newName
def getScore(self): '''returns the student's score''' return self.score
def setScore(self, newScore): '''resets/changes the student's score''' self.score = newScore
def __str__(self): '''the string representation of the current student''' return "Name: " + self.name + ", Score: " + str(self.score)
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent.setName("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
68
New cards
self.name = newName
""" Purpose: Represent a student by a class type """
class Student(object): '''Represents a student''' def __init__(self, initName, initScore): '''The constructor to instantiate a student object''' self.name = initName self.score = initScore
def getName(self): '''returns the student's name''' return self.name
def setName(self, newName): '''resets/changes the student's name''' ___________________
def getScore(self): '''returns the student's score''' return self.score
def setScore(self, newScore): '''resets/changes the student's score''' self.score = newScore
def __str__(self): '''the string representation of the current student''' return "Name: " + self.name + ", Score: " + str(self.score)
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent.setName("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
69
New cards
self.score
""" Purpose: Represent a student by a class type """
class Student(object): '''Represents a student''' def __init__(self, initName, initScore): '''The constructor to instantiate a student object''' self.name = initName self.score = initScore
def getName(self): '''returns the student's name''' return self.name
def setName(self, newName): '''resets/changes the student's name''' self.name = newName
def getScore(self): '''returns the student's score''' return __________
def setScore(self, newScore): '''resets/changes the student's score''' self.score = newScore
def __str__(self): '''the string representation of the current student''' return "Name: " + self.name + ", Score: " + str(self.score)
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent.setName("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
70
New cards
self.score = newScore
""" Purpose: Represent a student by a class type """
class Student(object): '''Represents a student''' def __init__(self, initName, initScore): '''The constructor to instantiate a student object''' self.name = initName self.score = initScore
def getName(self): '''returns the student's name''' return self.name
def setName(self, newName): '''resets/changes the student's name''' self.name = newName
def getScore(self): '''returns the student's score''' return self.score
def setScore(self, newScore): '''resets/changes the student's score''' ____________________
def __str__(self): '''the string representation of the current student''' return "Name: " + self.name + ", Score: " + str(self.score)
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent.setName("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
71
New cards
__str__
""" Purpose: Represent a student by a class type """
class Student(object): '''Represents a student''' def __init__(self, initName, initScore): '''The constructor to instantiate a student object''' self.name = initName self.score = initScore
def getName(self): '''returns the student's name''' return self.name
def setName(self, newName): '''resets/changes the student's name''' self.name = newName
def getScore(self): '''returns the student's score''' return self.score
def setScore(self, newScore): '''resets/changes the student's score''' self.score = newScore
def [______](self): '''the string representation of the current student''' return "Name: " + self.name + ", Score: " + str(self.score)
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent.setName("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
72
New cards
self.name, str(self.score)
""" Purpose: Represent a student by a class type """
class Student(object): '''Represents a student''' def __init__(self, initName, initScore): '''The constructor to instantiate a student object''' self.name = initName self.score = initScore
def getName(self): '''returns the student's name''' return self.name
def setName(self, newName): '''resets/changes the student's name''' self.name = newName
def getScore(self): '''returns the student's score''' return self.score
def setScore(self, newScore): '''resets/changes the student's score''' self.score = newScore
def __str__(self): '''the string representation of the current student''' return "Name: " + _________ + ", Score: " + ____________
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent.setName("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
73
New cards
Student
""" Purpose: Represent a student by a class type """
class Student(object): '''Represents a student''' def __init__(self, initName, initScore): '''The constructor to instantiate a student object''' self.name = initName self.score = initScore
def getName(self): '''returns the student's name''' return self.name
def setName(self, newName): '''resets/changes the student's name''' self.name = newName
def getScore(self): '''returns the student's score''' return self.score
def setScore(self, newScore): '''resets/changes the student's score''' self.score = newScore
def __str__(self): '''the string representation of the current student''' return "Name: " + self.name + ", Score: " + str(self.score)
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = ________("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent.setName("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
74
New cards
print(myStudent)
""" Purpose: Represent a student by a class type """
class Student(object): '''Represents a student''' def __init__(self, initName, initScore): '''The constructor to instantiate a student object''' self.name = initName self.score = initScore
def getName(self): '''returns the student's name''' return self.name
def setName(self, newName): '''resets/changes the student's name''' self.name = newName
def getScore(self): '''returns the student's score''' return self.score
def setScore(self, newScore): '''resets/changes the student's score''' self.score = newScore
def __str__(self): '''the string representation of the current student''' return "Name: " + self.name + ", Score: " + str(self.score)
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student __________________
#change the student's name and score myStudent.setName("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
75
New cards
setName
""" Purpose: Represent a student by a class type """
class Student(object): '''Represents a student''' def __init__(self, initName, initScore): '''The constructor to instantiate a student object''' self.name = initName self.score = initScore
def getName(self): '''returns the student's name''' return self.name
def setName(self, newName): '''resets/changes the student's name''' self.name = newName
def getScore(self): '''returns the student's score''' return self.score
def setScore(self, newScore): '''resets/changes the student's score''' self.score = newScore
def __str__(self): '''the string representation of the current student''' return "Name: " + self.name + ", Score: " + str(self.score)
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent._________("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
76
New cards
setScore
""" Purpose: Represent a student by a class type """
class Student(object): '''Represents a student''' def __init__(self, initName, initScore): '''The constructor to instantiate a student object''' self.name = initName self.score = initScore
def getName(self): '''returns the student's name''' return self.name
def setName(self, newName): '''resets/changes the student's name''' self.name = newName
def getScore(self): '''returns the student's score''' return self.score
def setScore(self, newScore): '''resets/changes the student's score''' self.score = newScore
def __str__(self): '''the string representation of the current student''' return "Name: " + self.name + ", Score: " + str(self.score)
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent.setName("Mandy") myStudent.________(100)
#print the student again print(myStudent)
#the entry point of execution main()
77
New cards
main()
""" Purpose: Represent a student by a class type """
class Student(object): '''Represents a student''' def __init__(self, initName, initScore): '''The constructor to instantiate a student object''' self.name = initName self.score = initScore
def getName(self): '''returns the student's name''' return self.name
def setName(self, newName): '''resets/changes the student's name''' self.name = newName
def getScore(self): '''returns the student's score''' return self.score
def setScore(self, newScore): '''resets/changes the student's score''' self.score = newScore
def __str__(self): '''the string representation of the current student''' return "Name: " + self.name + ", Score: " + str(self.score)
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent.setName("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution ______
78
New cards
student, Student
""" Purpose: Represent a student by a class type which is defined in the student module """ from ______ import _______ #bring in the Student class type
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent.setName("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
79
New cards
Student
""" Purpose: Represent a student by a class type which is defined in the student module """ from student import Student #bring in the Student class type
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = _______("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent.setName("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
80
New cards
myStudent
""" Purpose: Represent a student by a class type which is defined in the student module """ from student import Student #bring in the Student class type
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(_________)
#change the student's name and score myStudent.setName("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
81
New cards
myStudent.setName
""" Purpose: Represent a student by a class type which is defined in the student module """ from student import Student #bring in the Student class type
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score _____________________("Mandy") myStudent.setScore(100)
#print the student again print(myStudent)
#the entry point of execution main()
82
New cards
myStudent.setScore
""" Purpose: Represent a student by a class type which is defined in the student module """ from student import Student #bring in the Student class type
def main(): '''the main function of this program'''
#instantiate (create) a student myStudent = Student("Nancy", 98)
#print the student print(myStudent)
#change the student's name and score myStudent.setName("Mandy") ____________________(100)
#print the student again print(myStudent)
#the entry point of execution main()
83
New cards
random, randint
""" Purpose: Represent a die by a class type with default value of 1 """ from ______ import _______ #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(self, initValue = 1): '''Instantiates a die with the given initial value''' self.value = initValue
def getValue(self): '''Returns the die's value''' return self.value
def roll(self): '''Rolls the die''' self.value = randint(1, 6)
def __str__(self): '''Returns a string representation of the die''' return "Value: " + str(self.value)
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#the entry point of execution main()
84
New cards
object
""" Purpose: Represent a die by a class type with default value of 1 """ from random import randint #for rolling a die
class Die(______): '''Represents a die''' def __init__(self, initValue = 1): '''Instantiates a die with the given initial value''' self.value = initValue
def getValue(self): '''Returns the die's value''' return self.value
def roll(self): '''Rolls the die''' self.value = randint(1, 6)
def __str__(self): '''Returns a string representation of the die''' return "Value: " + str(self.value)
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#the entry point of execution main()
85
New cards
initValue = 1
""" Purpose: Represent a die by a class type with default value of 1 """ from random import randint #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(self, ___________): '''Instantiates a die with the given initial value''' self.value = initValue
def getValue(self): '''Returns the die's value''' return self.value
def roll(self): '''Rolls the die''' self.value = randint(1, 6)
def __str__(self): '''Returns a string representation of the die''' return "Value: " + str(self.value)
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#the entry point of execution main()
86
New cards
self.value = initValue
""" Purpose: Represent a die by a class type with default value of 1 """ from random import randint #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(self, initValue = 1): '''Instantiates a die with the given initial value''' ____________________
def getValue(self): '''Returns the die's value''' return self.value
def roll(self): '''Rolls the die''' self.value = randint(1, 6)
def __str__(self): '''Returns a string representation of the die''' return "Value: " + str(self.value)
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#the entry point of execution main()
87
New cards
self.value
""" Purpose: Represent a die by a class type with default value of 1 """ from random import randint #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(self, initValue = 1): '''Instantiates a die with the given initial value''' self.value = initValue
def getValue(self): '''Returns the die's value''' return _________
def roll(self): '''Rolls the die''' self.value = randint(1, 6)
def __str__(self): '''Returns a string representation of the die''' return "Value: " + str(self.value)
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#the entry point of execution main()
88
New cards
randint(1,6)
""" Purpose: Represent a die by a class type with default value of 1 """ from random import randint #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(self, initValue = 1): '''Instantiates a die with the given initial value''' self.value = initValue
def getValue(self): '''Returns the die's value''' return self.value
def roll(self): '''Rolls the die''' self.value = __________
def __str__(self): '''Returns a string representation of the die''' return "Value: " + str(self.value)
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#the entry point of execution main()
89
New cards
str(self.value)
""" Purpose: Represent a die by a class type with default value of 1 """ from random import randint #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(self, initValue = 1): '''Instantiates a die with the given initial value''' self.value = initValue
def getValue(self): '''Returns the die's value''' return self.value
def roll(self): '''Rolls the die''' self.value = randint(1, 6)
def __str__(self): '''Returns a string representation of the die''' return "Value: " + ___________
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#the entry point of execution main()
90
New cards
Die()
""" Purpose: Represent a die by a class type with default value of 1 """ from random import randint #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(self, initValue = 1): '''Instantiates a die with the given initial value''' self.value = initValue
def getValue(self): '''Returns the die's value''' return self.value
def roll(self): '''Rolls the die''' self.value = randint(1, 6)
def __str__(self): '''Returns a string representation of the die''' return "Value: " + str(self.value)
def main(): '''The main function of the program'''
#instantiate two dice d1 = ____ #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#the entry point of execution main()
91
New cards
print(d1), print(d2)
""" Purpose: Represent a die by a class type with default value of 1 """ from random import randint #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(self, initValue = 1): '''Instantiates a die with the given initial value''' self.value = initValue
def getValue(self): '''Returns the die's value''' return self.value
def roll(self): '''Rolls the die''' self.value = randint(1, 6)
def __str__(self): '''Returns a string representation of the die''' return "Value: " + str(self.value)
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice ________ ________
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#the entry point of execution main()
92
New cards
roll()
""" Purpose: Represent a die by a class type with default value of 1 """ from random import randint #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(self, initValue = 1): '''Instantiates a die with the given initial value''' self.value = initValue
def getValue(self): '''Returns the die's value''' return self.value
def roll(self): '''Rolls the die''' self.value = randint(1, 6)
def __str__(self): '''Returns a string representation of the die''' return "Value: " + str(self.value)
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#roll both dice d1.____ d2.roll()
#print both dice print(d1) print(d2)
#the entry point of execution main()
93
New cards
main()
""" Purpose: Represent a die by a class type with default value of 1 """ from random import randint #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(self, initValue = 1): '''Instantiates a die with the given initial value''' self.value = initValue
def getValue(self): '''Returns the die's value''' return self.value
def roll(self): '''Rolls the die''' self.value = randint(1, 6)
def __str__(self): '''Returns a string representation of the die''' return "Value: " + str(self.value)
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#the entry point of execution _____
94
New cards
self, initValue = 1
""" Purpose Represent a die by a class type """ from random import randint #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(_____________): '''Instantiates a die with the given initial value''' self.value = initValue
def getValue(self): '''Returns the die's value''' return self.value
def roll(self): '''Rolls the die''' self.value = randint(1, 6)
def __str__(self): '''Returns a string representation of the die''' return "Value: " + str(self.value)
def __lt__(self, other): '''The less than operator''' return self.value < other.value
def __ge__(self, other): '''The greater than or equal to operator''' return self.value >= other.value
def __eq__(self, other): '''The equal operator''' if self is other: return True #the same object elif type(self) != type(other): return False else: return self.value == other.value
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#compare these two dice if(d1 > d2): #will be translated into "if d1.__gt__(d2):" print("d1 is greater than d2") else: print("d1 is not greater than d2")
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#compare these two dice again (greater than or equal to) if(d1 >= d2): #will be translated into "if d1.__ge__(d2):" print("d1 is greater than or equal to d2") else: print("d1 is not greater than or equal to d2")
#compare these two dice again (equal to) if(d1 == d2): #will be translated into "if d1.__eq__(d2):" print("d1 is equal to d2") else: print("d1 is not equal to d2")
#the entry point of execution main()
95
New cards
self.value = initValue
""" Purpose Represent a die by a class type """ from random import randint #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(self, initValue = 1): '''Instantiates a die with the given initial value''' ___________________
def getValue(self): '''Returns the die's value''' return self.value
def roll(self): '''Rolls the die''' self.value = randint(1, 6)
def __str__(self): '''Returns a string representation of the die''' return "Value: " + str(self.value)
def __lt__(self, other): '''The less than operator''' return self.value < other.value
def __ge__(self, other): '''The greater than or equal to operator''' return self.value >= other.value
def __eq__(self, other): '''The equal operator''' if self is other: return True #the same object elif type(self) != type(other): return False else: return self.value == other.value
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#compare these two dice if(d1 > d2): #will be translated into "if d1.__gt__(d2):" print("d1 is greater than d2") else: print("d1 is not greater than d2")
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#compare these two dice again (greater than or equal to) if(d1 >= d2): #will be translated into "if d1.__ge__(d2):" print("d1 is greater than or equal to d2") else: print("d1 is not greater than or equal to d2")
#compare these two dice again (equal to) if(d1 == d2): #will be translated into "if d1.__eq__(d2):" print("d1 is equal to d2") else: print("d1 is not equal to d2")
#the entry point of execution main()
96
New cards
getValue(self)
""" Purpose Represent a die by a class type """ from random import randint #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(self, initValue = 1): '''Instantiates a die with the given initial value''' self.value = initValue
def __________: '''Returns the die's value''' return self.value
def roll(self): '''Rolls the die''' self.value = randint(1, 6)
def __str__(self): '''Returns a string representation of the die''' return "Value: " + str(self.value)
def __lt__(self, other): '''The less than operator''' return self.value < other.value
def __ge__(self, other): '''The greater than or equal to operator''' return self.value >= other.value
def __eq__(self, other): '''The equal operator''' if self is other: return True #the same object elif type(self) != type(other): return False else: return self.value == other.value
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#compare these two dice if(d1 > d2): #will be translated into "if d1.__gt__(d2):" print("d1 is greater than d2") else: print("d1 is not greater than d2")
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#compare these two dice again (greater than or equal to) if(d1 >= d2): #will be translated into "if d1.__ge__(d2):" print("d1 is greater than or equal to d2") else: print("d1 is not greater than or equal to d2")
#compare these two dice again (equal to) if(d1 == d2): #will be translated into "if d1.__eq__(d2):" print("d1 is equal to d2") else: print("d1 is not equal to d2")
#the entry point of execution main()
97
New cards
return self.value
""" Purpose Represent a die by a class type """ from random import randint #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(self, initValue = 1): '''Instantiates a die with the given initial value''' self.value = initValue
def getValue(self): '''Returns the die's value''' _______________
def roll(self): '''Rolls the die''' self.value = randint(1, 6)
def __str__(self): '''Returns a string representation of the die''' return "Value: " + str(self.value)
def __lt__(self, other): '''The less than operator''' return self.value < other.value
def __ge__(self, other): '''The greater than or equal to operator''' return self.value >= other.value
def __eq__(self, other): '''The equal operator''' if self is other: return True #the same object elif type(self) != type(other): return False else: return self.value == other.value
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#compare these two dice if(d1 > d2): #will be translated into "if d1.__gt__(d2):" print("d1 is greater than d2") else: print("d1 is not greater than d2")
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#compare these two dice again (greater than or equal to) if(d1 >= d2): #will be translated into "if d1.__ge__(d2):" print("d1 is greater than or equal to d2") else: print("d1 is not greater than or equal to d2")
#compare these two dice again (equal to) if(d1 == d2): #will be translated into "if d1.__eq__(d2):" print("d1 is equal to d2") else: print("d1 is not equal to d2")
#the entry point of execution main()
98
New cards
self.value = randint(1,6)
""" Purpose Represent a die by a class type """ from random import randint #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(self, initValue = 1): '''Instantiates a die with the given initial value''' self.value = initValue
def getValue(self): '''Returns the die's value''' return self.value
def roll(self): '''Rolls the die''' ___________________
def __str__(self): '''Returns a string representation of the die''' return "Value: " + str(self.value)
def __lt__(self, other): '''The less than operator''' return self.value < other.value
def __ge__(self, other): '''The greater than or equal to operator''' return self.value >= other.value
def __eq__(self, other): '''The equal operator''' if self is other: return True #the same object elif type(self) != type(other): return False else: return self.value == other.value
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#compare these two dice if(d1 > d2): #will be translated into "if d1.__gt__(d2):" print("d1 is greater than d2") else: print("d1 is not greater than d2")
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#compare these two dice again (greater than or equal to) if(d1 >= d2): #will be translated into "if d1.__ge__(d2):" print("d1 is greater than or equal to d2") else: print("d1 is not greater than or equal to d2")
#compare these two dice again (equal to) if(d1 == d2): #will be translated into "if d1.__eq__(d2):" print("d1 is equal to d2") else: print("d1 is not equal to d2")
#the entry point of execution main()
99
New cards
__str__(self)
""" Purpose Represent a die by a class type """ from random import randint #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(self, initValue = 1): '''Instantiates a die with the given initial value''' self.value = initValue
def getValue(self): '''Returns the die's value''' return self.value
def roll(self): '''Rolls the die''' self.value = randint(1, 6)
def ___________: '''Returns a string representation of the die''' return "Value: " + str(self.value)
def __lt__(self, other): '''The less than operator''' return self.value < other.value
def __ge__(self, other): '''The greater than or equal to operator''' return self.value >= other.value
def __eq__(self, other): '''The equal operator''' if self is other: return True #the same object elif type(self) != type(other): return False else: return self.value == other.value
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#compare these two dice if(d1 > d2): #will be translated into "if d1.__gt__(d2):" print("d1 is greater than d2") else: print("d1 is not greater than d2")
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#compare these two dice again (greater than or equal to) if(d1 >= d2): #will be translated into "if d1.__ge__(d2):" print("d1 is greater than or equal to d2") else: print("d1 is not greater than or equal to d2")
#compare these two dice again (equal to) if(d1 == d2): #will be translated into "if d1.__eq__(d2):" print("d1 is equal to d2") else: print("d1 is not equal to d2")
#the entry point of execution main()
100
New cards
self, other
""" Purpose Represent a die by a class type """ from random import randint #for rolling a die
class Die(object): #everything is a subclass from the object class '''Represents a die''' def __init__(self, initValue = 1): '''Instantiates a die with the given initial value''' self.value = initValue
def getValue(self): '''Returns the die's value''' return self.value
def roll(self): '''Rolls the die''' self.value = randint(1, 6)
def __str__(self): '''Returns a string representation of the die''' return "Value: " + str(self.value)
def __gt__(________): '''The greater than operator''' return self.value > other.value
def __lt__(self, other): '''The less than operator''' return self.value < other.value
def __ge__(self, other): '''The greater than or equal to operator''' return self.value >= other.value
def __eq__(self, other): '''The equal operator''' if self is other: return True #the same object elif type(self) != type(other): return False else: return self.value == other.value
def main(): '''The main function of the program'''
#instantiate two dice d1 = Die() #call the default constructor d2 = Die(3)
#print both dice print(d1) print(d2)
#compare these two dice if(d1 > d2): #will be translated into "if d1.__gt__(d2):" print("d1 is greater than d2") else: print("d1 is not greater than d2")
#roll both dice d1.roll() d2.roll()
#print both dice print(d1) print(d2)
#compare these two dice again (greater than or equal to) if(d1 >= d2): #will be translated into "if d1.__ge__(d2):" print("d1 is greater than or equal to d2") else: print("d1 is not greater than or equal to d2")
#compare these two dice again (equal to) if(d1 == d2): #will be translated into "if d1.__eq__(d2):" print("d1 is equal to d2") else: print("d1 is not equal to d2")