Name: _______________
Python Review!!
What is the difference between = and ==? Why are both used?
Given the following variable definitions:
i = 0
d = 1.1
s = "kelly"
Evaluate the following:
Expression True or False
i == 1
i <= -20
s == "kelly"
s != "Kelly"
d == i
i == "0"
Fill in the blanks to make all the following comparisons true
i > ___________
___________ <= d
s == ___________
not( i != ___________ )
Fill in the blank to make all the following comparisons false
i > ___________
___________ != d
s == ___________
Fill in the blank in the following program to make it so that it prompts the user for their
grade then tells them to study harder if they have below a 75 and congratulates them
otherwise:
grade = ____________("What is your grade?")
if(______________):
print("Very nice!")
else:
print("Study harder!")
What are the differences between while and for loops? Why do we need both?
What will be output by the following code?
def myst(foo):
for i in range(2):
print(foo * 2)
print("Foo was " + str(foo))
myst("goo")
What will be output by the following code?
while(2 > 1):
print("I will not talk while the teacher is talking.")
Fill in the blanks so that the following code prompts the user until a number between 1 and
10 is selected.
number = _____________________________________
while ( ________________________):
number = _____________("That is not a valid selection.
Please enter a number 1-10.")
What is output by the following program?
def do_it(goo):
print(goo)
do_that()
def do_that():
print("goo")
do_that()
do_it("hi")