Here are the answers to all questions from Quiz 2.

#### Question 1

The code

``````for i in range(10):
print(i)``````

will run total of 10 times. The first time through, it will print 0, next time through, it will print 1, etc. The last number printed will be 9. The correct answer is d.

#### Question 2

The code

``````from turtle import *
for i in range(6):
forward(200)
left(60)``````

will import the Turtle Graphics module and then six times execute the two indented statements (forward(200) and left(60)). The outer angle at each point is 60° which means that the inner angle is 120°. The correct answer is c, it will draw a regular hexagon.

#### Question 3

The code

``````from turtle import *
for i in range(3):
left(120)
forward(200)``````

will import the Turtle Graphics module and then execute the indented statement three times. In this case, the indented statement is left(120), so it will turn left 120° three times for a total of 360°. In other words, it will point in the same direction it started; i.e. East or 3 o’clock. After that, it will just draw a straight line of length 200 pixels. The correct answer is d.

#### Question 4

The code

``````a = 25
b = 3
a -= b
print(a)``````

will assign the value 25 to variable a. Then it will assign 3 to variable b. Finally, it will reduce a by b, so a now holds 25 – 3 = 22. The correct answer is a.