208k views
1 vote
What does this loop that uses a range function do? for i in range(7, 15): print("goodbye") It prints "goodbye" 8 times, numbered from 7 through 14. It prints "goodbye" 9 times, numbered from 7 through 15. It prints "goodbye" 9 times. It prints "goodbye" 8 times.

2 Answers

4 votes

Answer:

8 times is right

Step-by-step explanation:

User BrettMiller
by
5.5k points
4 votes

Answer:

It prints "goodbye" 8 times.

Step-by-step explanation:

The loop being described in this scenario would print "goodbye" 8 times. It would not include numbers detailing the range since the loop instructions only state for the system to print("goodbye") and nothing else. Also, it would only print it 8 times because in a range the endpoint is not included, this is mainly because in programming data structures tend to run on 0-based indexing.

User Mdsingh
by
5.5k points