You are on page 1of 3

LAB-4

 Write a program using function which does the following


1. Create a list of 10 random numbers between 10 and 100
2. Create a tuple of 8 random numbers between 20and 200
3.Create a dictionary of 7 key:values –random characters as key and
ASCII as its value

import random
def clist():
l=[]
for i in range(10):
n=random.randint(10,100)
l+=[n]
return l
def ctuple():
t=()
for i in range(8):
n=random.randint(20,200)
t+=(n,)
return t
def cdict():
d={}
for i in range(7):
1|Page
a=random.randint(65,80)
b=chr(a)
d.update({b:a})
return d
while True:
print("1.Create a list of 10 random numbers between 10 and 100")
print("2.Create a tuple of 8 random numbers between 20 & 200")
print("3.Create a dictionary of 7 key:values-random characters as
key and ASCII as its value")
ch=int(input("enter your choice:"))
if ch==1:
l=clist()
print(l)
elif ch==2:
t=ctuple()
print(t)
elif ch==3:
d=cdict()
print(d)
else:
print("Invalid Choice")
break

2|Page
3|Page

You might also like