Vidyalelo
Python · Q29

Python Introduction and basic

Programming · Python · question 29

Q29

What does the range() function in Python generate?

A.
A sequence of integers
Answer
B.
A random number
C.
A floating-point number
D.
A list of strings

Answer: Option A

Solution

Answer: Option A
Solution:
The range() function in Python generates a sequence of integers.
When called with one argument, range(n) produces a sequence of integers from 0 up to (but not including) n. When called with two arguments, range(start, stop) produces a sequence of integers from start up to (but not including) stop. The range() function is commonly used in for loops to iterate over a sequence of numbers. It provides a convenient way to generate sequences of integers without needing to manually specify each individual value.