0% found this document useful (0 votes)
208 views2 pages

Program 8. Nested Dictionary Aim

The document describes a Python program that uses nested dictionaries to store scores obtained by categories (seniors, juniors, sub-juniors) for each of four houses (BHARATHI, TAGORE, PRATAP, SHIVAJI). The program takes input of scores, stores them in the nested dictionary, and prints the house with the maximum score for each category.

Uploaded by

vimala
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)
208 views2 pages

Program 8. Nested Dictionary Aim

The document describes a Python program that uses nested dictionaries to store scores obtained by categories (seniors, juniors, sub-juniors) for each of four houses (BHARATHI, TAGORE, PRATAP, SHIVAJI). The program takes input of scores, stores them in the nested dictionary, and prints the house with the maximum score for each category.

Uploaded by

vimala
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/ 2

PROGRAM 8.

NESTED DICTIONARY
AIM:
To create a nested dictionary for categories SENIORS/ JUNIORS/ SUBJUNIORS
for each house BHARATHI / TAGORE/ PRATAP/ SHIVAJI, scores obtained.
Display the house with the maximum score for each category
PROGRAM CODING
d={}
for i in range(4):
d1={}
hn=input("enter the house name:")
s=int(input("enter scores of the seniors:"))
j=int(input("enter the scores of the juniors:"))
sj=int(input("enter thr scores the sub-juniors:"))
d1['seniors']=s
d1['juniors']=j
d1['sub-juniors']=sj
d[hn]=d1
dk=list(d.keys())
ls,lj,lsj=[],[],[]
for i in dk:
lk=list(d[i].values())
ls+=[lk[0]]
lj+=[lk[1]]
lsj+=[lk[2]]
a=ls.index(max(ls))
b=lj.index(max(lj))
c=lsj.index(max(lsj))
print('Winners of seniors:',max(ls),dk[a])
print('Winners of juniors:',max(lj),dk[b])
print('Winners of sub-juniors:',max(lsj),dk[c])
OUTPUT
enter the house name:BHARATHI
enter scores of the seniors:100
enter the scores of the juniors:56
enter thr scores the sub-juniors:25
enter the house name:PRATAP
enter scores of the seniors:90
enter the scores of the juniors:45
enter thr scores the sub-juniors:58
enter the house name:TAGORE
enter scores of the seniors:95
enter the scores of the juniors:32
enter thr scores the sub-juniors:12
enter the house name:SHIVAJI
enter scores of the seniors:85
enter the scores of the juniors:67
enter thr scores the sub-juniors:15
winners of seniors: 100 BHARATHI
winners of juniors: 67 SHIVAJI
winners of sub-juniors: 58 PRATAP

You might also like