147k views
0 votes
Write a for loop with a three-parameter range() function that prints the μltiples of 7 between 0 and 100. Print one μltiple per line and avoid printing any numbers that aren't μltiples of 7. Remember that 0 is also a μltiple of 7.

a. for i in range(0, 101, 7):
print(i)
b. for i in range(7, 101, 7):
print(i)
c. for i in range(1, 100, 7):
print(i)
d. for i in range(0, 100, 7):
print(i)

User Dzhu
by
7.4k points

1 Answer

2 votes

Final answer:

The correct for loop to print multiples of 7 between 0 and 100 is 'for i in range(0, 101, 7): print(i)'. This loop will include 0 and exclude any number that is not a multiple of 7, ending before 101.

Step-by-step explanation:

To write a for loop with a three-parameter range() function that prints the multiples of 7 between 0 and 100, including the number 0, we need to make sure that the loop starts at 0 and increases in steps of 7 up to 100. Therefore, the correct option is:

a. for i in range(0, 101, 7): print(i)

The range starts at 0, ends just before 101, and increments by 7 in each step. Here's how it looks like in a loop:

for i in range(0, 101, 7):
print(i)

This will print all multiples of seven from 0 up to and including 98, as 98 is the last multiple of 7 before 100.

User Andrew Eddie
by
7.5k points