900280-CLASS XI - CS-WS7-tuples&dictionary
900280-CLASS XI - CS-WS7-tuples&dictionary
KABIR
Class: XI SUB: COMPUTER SCIENCE Date of
Completion:
6. Write a python program which reads N number of elements from the user in a tuple T. Program finds and
displays the second largest element in the tuple.
7. If
>>>tup1=("bag", "book", "copy", "lunch box", "pencil box")
>>>tup2=(5, 10, 15, 20, 25, 30, 35)
Give the output:
a) >>>tup3= tup1[:]
b) >>>tup4= tup2[1:5]
10. Create a dictionary whose keys are month names and whose values are number of days in the
corresponding months.
i) Ask the user to enter month name and display the days in that month
ii) Print out all the keys in alphabetical order
iii) Print out the key value pairs sorted by the number of days in each month.
11. Write a program to enter names of employees and their salaries as input and store them in a dictionary.
12. Write a program to input your friends’ names and their Phone Numbers and store them in the
dictionary as the key-value pair. Perform the following operations on the dictionary:
a) Display the name and phone number of all your friends
b) Add a new key-value pair in this dictionary and display the modified dictionary
c) Delete a particular friend from the dictionary
d) Modify the phone number of an existing friend
e) Check if a friend is present in the dictionary or not
f) Display the dictionary in sorted order of names