🔥 Welcome to my blog! Latest updates available now. Visit daily! 🔥 🔥 Click Here for Latest Updates – Visit My Blog 🔥
🔥 Latest Updates 📊 GP Grade Finder 📢 Government Services Info 🆕 New Schemes Updates

range Data Type in Python

-->range Data Type represents a sequence of numbers.

-->The elements present in range Data type are not modifiable. i.e range Data type is immutable.


Form-1: range(10)#generate numbers from 0 to 9

Example:

rarange(10)

for i in r: print(i) 0 to 9


Form-2; range(10,20)#generate numbers from 10 to 19

r = range(10,20)

for i in r: print(i) 10 to 19


Form-3: range(10,20,2)#2 means increment value.

r = range(10,20,2)

for i in r: print(i) #10,12,14,16,18


-->We can access elements present in the range Data Type by using index.


r=range(10,20)

r[0]==>10

r[15]==>IndexError: range object index out of range

-->We cannot modify the values of range data type

Example:

r[0]=100

TypeError: 'range' object does not support item assignment.

-->We can create a list of values with range data type.

Example

>>> l=list(range(10))

>>>l#[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

No comments:

Post a Comment

Thank you Very Much.For Given Comment

Free 51 Websites for Learning Education and Courses

🛑 లక్à°·à°²ు à°–à°°్à°šుà°ªెà°Ÿ్à°Ÿి à°•ాà°²ేà°œీà°²్à°²ో à°¨ేà°°్à°šుà°•ోà°²ేà°¨ి à°µిà°·à°¯ాలను, à°«్à°°ీà°—ా à°¨ేà°°్à°ªింà°šే 51 à°…à°¦్à°­ుతమైà°¨ à°µెà°¬్‌à°¸ైà°Ÿ్à°²ు ఇవే! 🛑 à°Žà°¡్à°¯ుà°•ేà°·à°¨్ and à°•ోà°°్à°¸ుà°²ు: Co...