0% found this document useful (0 votes)
27 views21 pages

DA2 Final PDF

The program stores information about 5 students such as name, phone number, and electricity units consumed in a dictionary. It then calculates the electricity bill amount for each student based on consumption slab rates and prints the output. It initializes lists to store the student data and adds it to the dictionary. For each student, it calculates the bill amount based on the slab rates and prints the name, phone number, and bill amount.

Uploaded by

Eshank Pal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views21 pages

DA2 Final PDF

The program stores information about 5 students such as name, phone number, and electricity units consumed in a dictionary. It then calculates the electricity bill amount for each student based on consumption slab rates and prints the output. It initializes lists to store the student data and adds it to the dictionary. For each student, it calculates the bill amount based on the slab rates and prints the name, phone number, and bill amount.

Uploaded by

Eshank Pal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

VELLORE INSTITUTE OF TECHNOLOGY

DA-2

BCSE101E – PYTHON PROGRAMMING

NAME: ESHANK PAL

REG NO.: 21BEC2140

LAB SLOT: L1+L2+L27+L28

FACULTY: ANTONY XAVIER GLITTAS


DA-2 2BEC21YO

o f 5 sludcnts
AIM To stoxe he intoornad ion
he 7ade o all
a dictionasy. and find
he shudents and poiit em

PRoCEpuRE
1: Open ychasnm

2. On he wxelcone S6eCn Ceale a ne psoje

3 On he psojeck tod wnd Selet te Neus

4ScledPylhon le Ond name


students rade,
res Python e nll be Coeated

5 Witt he P3ogpam Stuse he intomation


Shdent's in dicdionosl and psint h e 3sdes
Stulent.S

6 Chonge he CRnhqootion o heile to


Flel name

Rn the po9am and he Studats avade


wil e Pthte
ALORTTHM
STEP 1 Stuxe studenl s inoanmat ion

mex Ko.
STER 2 Coleuloke Student' awexage

SIEP 3 : 1 maks 90 paint the Studeni's qde


A
STEP4: maaks 2 Bo paint the Student's gode

STEP 65: mars to, ptind taShdat's q3ade


a'c

2 60 pind tha Studtls q1ode o D.


STEP 6 mas K
STE 3: Else pid studet' 1ade a

STEP 8 : Calaslake fhe cla weca mas o

STE 9 Ri Ave xage qaade

S1EP o Sto he Paogiam


FLON C HART

Stant n1tiauge anempg >Take Inpu F Suoant a

Jua

LntHali3ation 6
for i un
int Dictiuny Valuw
nam Studnts

|oblaining ChT, DA. ano


Peint u-gistraiur FAT Valut. o m obtnun
numai
dic

Caav aunage
To tai avosage -
iXGaut-au DA
d- aw
auua C
O 6x da -aV tiXxqu3
o'xfat -av ws-av aveage o s
Fas -aw - atuage ofF*T

taul appena Pins totat Pn A


Ctetal auuage otat age29d
auag
LF toaLavaag THotalav Pnt B

N
clas auage Sun
tF total-aves0
60 5 e L i s en (reauultlis"

Pant
E"NO

n - C 'kss avesage)
Class aveaga 9o
fantaH

if ClasS avege 780

Ef Class avaag: 77 Paat"c


F Class-avoage , 60
NO

Pan"e
Tesminafe
PROGRAM CODE:

Eshank = {"name": "Eshank",

"Roll number": "21BEC2116",

"CAT" : [38, 30],

"DA" : [10, 10],

"quiz": [10, 10],

"FAT": [98]

Raj = {"name": "Raj",

"Roll number": "21BEC02790",

"CAT" : [26, 28],

"DA" : [9, 8],

"quiz": [9, 10],

"FAT": [95]

Rohit = {"name": "Rohit",

"Roll number": "21BEC2137",

"CAT": [21, 23],

"DA": [3, 8],

"quiz": [10, 7],

"FAT": [93]

Tina = {"name": "Tina",

"Roll number": "21BEC2027",


"CAT" : [30, 30],

"DA" : [9, 10],

"quiz": [10, 10],

"FAT": [99]

Sam = {"name": "Sam",

"Roll number": "21BEC2077",

"CAT" : [39, 29],

"DA" : [9, 9],

"quiz": [20, 10],

"FAT": [98]

def get_average(marks):

total_sum = sum(marks)

total_sum = float(total_sum)

return total_sum / len(marks)

def calculate_total_average(students):

CAT = get_average(students["CAT"])

DA = get_average(students["DA"])

quiz = get_average(students["quiz"])

FAT = get_average(students["FAT"])
return (1 * CAT +

0.67 * DA + 1 * quiz + 0.4 * FAT)

# Calculate letter grade of each student

def assign_letter_grade(score):

if score >= 90:

return "A"

elif score >= 80:

return "B"

elif score >= 70:

return "C"

elif score >= 60:

return "D"

else:

return "E"

# Function to calculate the total

# average marks of the whole class

def class_average_is(student_list):

result_list = []

for student in student_list:

stud_avg = calculate_total_average(student)

result_list.append(stud_avg)

return get_average(result_list)
# Student list consisting the

# dictionary of all students

students = [Eshank, Raj, Rohit, Tina, Sam]

# Iterate through the students list

# and calculate their respective

# average marks and letter grade

for i in students:

print(i["name"])

print(i["Roll number"])

print("__")

print("Average marks of %s is : %s " % (i["name"],

calculate_total_average(i)))

print("Student's Grade of %s is : %s" % (i["name"],

assign_letter_grade(calculate_total_average(i))))

print()

# Calculate the average of whole class

class_av = class_average_is(students)

print("Class Average is %s" % (class_av))

print("Letter Grade of the class is %s "

% (assign_letter_grade(class_av)))

RESULT:
ALM To slunc he intomaion CUsloMC
hc TNER bil amourd
dickioncy nd find

PRoLEDURE
: Open Rychaarm
2 On the Leceme, SC3een CxEake a ne Pxee

3: n Paoje o ndot Sel ek Pe e .

4Selek pihe e Cnd Mame t NEB ,a


nes e,hen Rle e Cseaked

5: Wite ps0gC costpms noyma


n dictionany Ond Pind TNER bil Cmaunt

6 Chong Cnfiguahiou le
h@rme

n Pson Ona TNEB bil Omou


oe Paintea
ALGORITHM
Io Storc hCimenombta n d
STEP 1 beate adic imaoy
Cen SUmcY UnilAs.

STER 2. Tnitialize a st A ihname

STE 3 Ini bialie a 0st A wi nomc


Units
STEP 4:ntialize a Rist ith

STEP S tiali 2e a ephy list

Ttaate hrnugh list and alcolate he chage j..


STEP
STEP 3 7 s les a er u a o 200 Lst is 3.S

STEF 8 t ngebetwee th 201-SDo Ct is 1'S.

STEP9 ' s queader an Soo han Cst i 6:s

STEP 1 find tat eletri dby a pex gve Cand: hion

STEP : rin Nam

STEr 12 Paink mobile numbed

STE 13: Pin CBut ektdriuhy

SMEP 19: E k PTogYo


LO HART:

Stant 9nituniea
Tnttialge a Lal
La Lth uakiciua
hoe uunlis
9ntaipe

Cee mu

n ialige an
tmpy S
CrmonEl-A
Can Sunedonit
p-operez in

-:0
Paint mobile mumker (12t)
I funt coot o tledhucity s)

Tomuota)
PROGRAM CODE:

#<=200 3.5

#201-500 4.5

# >500 6.5

#RATES

z={}

L=['Eshank','Tony','Riya','Deep','Amit']

L2=['9908257153','9293819661','6274019371','9129667816','9814365012']

L3=[340,970,150,360,740]

z['NAME']=L

z['PHONE NO']=L2

z['consumed units']=L3

p=(z.values())

pp=[]

for i in z:

pp.append(z[i])

print("DICTIONARY IS")

print(z)

for i in range (0,5):

l=pp[2]

l1=pp[0]

c=l[i]

l2=pp[1]

# c=l[i]

s=0

if c<=200:

s=s+c*3.5

elif c>200 and c<=500:


s=s+(c-200)*4.5+100*3.5

elif c>500:

s=s+100*3.5+300*4.5+(c-500)*6.5

print("Name",l1[i])

print("mobile",l2[i])

print("cost of elec is",s)

print("------------")

RESULT:
ALMTo find n and
uncbion.

PRoCEDURE

1Opn Kghaan
2 weleom 6Cen, Cx eoe a ne prbjek

3 In projesADo toindou Sele FtleNes.

: Selek Pythen Rle Cnd ham t ewsve unchio


Pyh le L be Cxeatd

5 wite pxbgram Pain Volwe n nf

Chovge Ce iqration ile


le'b name

Ron Psoganm and hu desn ea eut


be prinked
ALGORTTHM:
STEP 1 : (sote o fundkiom h USinag

Holdotina fama
STEP 2: Fesfom calcslahion

(h-3)

STEP 3 Cscate afuncAion USimg de


VSing hP forula
STE: Pesfoomm Calcolahon
nP n_
(n-sS

STEP S: terate Cendi tios ad obtain

h Valwe n.
STER 6 nput
vawe T
STEP 3: nput

STEP 8: Pin

STEP 9 Pi Pr
STER to d
FLON CHnT

(-8)
(start deffatts)>def findt un

INum Fact )
d en Fact (a-)
twn P m-num acn
FF
num Fac+ )
deF And wmb (1.)
den. foct (a-g)
den fact 9)tder

Comb rum den Prin+(Cnt ie valu


etu Tnb 04 n:End-""]

n tn (nbw0)
(End PintL°Enio ihe Ualus o: td
u i t ( input))
Peant(lnfesmulaion(nRe)"findferaon
Punt "In Combiniatuon(nes)"
Fin d om b{n 7)
PROGRAM CODE:

def fact(k):

f=i=1

while i<=k:

f = i*f

i += 1

return f

def findperm(x, y):

num = fact(x)

den = fact(x - y)

perm = num / den

return perm

def findcomb(x, y):

num = fact(x)

den = fact(x - y)

den = fact(y) * den

comb = num / den

return comb

print("Enter the Value of n: ", end="")

n = int(input())

print("Enter the Value of r: ", end="")

r = int(input())

print("\nPermutation (nPr) =", findperm(n, r))

print("Combination (nCr) =", findcomb(n, r))


RESULT:

You might also like