Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Demonstration of Python range()

# welcome to softhunt.net
# Python Program to
# show range() basics
# printing a number
print('Numbers: ')
for i in range(15):
	print(i, end=" ")
print()

# using range for iteration
print('using range for iteration: ')
l = [5, 10, 15, 20, 25]
for i in range(len(l)):
	print(l[i], end=" ")
print()

# performing sum of natural
# number
sum = 0
for i in range(1, 16):
	sum = sum + i
print("Sum of first 15 natural number :", sum)
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Demonstration #Python
ADD COMMENT
Topic
Name
8+1 =