1. Home
  2. Data Science
  3. Python
  4. What is the purpose of the 'range' function in Python?

Added 10 Feb 2024

What is the purpose of the 'range' function in Python?

  1. To generate a random number
  2. To create a sequence of numbers Correct answer
  3. To calculate the length of a list
  4. To round a floating-point number

Correct answer

B. To create a sequence of numbers

17 views

MCQSEXAM

Explanation

The 'range' function in Python is used to generate a sequence of numbers within a specified range. It is commonly used in conjunction with 'for' loops to control the number of iterations.

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs