COP2034 - Final Exam

0.0(0)
studied byStudied by 9 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/175

flashcard set

Earn XP

Description and Tags

Ch. 7&9

Last updated 9:24 PM on 12/8/22
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

176 Terms

1
New cards
Turtle()
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

#create a turtle
t = _______

#raise the pen from the drawing surface
t.up()

#go to the starting location for drawing
t.goto(100, -100)

#set the pen color to red
t.pencolor("red")

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(200)

t.end_fill()

#hide the turtle body
t.hideturtle()
2
New cards
up()
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

#create a turtle
t = Turtle()

#raise the pen from the drawing surface
t.____

#go to the starting location for drawing
t.goto(100, -100)

#set the pen color to red
t.pencolor("red")

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(200)

t.end_fill()

#hide the turtle body
t.hideturtle()
3
New cards
goto
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

#create a turtle
t = Turtle()

#raise the pen from the drawing surface
t.up()

#go to the starting location for drawing
t.____(100, -100)

#set the pen color to red
t.pencolor("red")

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(200)

t.end_fill()

#hide the turtle body
t.hideturtle()
4
New cards
pencolor
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

#create a turtle
t = Turtle()

#raise the pen from the drawing surface
t.up()

#go to the starting location for drawing
t.goto(100, -100)

#set the pen color to red
t._______("red")

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(200)

t.end_fill()

#hide the turtle body
t.hideturtle()
5
New cards
down()
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

#create a turtle
t = Turtle()

#raise the pen from the drawing surface
t.up()

#go to the starting location for drawing
t.goto(100, -100)

#set the pen color to red
t.pencolor("red")

#lower the pen to touch the drawing surface
t.______

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(200)

t.end_fill()

#hide the turtle body
t.hideturtle()
6
New cards
fillcolor
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

#create a turtle
t = Turtle()

#raise the pen from the drawing surface
t.up()

#go to the starting location for drawing
t.goto(100, -100)

#set the pen color to red
t.pencolor("red")

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t._______("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(200)

t.end_fill()

#hide the turtle body
t.hideturtle()
7
New cards
begin_fill()
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

#create a turtle
t = Turtle()

#raise the pen from the drawing surface
t.up()

#go to the starting location for drawing
t.goto(100, -100)

#set the pen color to red
t.pencolor("red")

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t._________

for i in range(4):
t.left(90)
t.forward(200)

t.end_fill()

#hide the turtle body
t.hideturtle()
8
New cards
i, 4
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

#create a turtle
t = Turtle()

#raise the pen from the drawing surface
t.up()

#go to the starting location for drawing
t.goto(100, -100)

#set the pen color to red
t.pencolor("red")

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for __ in range(__):
t.left(90)
t.forward(200)

t.end_fill()

#hide the turtle body
t.hideturtle()
9
New cards
left
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

#create a turtle
t = Turtle()

#raise the pen from the drawing surface
t.up()

#go to the starting location for drawing
t.goto(100, -100)

#set the pen color to red
t.pencolor("red")

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.___(90)
t.forward(200)

t.end_fill()

#hide the turtle body
t.hideturtle()
10
New cards
forward
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

#create a turtle
t = Turtle()

#raise the pen from the drawing surface
t.up()

#go to the starting location for drawing
t.goto(100, -100)

#set the pen color to red
t.pencolor("red")

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t._______(200)

t.end_fill()

#hide the turtle body
t.hideturtle()
11
New cards
end_fill()
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

#create a turtle
t = Turtle()

#raise the pen from the drawing surface
t.up()

#go to the starting location for drawing
t.goto(100, -100)

#set the pen color to red
t.pencolor("red")

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(200)

t._________

#hide the turtle body
t.hideturtle()
12
New cards
hideturtle()
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

#create a turtle
t = Turtle()

#raise the pen from the drawing surface
t.up()

#go to the starting location for drawing
t.goto(100, -100)

#set the pen color to red
t.pencolor("red")

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(200)

t.end_fill()

#hide the turtle body
t.___________
13
New cards
turtle, Turtle
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from _____ import ______ #bring in the Turtle class

def main():
#create a turtle
myTurtle = Turtle()

#raise the pen from the drawing surface
myTurtle.up()

#set the pen color to red
myTurtle.pencolor("red")

#hide the turtle body
myTurtle.hideturtle()

#start drawing
drawSquare(myTurtle, 100, -100, 200)


def drawSquare(t, x, y, length):
'''Draws a square and fills in yellow'''
#go to the starting location for drawing
t.goto(x, y)

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(length)

t.end_fill()


#the entry point of execution
main()
14
New cards
Turtle()
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

def main():
#create a turtle
myTurtle = _______

#raise the pen from the drawing surface
myTurtle.up()

#set the pen color to red
myTurtle.pencolor("red")

#hide the turtle body
myTurtle.hideturtle()

#start drawing
drawSquare(myTurtle, 100, -100, 200)


def drawSquare(t, x, y, length):
'''Draws a square and fills in yellow'''
#go to the starting location for drawing
t.goto(x, y)

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(length)

t.end_fill()


#the entry point of execution
main()
15
New cards
myTurtle.up()
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

def main():
#create a turtle
myTurtle = Turtle()

#raise the pen from the drawing surface
______________

#set the pen color to red
myTurtle.pencolor("red")

#hide the turtle body
myTurtle.hideturtle()

#start drawing
drawSquare(myTurtle, 100, -100, 200)


def drawSquare(t, x, y, length):
'''Draws a square and fills in yellow'''
#go to the starting location for drawing
t.goto(x, y)

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(length)

t.end_fill()


#the entry point of execution
main()
16
New cards
pencolor("red")
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

def main():
#create a turtle
myTurtle = Turtle()

#raise the pen from the drawing surface
myTurtle.up()

#set the pen color to red
myTurtle._____________

#hide the turtle body
myTurtle.hideturtle()

#start drawing
drawSquare(myTurtle, 100, -100, 200)


def drawSquare(t, x, y, length):
'''Draws a square and fills in yellow'''
#go to the starting location for drawing
t.goto(x, y)

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(length)

t.end_fill()


#the entry point of execution
main()
17
New cards
myTurtle.hideturtle()
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

def main():
#create a turtle
myTurtle = Turtle()

#raise the pen from the drawing surface
myTurtle.up()

#set the pen color to red
myTurtle.pencolor("red")

#hide the turtle body
____________________

#start drawing
drawSquare(myTurtle, 100, -100, 200)


def drawSquare(t, x, y, length):
'''Draws a square and fills in yellow'''
#go to the starting location for drawing
t.goto(x, y)

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(length)

t.end_fill()


#the entry point of execution
main()
18
New cards
drawSquare
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

def main():
#create a turtle
myTurtle = Turtle()

#raise the pen from the drawing surface
myTurtle.up()

#set the pen color to red
myTurtle.pencolor("red")

#hide the turtle body
myTurtle.hideturtle()

#start drawing
___________(myTurtle, 100, -100, 200)


def drawSquare(t, x, y, length):
'''Draws a square and fills in yellow'''
#go to the starting location for drawing
t.goto(x, y)

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(length)

t.end_fill()


#the entry point of execution
main()
19
New cards
goto(x,y)
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

def main():
#create a turtle
myTurtle = Turtle()

#raise the pen from the drawing surface
myTurtle.up()

#set the pen color to red
myTurtle.pencolor("red")

#hide the turtle body
myTurtle.hideturtle()

#start drawing
drawSquare(myTurtle, 100, -100, 200)


def drawSquare(t, x, y, length):
'''Draws a square and fills in yellow'''
#go to the starting location for drawing
t.________

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(length)

t.end_fill()


#the entry point of execution
main()
20
New cards
t.down()
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

def main():
#create a turtle
myTurtle = Turtle()

#raise the pen from the drawing surface
myTurtle.up()

#set the pen color to red
myTurtle.pencolor("red")

#hide the turtle body
myTurtle.hideturtle()

#start drawing
drawSquare(myTurtle, 100, -100, 200)


def drawSquare(t, x, y, length):
'''Draws a square and fills in yellow'''
#go to the starting location for drawing
t.goto(x, y)

#lower the pen to touch the drawing surface
_________

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(length)

t.end_fill()


#the entry point of execution
main()
21
New cards
fillcolor("yellow")
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

def main():
#create a turtle
myTurtle = Turtle()

#raise the pen from the drawing surface
myTurtle.up()

#set the pen color to red
myTurtle.pencolor("red")

#hide the turtle body
myTurtle.hideturtle()

#start drawing
drawSquare(myTurtle, 100, -100, 200)


def drawSquare(t, x, y, length):
'''Draws a square and fills in yellow'''
#go to the starting location for drawing
t.goto(x, y)

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.____________

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(length)

t.end_fill()


#the entry point of execution
main()
22
New cards
t.begin_fill()
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

def main():
#create a turtle
myTurtle = Turtle()

#raise the pen from the drawing surface
myTurtle.up()

#set the pen color to red
myTurtle.pencolor("red")

#hide the turtle body
myTurtle.hideturtle()

#start drawing
drawSquare(myTurtle, 100, -100, 200)


def drawSquare(t, x, y, length):
'''Draws a square and fills in yellow'''
#go to the starting location for drawing
t.goto(x, y)

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
______________

for i in range(4):
t.left(90)
t.forward(length)

t.end_fill()


#the entry point of execution
main()
23
New cards
t.left(90)
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

def main():
#create a turtle
myTurtle = Turtle()

#raise the pen from the drawing surface
myTurtle.up()

#set the pen color to red
myTurtle.pencolor("red")

#hide the turtle body
myTurtle.hideturtle()

#start drawing
drawSquare(myTurtle, 100, -100, 200)


def drawSquare(t, x, y, length):
'''Draws a square and fills in yellow'''
#go to the starting location for drawing
t.goto(x, y)

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
_________
t.forward(length)

t.end_fill()


#the entry point of execution
main()
24
New cards
t.forward(length)
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

def main():
#create a turtle
myTurtle = Turtle()

#raise the pen from the drawing surface
myTurtle.up()

#set the pen color to red
myTurtle.pencolor("red")

#hide the turtle body
myTurtle.hideturtle()

#start drawing
drawSquare(myTurtle, 100, -100, 200)


def drawSquare(t, x, y, length):
'''Draws a square and fills in yellow'''
#go to the starting location for drawing
t.goto(x, y)

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
_________________

t.end_fill()


#the entry point of execution
main()
25
New cards
end_fill()
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

def main():
#create a turtle
myTurtle = Turtle()

#raise the pen from the drawing surface
myTurtle.up()

#set the pen color to red
myTurtle.pencolor("red")

#hide the turtle body
myTurtle.hideturtle()

#start drawing
drawSquare(myTurtle, 100, -100, 200)


def drawSquare(t, x, y, length):
'''Draws a square and fills in yellow'''
#go to the starting location for drawing
t.goto(x, y)

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(length)

t.________


#the entry point of execution
main()
26
New cards
main()
"""
Purpose: draw a square using red lines and fill it in with yellow
"""
from turtle import Turtle #bring in the Turtle class

def main():
#create a turtle
myTurtle = Turtle()

#raise the pen from the drawing surface
myTurtle.up()

#set the pen color to red
myTurtle.pencolor("red")

#hide the turtle body
myTurtle.hideturtle()

#start drawing
drawSquare(myTurtle, 100, -100, 200)


def drawSquare(t, x, y, length):
'''Draws a square and fills in yellow'''
#go to the starting location for drawing
t.goto(x, y)

#lower the pen to touch the drawing surface
t.down()

#set the fill color to yellow
t.fillcolor("yellow")

#draw the square (4 sides) and fill in the color
t.begin_fill()

for i in range(4):
t.left(90)
t.forward(length)

t.end_fill()


#the entry point of execution
_______
27
New cards
Turtle()
"""
Purpose: Draw a shape by connecting a list of points/vertices
"""
from turtle import Turtle #bring in the Turtle class

def main():
'''The main function of the program'''

#instantiate/create a turtle
goofy = ________

#hide the turtle's body
goofy.hideturtle()

#the given list of points
listOfPoints = [(100, 100), (80, 150), (200, 250), (60, 10)]

#before drawing (raise the pen)
goofy.up()

#set pen color
goofy.pencolor('green')

#start drawing
drawShape(goofy, listOfPoints)

def drawShape(t, points):
'''Draw a shape by connecting a list of points/vertices'''

#go to the last point in the list
(x, y) = points[-1]
t.goto(x, y)

#lower the pen
t.down()

#connecting all points
for (x, y) in points:
t.goto(x, y)

#the entry point of execution
main()
28
New cards
hideturtle()
"""
Purpose: Draw a shape by connecting a list of points/vertices
"""
from turtle import Turtle #bring in the Turtle class

def main():
'''The main function of the program'''

#instantiate/create a turtle
goofy = Turtle()

#hide the turtle's body
goofy.___________

#the given list of points
listOfPoints = [(100, 100), (80, 150), (200, 250), (60, 10)]

#before drawing (raise the pen)
goofy.up()

#set pen color
goofy.pencolor('green')

#start drawing
drawShape(goofy, listOfPoints)

def drawShape(t, points):
'''Draw a shape by connecting a list of points/vertices'''

#go to the last point in the list
(x, y) = points[-1]
t.goto(x, y)

#lower the pen
t.down()

#connecting all points
for (x, y) in points:
t.goto(x, y)

#the entry point of execution
main()
29
New cards
[, ]
"""
Purpose: Draw a shape by connecting a list of points/vertices
"""
from turtle import Turtle #bring in the Turtle class

def main():
'''The main function of the program'''

#instantiate/create a turtle
goofy = Turtle()

#hide the turtle's body
goofy.hideturtle()

#the given list of points
listOfPoints = _(100, 100), (80, 150), (200, 250), (60, 10)_

#before drawing (raise the pen)
goofy.up()

#set pen color
goofy.pencolor('green')

#start drawing
drawShape(goofy, listOfPoints)

def drawShape(t, points):
'''Draw a shape by connecting a list of points/vertices'''

#go to the last point in the list
(x, y) = points[-1]
t.goto(x, y)

#lower the pen
t.down()

#connecting all points
for (x, y) in points:
t.goto(x, y)

#the entry point of execution
main()
30
New cards
goofy.up()
"""
Purpose: Draw a shape by connecting a list of points/vertices
"""
from turtle import Turtle #bring in the Turtle class

def main():
'''The main function of the program'''

#instantiate/create a turtle
goofy = Turtle()

#hide the turtle's body
goofy.hideturtle()

#the given list of points
listOfPoints = [(100, 100), (80, 150), (200, 250), (60, 10)]

#before drawing (raise the pen)
________

#set pen color
goofy.pencolor('green')

#start drawing
drawShape(goofy, listOfPoints)

def drawShape(t, points):
'''Draw a shape by connecting a list of points/vertices'''

#go to the last point in the list
(x, y) = points[-1]
t.goto(x, y)

#lower the pen
t.down()

#connecting all points
for (x, y) in points:
t.goto(x, y)

#the entry point of execution
main()
31
New cards
pencolor
"""
Purpose: Draw a shape by connecting a list of points/vertices
"""
from turtle import Turtle #bring in the Turtle class

def main():
'''The main function of the program'''

#instantiate/create a turtle
goofy = Turtle()

#hide the turtle's body
goofy.hideturtle()

#the given list of points
listOfPoints = [(100, 100), (80, 150), (200, 250), (60, 10)]

#before drawing (raise the pen)
goofy.up()

#set pen color
goofy._______('green')

#start drawing
drawShape(goofy, listOfPoints)

def drawShape(t, points):
'''Draw a shape by connecting a list of points/vertices'''

#go to the last point in the list
(x, y) = points[-1]
t.goto(x, y)

#lower the pen
t.down()

#connecting all points
for (x, y) in points:
t.goto(x, y)

#the entry point of execution
main()
32
New cards
goofy, listOfPoints
"""
Purpose: Draw a shape by connecting a list of points/vertices
"""
from turtle import Turtle #bring in the Turtle class

def main():
'''The main function of the program'''

#instantiate/create a turtle
goofy = Turtle()

#hide the turtle's body
goofy.hideturtle()

#the given list of points
listOfPoints = [(100, 100), (80, 150), (200, 250), (60, 10)]

#before drawing (raise the pen)
goofy.up()

#set pen color
goofy.pencolor('green')

#start drawing
drawShape(____, __________)

def drawShape(t, points):
'''Draw a shape by connecting a list of points/vertices'''

#go to the last point in the list
(x, y) = points[-1]
t.goto(x, y)

#lower the pen
t.down()

#connecting all points
for (x, y) in points:
t.goto(x, y)

#the entry point of execution
main()
33
New cards
points[-1]
"""
Purpose: Draw a shape by connecting a list of points/vertices
"""
from turtle import Turtle #bring in the Turtle class

def main():
'''The main function of the program'''

#instantiate/create a turtle
goofy = Turtle()

#hide the turtle's body
goofy.hideturtle()

#the given list of points
listOfPoints = [(100, 100), (80, 150), (200, 250), (60, 10)]

#before drawing (raise the pen)
goofy.up()

#set pen color
goofy.pencolor('green')

#start drawing
drawShape(goofy, listOfPoints)

def drawShape(t, points):
'''Draw a shape by connecting a list of points/vertices'''

#go to the last point in the list
(x, y) = _________
t.goto(x, y)

#lower the pen
t.down()

#connecting all points
for (x, y) in points:
t.goto(x, y)

#the entry point of execution
main()
34
New cards
t.goto(x,y)
"""
Purpose: Draw a shape by connecting a list of points/vertices
"""
from turtle import Turtle #bring in the Turtle class

def main():
'''The main function of the program'''

#instantiate/create a turtle
goofy = Turtle()

#hide the turtle's body
goofy.hideturtle()

#the given list of points
listOfPoints = [(100, 100), (80, 150), (200, 250), (60, 10)]

#before drawing (raise the pen)
goofy.up()

#set pen color
goofy.pencolor('green')

#start drawing
drawShape(goofy, listOfPoints)

def drawShape(t, points):
'''Draw a shape by connecting a list of points/vertices'''

#go to the last point in the list
(x, y) = points[-1]
_________

#lower the pen
t.down()

#connecting all points
for (x, y) in points:
t.goto(x, y)

#the entry point of execution
main()
35
New cards
t.down()
"""
Purpose: Draw a shape by connecting a list of points/vertices
"""
from turtle import Turtle #bring in the Turtle class

def main():
'''The main function of the program'''

#instantiate/create a turtle
goofy = Turtle()

#hide the turtle's body
goofy.hideturtle()

#the given list of points
listOfPoints = [(100, 100), (80, 150), (200, 250), (60, 10)]

#before drawing (raise the pen)
goofy.up()

#set pen color
goofy.pencolor('green')

#start drawing
drawShape(goofy, listOfPoints)

def drawShape(t, points):
'''Draw a shape by connecting a list of points/vertices'''

#go to the last point in the list
(x, y) = points[-1]
t.goto(x, y)

#lower the pen
________

#connecting all points
for (x, y) in points:
t.goto(x, y)

#the entry point of execution
main()
36
New cards
(x,y)
"""
Purpose: Draw a shape by connecting a list of points/vertices
"""
from turtle import Turtle #bring in the Turtle class

def main():
'''The main function of the program'''

#instantiate/create a turtle
goofy = Turtle()

#hide the turtle's body
goofy.hideturtle()

#the given list of points
listOfPoints = [(100, 100), (80, 150), (200, 250), (60, 10)]

#before drawing (raise the pen)
goofy.up()

#set pen color
goofy.pencolor('green')

#start drawing
drawShape(goofy, listOfPoints)

def drawShape(t, points):
'''Draw a shape by connecting a list of points/vertices'''

#go to the last point in the list
(x, y) = points[-1]
t.goto(x, y)

#lower the pen
t.down()

#connecting all points
for ____ in points:
t.goto(x, y)

#the entry point of execution
main()
37
New cards
points
"""
Purpose: Draw a shape by connecting a list of points/vertices
"""
from turtle import Turtle #bring in the Turtle class

def main():
'''The main function of the program'''

#instantiate/create a turtle
goofy = Turtle()

#hide the turtle's body
goofy.hideturtle()

#the given list of points
listOfPoints = [(100, 100), (80, 150), (200, 250), (60, 10)]

#before drawing (raise the pen)
goofy.up()

#set pen color
goofy.pencolor('green')

#start drawing
drawShape(goofy, listOfPoints)

def drawShape(t, points):
'''Draw a shape by connecting a list of points/vertices'''

#go to the last point in the list
(x, y) = points[-1]
t.goto(x, y)

#lower the pen
t.down()

#connecting all points
for (x, y) in ______:
t.goto(x, y)

#the entry point of execution
main()
38
New cards
goto(x,y)
"""
Purpose: Draw a shape by connecting a list of points/vertices
"""
from turtle import Turtle #bring in the Turtle class

def main():
'''The main function of the program'''

#instantiate/create a turtle
goofy = Turtle()

#hide the turtle's body
goofy.hideturtle()

#the given list of points
listOfPoints = [(100, 100), (80, 150), (200, 250), (60, 10)]

#before drawing (raise the pen)
goofy.up()

#set pen color
goofy.pencolor('green')

#start drawing
drawShape(goofy, listOfPoints)

def drawShape(t, points):
'''Draw a shape by connecting a list of points/vertices'''

#go to the last point in the list
(x, y) = points[-1]
t.goto(x, y)

#lower the pen
t.down()

#connecting all points
for (x, y) in points:
t.________

#the entry point of execution
main()
39
New cards
Turtle
"""
Purpose: Take a random walk
"""
from turtle import ______
from random import randint

def main():
'''The main function of the program'''

#create a turtle
goody = Turtle()

#hide the turtle's body
goody.hideturtle()

#start walking randomly
randomWalk(goody, 30, 50)

def randomWalk(t, turns, distance):
'''Walk randomly'''

for i in range(turns):
t.setheading(randint(0, 360))
t.forward(distance)

#the entry point of execution
main()
40
New cards
random, randint
"""
Purpose: Take a random walk
"""
from turtle import Turtle
from ______ import _______

def main():
'''The main function of the program'''

#create a turtle
goody = Turtle()

#hide the turtle's body
goody.hideturtle()

#start walking randomly
randomWalk(goody, 30, 50)

def randomWalk(t, turns, distance):
'''Walk randomly'''

for i in range(turns):
t.setheading(randint(0, 360))
t.forward(distance)

#the entry point of execution
main()
41
New cards
goody.hideturtle()
"""
Purpose: Take a random walk
"""
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
________________

#start walking randomly
randomWalk(goody, 30, 50)

def randomWalk(t, turns, distance):
'''Walk randomly'''

for i in range(turns):
t.setheading(randint(0, 360))
t.forward(distance)

#the entry point of execution
main()
42
New cards
randomWalk
"""
Purpose: Take a random walk
"""
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()

#start walking randomly
__________(goody, 30, 50)

def randomWalk(t, turns, distance):
'''Walk randomly'''

for i in range(turns):
t.setheading(randint(0, 360))
t.forward(distance)

#the entry point of execution
main()
43
New cards
i, turns
"""
Purpose: Take a random walk
"""
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()

#start walking randomly
randomWalk(goody, 30, 50)

def randomWalk(t, turns, distance):
'''Walk randomly'''

for _ in range(_____):
t.setheading(randint(0, 360))
t.forward(distance)

#the entry point of execution
main()
44
New cards
setheading
"""
Purpose: Take a random walk
"""
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()

#start walking randomly
randomWalk(goody, 30, 50)

def randomWalk(t, turns, distance):
'''Walk randomly'''

for i in range(turns):
t._________(randint(0, 360))
t.forward(distance)

#the entry point of execution
main()
45
New cards
randint(0,360)
"""
Purpose: Take a random walk
"""
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()

#start walking randomly
randomWalk(goody, 30, 50)

def randomWalk(t, turns, distance):
'''Walk randomly'''

for i in range(turns):
t.setheading(_____________)
t.forward(distance)

#the entry point of execution
main()
46
New cards
forward(distance)
"""
Purpose: Take a random walk
"""
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()

#start walking randomly
randomWalk(goody, 30, 50)

def randomWalk(t, turns, distance):
'''Walk randomly'''

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)

#the entry point of execution
donut()
58
New cards
goofy.pencolor(randint(0,255), randint(0,255), randint(0,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
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 __gt__(self, other):
'''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")

#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 __gt__(self, other):
'''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")

#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 __gt__(self, other):
'''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")

#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 __gt__(self, other):
'''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")

#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 __gt__(self, other):
'''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")

#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 __gt__(self, other):
'''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")

#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")

#the entry point of execution
main()