3
QuizMultiple Choice

Use Data Structures — Cumulative exam

Question 3 • Introduction to Information Technology - EL3701

What does this loop that uses a range function do? for i in range(7, 15):print(“goodbye”)

Answer
A
It prints “goodbye” 8 times, numbered from 7 through 14.
B
It prints “goodbye” 9 times, numbered from 7 through 15.
C
It prints “goodbye” 9 times.
D
It prints “goodbye” 8 times.

Explanation

In Python, range(7, 15) produces the values 7 through 14; the stop value, 15, is not included. That is 8 values, and the loop prints “goodbye” once for each value. Since the print statement does not include i, the messages are not numbered.

AI-written and checked against the verified answer.

Previous
Next