हिंदी

What is the purpose of the range() function? Give one example.

Advertisements
Advertisements

प्रश्न

What is the purpose of the range() function? Give one example.

टिप्पणी लिखिए
Advertisements

उत्तर

The range() function is a built-in function of Python. It is used to create a list containing a sequence of integers from the given start value to the stop value (excluding the stop value). This is often used in for loop for generating the sequence of numbers.

​Example:

for num in range(0,5):
print (num)

OUTPUT:
0
1
2
3
​4
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 6: Flow of Control - Exercise [पृष्ठ १३९]

APPEARS IN

एनसीईआरटी Computer Science [English] Class 11
अध्याय 6 Flow of Control
Exercise | Q 2. | पृष्ठ १३९
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×