D. Read the document Python's range expression, doing the next set of questions while you do so. D. For the next several questions, consider the following snippet of code:
  for k in range(500): 
print(k)
1. What is the first number that the above loop prints? ANS. 0 1. What is the last number that the above loop prints? ANS. 499 1. How many numbers does the above loop print? ANS. 500 D. For the next several questions, consider the following snippet of code:
  for k in range(300, 700): 
print(k)
1. What is the first number that the above loop prints? ANS. 300 1. What is the last number that the above loop prints? ANS. 699 1. How many numbers does the above loop print? ANS. 400 D. For the next several questions, consider the following snippet of code:
  for k in range(300, 320, 5): 
print(k)
1. What is the first number that the above loop prints? ANS. 300 1. What is the last number that the above loop prints? ANS. 315 1. How many numbers does the above loop print? ANS. 4 D. For the next several questions, consider the following snippet of code:
  for k in range(300, 321, 5): 
print(k)
1. What is the first number that the above loop prints? ANS. 300 1. What is the last number that the above loop prints? ANS. 320 1. How many numbers does the above loop print? ANS. 5 D. For the next several questions, consider the following snippet of code:
  for k in range(321, 300, -5): 
print(k)
1. What is the first number that the above loop prints? ANS. 321 1. What is the last number that the above loop prints? ANS. 301 1. How many numbers does the above loop print? ANS. 5 1. How many numbers does the following code snippet print?
  for k in range(1, 10, -1): 
print(k)
ANS. 0 ANS. None 1. A student wrote the following code to compute n! (n factorial).
product = 1 
for k in range(n, 0):
product = product * k
What error did the student make? 1. True or false: The code snippet
total = 0 
for k in range(m, n):
total = total + k
print(total)
and
total = 0 
for j in range(n - m):
total = total + j + m
print(total)
both print the same thing. a. True~ b. False D. Watch the video Box and Pointer Diagrams, doing the next set of questions while you do so. 1. True or False?
A box and pointer diagram helps explain the idea that a variable is a REFERENCE to its value.
a. True~ b. False 2. True or False?
A box and pointer diagram helps show the CONSEQUENCES of the idea that a variable is a REFERENCE to its value.
a. True~ b. False 3. A block and pointer diagram: a. Shows the flow of control of a program. b. Gives hints for how to ship boxes safely. c. Explains why cats chase laser pointers. d. Shows a snapshot of the variables and their values at a given point of a program's execution.~ 4. True or False?
In Python, every piece of data is an OBJECT.
a. True~ b. False 4. True or False?
Every object has a TYPE.
a. True~ b. False 5. What is the TYPE of the object 98.6? a. int (shorthand for integer) b. float (shorthand for floating-point number)~ c. str (shorthand for string) d. None of the above 6. What is the type of the object 48? a. int (shorthand for integer)~ b. float (shorthand for floating-point number) c. str (shorthand for string) d. None of the above 7. What is the type of the object 'Once upon a time ...'? a. int (shorthand for integer) b. float (shorthand for floating-point number) c. str (shorthand for string)~ d. None of the above 8. What is the type of the object "HELLO"? a. int (shorthand for integer) b. float (shorthand for floating-point number) c. str (shorthand for string)~ d. None of the above 9. Consider the line of code:
 c2 = rg.Circle(rg.Point(100, 300), 45) 
Are the following equivalent?
c2 REFERS to the rg.Circle whose center is at (100, 300) and whose radius is 45.
c2 POINTS to the rg.Circle whose center is at (100, 300) and whose radius is 45.
c2 is the NAME OF the rg.Circle whose center is at (100, 300) and whose radius is 45.
a. Yes, they are equivalent.~ b. No, they are NOT equivalent. 10. Consider the line of code:
 x = 53 
True or False: x refers to the integer 53. a. True~ b. False 11. Consider the line of code:
 s = 'Greetings, earthling!' 
True or False: s is the name of the string 'Greetings, earthling!'. a. True~ b. False 12. Consider the line of code:
 s = 'Greetings, earthling!' 
True or False: s points to the string 'Greetings, earthling!'. a. True~ b. False 13. Which of the following are CONTAINER objects? a. rg.Point(0, 0)~ b. 0 c. (0, 0)~ d. [0, 0, 0]~ e. rg.Rectangle(rg.Point(3, 20), rg.Point(300, 500))~ f. 100 g. 0.0 h. 'Hello'~ i. 'H'~ j. '' (that is, the empty string)~ k. The Python object None l. The Python object True 14. Consider the Python statement:
 temperature = 98.6 
Which of the following is a correct box-and-pointer diagram of that statement?


a. The FIRST diagram (on the top) is correct. b. The SECOND diagram (on the bottom) is correct.~ 15. Consider the Python statement:
 center = rg.Point(50, 30) 
Which of the following is a correct box-and-pointer diagram of that statement?




a. The FIRST diagram (on the top) is correct. b. The SECOND diagram (in the middle) is correct. b. The THIRD diagram (on the bottom) is correct.~ 16. Consider the code snippet:
 x = 50 
y = 30
center = rg.Point(x, y)
Which of the following is a correct box-and-pointer diagram for that snippet?


a. The FIRST diagram (on the top) is correct. b. The SECOND diagram (on the bottom) is correct.~ 17. Consider the code snippet:
 y = 7 
y = y * 3
The box-and-pointer diagram after the FIRST line executes is as follows:
On a piece of scratch paper (NOT here in this Moodle quiz), re-draw the above diagram and then augment your diagram to show the effect of the SECOND line of code shown above. (Nothing to turn in for this problem: just leave its answer box blank.) D. The previous problem asked you to draw a box-and-pointer diagram for the following:
 y = 7 
y = y * 3
Here is a correct answer:
Compare your answer (that you wrote on scratch paper) to the above. Be sure that they are the same (and if not, bring any questions that you have about them to class). 18. Consider the code snippet:
 x = 10 
y = x * 2
p = rg.Point(x, y)
x = 40
p.y = 30
The box-and-pointer diagram after the FIRST THREE lines execute is as follows:
On a piece of scratch paper (NOT here in this Moodle quiz), re-draw the above diagram and then augment your diagram to show the effect of the last two lines of code shown above. (Nothing to turn in for this problem: just leave its answer box blank.) D. The previous problem asked you to draw a box-and-pointer diagram for the following:
 x = 10 
y = x * 2
p = rg.Point(x, y)
x = 40
p.y = 30
Here is a correct answer.
Compare your answer (that you wrote on scratch paper) to the above. Be sure that they are the same (and if not, bring any questions that you have about them to class). 19. Consider the code snippet:
 number1 = 88 
number2 = number1
Explain what is WRONG about the following attempt at a box-and-pointer diagram for the above code snippet:
20. Consider the code snippet:
 r = 66 
r2 = r
center = rg.Point(90, 40)
circle = rg.Circle(center, r)
r = 35
center.x = 200

print(r)
print(r2)
print(center)
print(circle)
Determine IN YOUR HEAD (that is, without using a computer and without using any scratch paper) what would be printed when the above code snippet executes. In the box below, write your answer for what would be printed. (The details of how you write the center and circle are unimportant; any way is fine. Just don't use any VARIABLES in your answer. That is, use only NUMBERS and the class names rg.Circle and rg.Point.) 21. On a piece of scratch paper (NOT here in this Moodle quiz), draw a box and pointer diagram for the FIRST FOUR lines of the code snippet in the previous problem. (Nothing to turn in for this problem: just leave its answer box blank.) D. The previous problem asked you to draw a box-and-pointer diagram for the FIRST FOUR lines of the following six-line code snippet:
 r = 66 
r2 = r
center = rg.Point(90, 40)
circle = rg.Circle(center, r)
r = 35
center.x = 200
Here is a correct answer to the previous problem:
Compare your answer (that you wrote on scratch paper) to the above. Be sure that they are the same (and if not, bring any questions that you have about them to class). 22. Augment your box-and-pointer diagram for the previous problem to include the remaining two lines of its code snippet. (Nothing to turn in for this problem: just leave its answer box blank.) D. The previous problem asked you to draw a box-and-pointer diagram for the first six lines of the following code snippet:
 r = 66 
r2 = r
center = rg.Point(90, 40)
circle = rg.Circle(center, r)
r = 35
center.x = 200

print(r)
print(r2)
print(center)
print(circle)
Here is a correct answer to the previous problem:
Compare your answer (that you wrote on scratch paper) to the above. Be sure that they are the same (and if not, bring any questions that you have about them to class). 23. Now that you have a box-and-pointer diagram for the above code snippet, consider again: What what would be printed when the above code snippet executes? In the box below, write your answer for what would be printed. Compare your answer to THIS problem to what you wrote for a PREVIOUS problem (three problems back) that asked the same question. Are the two answers the same? If they are NOT the same, and you are uncertain which is correct, bring any questions that you have to class.