Question: 1. We use loops ________________________. a) to test if more than one condition is true b) to do calculations on user input c) to repeat

1. We use loops ________________________.

a) to test if more than one condition is true
b) to do calculations on user input
c) to repeat a section of code
d) as a gate to block off sections of code

2. Consider the following code:

for i in range (x, y, z): print (i, end=" ")

What values for variables x, y, and z will produce the output below?

26 24 22 20 18 16 14 12 10 a) x = 26 y = 8 z = -2 b) x = 10 y = 28 z = -2 c) x = 26 y = 10 z = -2 d) x = 10 y = 28 z = 2

3. What is output by the following code?

for x in range (4): for y in range (3): print ("*", end=" ") print (" ")

a) * * * * * * * * * * * *

b) * * * * * * * * * * * * * * * * * * * *

c) * * * * * * * * * * * *

d) * * * * * * * * * * * * * * * * * * * *

4. Consider the following code:

start = int(input("Enter the starting number: ")) stop = int(input("Enter the ending number: "))

for i in range (start, stop): print (i, end=" ")

What variable is the loop control variable in this program?

a) i b) This loop doesn't have a control variable. c) start d) stop

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!