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

900280-CLASS XI - CS-WS7-tuples&dictionary

Uploaded by

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

900280-CLASS XI - CS-WS7-tuples&dictionary

Uploaded by

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

INDIAN SCHOOL AL WADI AL

KABIR
Class: XI SUB: COMPUTER SCIENCE Date of
Completion:

Worksheet No:7 TOPIC: Tuples & Note:


Dictionaries
Try all practical questions on the
python editor

1. What is tuple? Explain with suitable example.

2. How a List are different from Tuple?

3. What is the difference between a list and a dictionary?

4. What is the difference between


>>>tp1= (10,12,14) >>>tp1=(10,12,14)
>>>tp1+(3) AND >>>tp1+(3,)

5. What is unpacking Tuples? Give an example.

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]

8. Consider the following dictionary stateCapital:


stateCapital = {"AndhraPradesh":"Hyderabad", “Bihar":"Patna","Maharashtra":"Mumbai",
"Rajasthan":"Jaipur"}
Find the output of the following statements:
i. print(stateCapital.get("Bihar"))
ii. print(stateCapital.keys())
iii. print(stateCapital.values())
iv. print(stateCapital.items())
v. print(len(stateCapital))
vi print("Maharashtra" in stateCapital)
vii. print(stateCapital.get("Assam"))
viii.del stateCapital["Rajasthan"]
ix. print(stateCapital)
1| 28 - 10 - 2 0 23 / P R E P A R E D B Y : MRS . ANILA BALAGOPAL | I C T D e p t .
9. Write a python program to create a dictionary called D1, that holds 4 elements. Each element is name of the
member and age. When age is entered find out the name of the member. If not found display error message.

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

2| 28 - 10 - 2 0 23 / P R E P A R E D B Y : MRS . ANILA BALAGOPAL | I C T D e p t .

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy