In: Computer Science
import random
#first way to create LIST
#declare an empty list
Num=[]
for i in range(0,10): #loop to add numbers into list
#generate a number between 1 to 100 with step value 1 and
append
#it to Num[] list
Num.append(random.randrange(1,100,1))
#print the elements of Num
print(Num)
#second way to create List
#declare and initialize a list by fixed numbers
Numbers = [2,34,54,67,4,21,99,87,45,55]
print(Numbers) #print the list
#third way to create a list
Number=[]
for i in range(0,10): #loop to add numbers into list
Number.append(random.choice(Numbers)) #fill the list by randomly
choosen from Numbers List
print(Number)
#print the numbers from 1 to 10 using while loop
print("Print the numbers using WHILE loop : ",end=' ')
i=1
while (i<=10):
print(i,end=' ') #print the numbers
i=i+1#increase the value of i
print("")
#print the numbers from 1 to 10 using FOR loop
print("Print the numbers using FOR loop : ",end=' ')
for i in range(1,11):
print(i,end=' ')
#print the elements of first LIST by using FOR loop
print("")
print("Print the elements of list by using FOR loop : ",end='
')
for i in range(0,len(Num)-1):
print(Num[i],end='& ')
print(Num[i+1])
#print the elements of second LIST by using FOR loop
print("")
print("Print the elements of list by using FOR loop : ",end='
')
for i in range(0,len(Numbers)-1):
print(Numbers[i],end='& ')
print(Numbers[i+1])
#print the elements of third LIST by using FOR loop
print("")
print("Print the elements of list by using FOR loop : ",end='
')
for i in range(0,len(Number)-1):
print(Number[i],end='& ')
print(Number[i+1])
OUTPUT