You are on page 1of 4

INTRODUCTION TO COMPUTER PROGRAMING AND DATA SCIENCE

LAB # 7
SUBMISSION DATE:20/01/2023
#GROUP 8

ASSIGNMENT # 1
INPUT CODE:
#2022-ME-312

#2022-ME-321

#2022-M3-325

#Tuples

INPUT:
import random

N=('man','boy','girl','haider','Ayesha','Bilal','mountains','river','car','car','machine','fan')

V=('dance','do','run','sleep','eat','jump','play','fight','go','fall')

A=('beautiful','adorable','fast','lazy','soundly','jealous','cruel','awful','clever')

Numcurses=int(input('Enter the number of curses:'))

for Curse in range(Numcurses):

i1=random.randrange(0,len(N))

i2=random.randrange(0,len(V))

i3=random.randrange(0,len(A))

i4=random.randrange(0,len(N))

i5=random.randrange(0,len(V))

i6=random.randrange(0,len(A))

print(N[i1],'can',V[i2],'and',V[i5],A[i3]+'.')
OUTPUT:
Enter the number of curses:8

fan can fall and do jealous.

Ayesha can go and fall adorable.

mountains can go and jump fast.

river can jump and eat jealous.

Bilal can run and jump cruel.

Bilal can dance and do jealous.

machine can sleep and jump cruel.

boy can run and play fast.


ASSIGNMENT # 2
#2022-ME-312

#2022-ME-321

#2022-M3-325

#Descending order

INPUT:
a=('iamhighlyconfusedbytis')

b=[]

for ppp in a:

b.append(ppp)

o=set(b)

o=list(o)

o.sort()

yu={}

l=[]

for t in o:

p=0

for r in b:

if(t==r):

p=p+1

yu[str(t)]=str(p)

sorted_values=sorted(yu.values(),reverse=True)

sorted_dict={}

for i in sorted_values:

for k in yu.keys():
if yu[k]==i:

sorted_dict[k]=yu[k]

for io in sorted_dict.keys():

print(io,' ',sorted_dict[io])

OUTPUT:
i 3

h 2

s 2

y 2

a 1

b 1

c 1

d 1

e 1

f 1

g 1

l 1

m 1

n 1

o 1

t 1

u 1

You might also like