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

PL - 2 XII Lists, Tuple and Dictionary

The document contains a practical list of Python programming tasks involving lists, tuples, and dictionaries. Each task requires writing code to perform specific operations such as calculating marks, manipulating lists, and creating dictionaries. The tasks range from basic list operations to more complex functions involving user input and data manipulation.

Uploaded by

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

PL - 2 XII Lists, Tuple and Dictionary

The document contains a practical list of Python programming tasks involving lists, tuples, and dictionaries. Each task requires writing code to perform specific operations such as calculating marks, manipulating lists, and creating dictionaries. The tasks range from basic list operations to more complex functions involving user input and data manipulation.

Uploaded by

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

PRACTICAL LIST – 2

Lists, Tuple and Dictionary


1 Write a Python code to accept Marks of English and Maths in two separate lists E and M for 5 students,
create another list as T to have the total marks as sum of corresponding marks of E and M, display the
following:
a. Content of E
b. Content of M
c. Content of T
d. Minimum marks of E, M and T
e. Maximum marks of E, M and T
f. Average marks of E, M and T
2 Write a Python code to perform the following:
a. To initialize a list A=[10,20,30,40]
b. To initialize a list B=[35,25,15,45]
c. To create a list C to get the content from A and B as [10,35,20,25,30,15,40,45]
d. To display content of C
3 Write a Python code with the following functions:
a. AddValues(L) - To add integer values entered by the user in the list L
b. DispValues(L) - To display values of L
c. RevContent(L) - To re-arrange content of L by reversing the order of values
d. AddEven(L) - To add all the even values of L and return the sum
e. AddOdd(L) - To add all the odd values of L and return the sum
f. AddZeroEnd(L) - To add all the values of L, which are ending with 0 and return the sum
g. Show7Ten(L) - To display those values of L, which have 7 at tens place
h. Show20_50(L) - To display those values of L, which are between 20 and 50.

Also, call the above function in the order as a, b, c, b, d, e, f, g and h


4 Write a Python code with the following functions:
a. AddValues(L) - To add integer values entered by the user in the list L
b. DispValues(L) - To display values of L
c. SwapPair(L) - To re-arrange the content of L by swapping each pair of adjacent neighboring values
d. SwapHalf(L) - To re-arrange content of L by swapping first half of the list with second half of the list

Also, call the above functions in the order as a, b, c, b, d and b.


5 Write a Python code with the following functions:
a. AddCity(C) - To add names of cities (as strings) entered by user in the list C
b. AllUcase(C) - To change the names of cities in uppercase in the list C
c. ShowDisp(C) - To display names of cities from list C
d. Arrange(C) - To arrange the names of cities from list C in alphabetical order (descending).
e. ShortNameCities(C) - To display the names of those cities from list C, which have 4 or less number of
characters
f. BigNameCities(C) - To display the names of those cities from list C, which have more than 4
characters
g. CityNameLength(C) - To display number of alphabets present in each name of the city in list C

Also, write menu driven options to call the above functions


6 Write a Python code to perform the following on a tuple T=(10,40,20,30,50,70)
a. To display the content of T in reverse order
b. To add and display the sum of values stored in T
c. To find and display minimum and maximum values present in T
d. To display sum of each adjacent pair of values
7 Write a Python code to perform the following:
a. To initialize a tuple WD containing (1,2,3,4,5,6,7)
b. To initialize a list WDN containing ['SUN','MON','TUE','WED','THU,'FRI','SAT']
c. To create a dictionary W with key-value pairs with corresponding values from WD and WDN
d. To display content of W
e. To re-arrange the content of dictionary in such a way that it becomes as follows:
{1:'MON',2:'TUE',3:'WED',4:'THU,5:'FRI',6:'SAT',7:'SUN'}
f. To display the content of W
g. To copy the partial content of W in dictionaries MyDays and OfficeDays, MyDays should have content
from keys 2,4 and 7 and rest from W to be the content of OfficeDays.
h. To display the contents of MyDays and OfficeDays

8 Write a Python code to perform the following operations:


a. To initialize a tuple TL=('RED','YELLOW','GREEN')
b. To accepts names of 10 colors from user and store them in a list CL
c. To display the color names from CL along with corresponding message "TRAFFIC LIGHT" and "NOT
TRAFFIC LIGHT" after checking from the content of TL
d. To initialize another tuple TM=('STOP','BE READY TO START/STOP','GO')
e. To create a dictionary TLM by combining corresponding key-value pairs from TL and TM.
f. To display the content of TLM

9 Create a list to store first N prime numbers in it and then display the list.

10 Write a python program to create a list L to store first N terms of Fibonacci series in it and then display the
list.

You might also like