Ayush (0301CS211029) Assignment 3
Ayush (0301CS211029) Assignment 3
#3 : List Assignment
list = [56.7,78,45.3,89,19.9,32.9,10.0,22.1,45.9,55.6]
for L in range(len(list)):
print("The average of player is : {0}".format(list[L]))
odd_list=[]
even_list=[]
L=1
for L in range(100):
if(L%2==0):
even_list.append(L)
else:
odd_list.append(L)
print(odd_list)
print(even_list)
import random
list= ["data", "science", "machine", "learning"]
list2=[]
cd=0
cs=0
cm=0
cl=0
for i in range(20):
list2.append(random.choice(list))
print(list2)
for i in range(len(list2)):
if(list2[i]=="data"):
cd +=1
elif(list2[i]=="science"):
cs+=1
elif(list2[i]=="machine"):
cm+=1
elif(list2[i]=="learning"):
cl+=1
print("Count of data : {0}".format(cd))
print("Count of science :{0} ".format(cs))
print("Count of machine : {0}".format(cm))
print("Count of machine :{0} ".format(cl))
#5) create 2 numeric lists having 1,2 and 3 digit numbers. (selected at random)
#The lists need not have the same count of numbers.
#Your task is to multiply
#all 1-digit number of list1 with all 1-digit numbers of list2
#all 2-digit numbers of list1 with all 2-digit numbers of list2
#all 3-digit numbers of list1 with all 3-digit numbers of list2
#expected output
#---------------
#1*6 = 6
#5*6 = 30
#102*239 = 24378
#100*239 = 23900
#45*15 = 675
#75*15 = 1125
import random
n1=random.randint(1,9)
n2=random.randint(1,9)
n3=random.randint(1,9)
n4=random.randint(1,9)
n5=random.randint(1,9)
n6=random.randint(1,9)
list1=[]
list2=[]
for i in range(n1):
list1.append(random.randint(1,9))
for i in range(n2):
list1.append(random.randint(10,99))
for i in range(n3):
list1.append(random.randint(100,999))
for i in range(n3):
list2.append(random.randint(1,9))
for i in range(n4):
list2.append(random.randint(10,99))
for i in range(n5):
list2.append(random.randint(100,999))
for n1 in list1:
for n2 in list2:
if((n1>=1 and n1<=9) and (n2>=1 and n2<=9)):
print("{0} * {1} = {2}".format(n1,n2,n1*n2))
for n1 in list1:
for n2 in list2:
if((n1>=10 and n1<=99) and (n2>=10 and n2<=99)):
print("{0} * {1} = {2}".format(n1,n2,n1*n2))
for n1 in list1:
for n2 in list2:
if((n1>=100 and n1<=999) and (n2>=100 and n2<=999)):
print("{0} * {1} = {2}".format(n1,n2,n1*n2))
#6) A list contains the email IDs of employees of different organisations in the
following format:
#<firstname>.<lastname>@<domain>
#[email protected]
#[email protected]
#[email protected]
#[email protected]
#[email protected]
#[email protected]
#[email protected]
list =
["[email protected]","[email protected]","sarita.patil@mycompany
.in","[email protected]","[email protected]","[email protected]",
"[email protected]"]