Question Detail

COS 102 6 lecture note; fundamentals of programming Objective Question

Question

What does the range() function return in Python, by default?
Options
A A single integer starting from 1.
B A sequence of numbers starting from 0, incrementing by 1, and ending at a specified number.
Correct Answer
C A random number within a given interval.
D A boolean value indicating true or false.
Correct Answer

Option B is the correct answer.

Detailed Explanation

Page 78 explains: 'The range() function returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and ends at a specified number.'

Hint

Think about how for loops often generate a sequence of numbers for iteration.

Question Info