0% found this document useful (0 votes)
22 views3 pages

05 Dictionary Oct 2024

Uploaded by

aryansanghani27
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)
22 views3 pages

05 Dictionary Oct 2024

Uploaded by

aryansanghani27
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/ 3

CLASS - XI - (INFORMATICS PRACTICES) Date: 07-10-2024

PYTHON PROGRAMMING ( ASS.- 5 )

Dictionary
1) Write a Python script to create a dictionary by define any 7 students name as key and
their total marks as respective values.

2) Store any five students grno into list, Store their name into another list, Create a dictionary
as the students grno are keys and their names are valuesof dictionary . Print the
dictionary.

3) Define a dictionary , day position number as key and day name as respective position
values . Also write code to input the day position and print that day name.

4) Create a dictionary store the number 1 to 10 as key of dictionary and their cube as values
for e.g. { 3:27} , Print the dictionary two column format.

5) Create a dictionary store the number 1 to 1000 into a list and their square value into
another list . Create a dictionary with using these list with number as key and their
square as value. Print the dictionary in multiple column

6) Write a Python script to check input any 10 customer’s mobile numbers as key and their
name as values . If any mobile number already entered , flash a message that number
already exist please enter other number.

7) Write a Python program to map two lists into a dictionary (enter any 5 states name into
list and their capital into another list). Print the dictionary in columns format.

8) Write a program input any number 1 to 100 and print their spelling by implement
dictionary .

9) Write a program input any five city name into a dictionary as key and their population as
their values. If the city already exist flash a message “city already exist” and does not
add. Print the dictionary columns format.

10) Write a python program to enter gr number and store that gr number as key of
dictionary , if that exist previously flash message “GR Number already exist” ,other wise
as enter student name and store as value of that gr number.

11) Write a python program to enter a string , store each unique character of string into the
key of dictionary and their frequency as value of dictionary. Print the dictionary in two
columns format key , values.
12) School is celebrating fruits and vegetable for the class of UKG-C . The class teacher
instruct the students to bring any one fruit or vegetable from their home.
Write python program to enter the student roll number and the fruit / vegetable name
that he bring. Store the roll number as key and their fruits/ vegetable as value. ( only one
students have one entry )
Write python code to create another dictionary to define all the unique fruits /
vegetable as key and their frequency as values of dictionary .

13) Write a Python program to create dictionary city , use the given two lists. List a to be the
key of dictionary and list b the values of dictionary.
Also write python code to create new dictionary by sorting the key of dictionary . print
the dictionary before soft and after sort.
a=[4,6,8,2,3,1,7,5 ]
b=['SURAT','DELHI','JAIPUR','CHENNAI','PANJI','GOA','THANE','MUMBAI']

14) Store five students information in the form of nested dictionary. Student’s roll number as
outer dictionary key, students information as inner dictionary values. Inner dictionary
keyes : sname , class, age, total,result , inner dictionary values : like ‘rohit’, ‘xi-a’, 16 , 450
, ‘pass’ . Print the information proper row and columns format

15) Write python program to enter students grno, name, activity, fees of 5 students . store
the information in the form of nested dictionary and print the dictionary in two columns
format.

16) Create a menu driven program to add, delete , display information from dictionary .
Like
Employee Information
--------------------------------------------------------------------------------
1 - Add Employee Infomratin
2 - Display Employee Information by empid
3 - Searching Employee information
4 - Modify employee information by empid
5 - Delete employee information
6 – Close the program.
----------------------------------------------------------------------------
Enter your choice :
#17) Write a program input any number 1 to 99999 and print their spelling by implement
dictionary .
def spelling(n):
sp={0:'zero',1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',
10:'ten',11:'eleven',12:'twelve',13:'thirteen',14:'fourteen', 15:'fifteen',16:'sixteen',
17:'seventeen',18:'eighteen',19:'ninteen', 20:'twenty',21:'thirty',22:'fourty',23:'fifty',
24:'sixty',25:'seventy',26:'eighty',27:'ninty'}
n=int(input("Enter any number : "))
s=''
if n>99999 or n<0:
print(n, 'value should be 0 to 99999')
return ''
else:
if n>=1000:
th=n//1000
if th<=20:
s=s+sp[th]+' '+' thousands '
else:
t=th%10
th=th//10
if t!=0:
s=s+sp[18+th] + sp[t]+ ' thousands '
else:
s=s+sp[18+th] + ' thousands '
n=n%1000
if n>=100:
h=n//100
if h != 0:
s=s+sp[h]+' hundreds '
n=n%100
if n<=20:
if len(s)==0:
s=s+sp[n]
else:
x=n%10
n=n//10
if x!=0 and n !=0:
s=s+sp[18+n]+sp[x]
else:
s=s+sp[18+n]
return s.capitalize()
#----------------------------------------------------

n=int(input("Enter any number to print spellig : "))


print(n , spelling(n))

#--------------------------------------------------

You might also like