0% found this document useful (0 votes)
4 views18 pages

Program

The document contains a series of programming tasks in Python, each requiring the implementation of specific functions and operations on lists, tuples, and dictionaries. Each program has distinct requirements, such as calculating totals, displaying values, rearranging content, and filtering data based on conditions. The tasks are designed to enhance understanding of Python data structures and basic programming concepts.

Uploaded by

aabidmusmani66
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)
4 views18 pages

Program

The document contains a series of programming tasks in Python, each requiring the implementation of specific functions and operations on lists, tuples, and dictionaries. Each program has distinct requirements, such as calculating totals, displaying values, rearranging content, and filtering data based on conditions. The tasks are designed to enhance understanding of Python data structures and basic programming concepts.

Uploaded by

aabidmusmani66
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

Program-1

Q1. 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 (without using Built in Functions/methods):
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

Input:
Output:
Program-2
Q2. 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

Input:

Output:
Program-3
Q3. Write a Python code with the following functions:
a. Add Values(L) - To add integer values entered by the user in the list L
b. Disp Values(L) - To display values of L
c. Rev Content(L) - To re-arrange content of L by reversing the order of values
d. Add Even(L) - To add all the even values of L and display the sum
e. Add Odd(L) - To add all the odd values of L and display the sum
f. Add ZeroEnd(L) - To add all the values of L, which are ending with 0 and display 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 [Link], call the above function in the order as a, b, c, b, d, e, f, g
and h

Input:
Output:
Program-4
Q4. 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
neighbouringvalues
d. SwapHalf(L) - To re-arrange content of L by swapping first half of the list with
second half
of thelist
Also, call the above functions in the order as a, b, c, b, d and b.

Input:
Output:
Program-5
Q5. Write a Python code with the following functions:
a. Add City(C) - To add names of cities (as strings) entered by user in the list C
b. All Ucase(C) - To change the names of cities in uppercase in the list C
c. Show Disp(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. Short Name Cities(C) - To display the names of those cities from list C, which have 4
or less
numberof characters
f. Big Name Cities(C) - To display the names of those cities from list C, which have
more than 4characters
g. City Name Length(C) - To display number of alphabets present in each name of the
city
in list CAlso, call the above functions in the order as a, c, b, c, d, c, e, f and g

Input:
Output:
Program-6
Q6. Write a Python code with the following functions:
a. Add Books(B) - To add titles of books (as strings) entered by user in the list B
b. All India(B) - To find and display titles of all the books, which contain "INDIA" or
"India" as part of its title.
c. Show Books(B) - To display titles of books from list B
d. Single Words(B) - To display the uppercase equivalent of single word titles of books
from list
B.
e. Count Single(B) - To display the number of books from the list B which contain only
a
single wordin its title.
f. ThetoA(B) - To change the presence of the word “The” to “A” in the titles of the list
[Link], call the above functions in the order as a, c, b, d, e and f

Input:

Output:
Program-7
Q7. 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
e. To find those pair (any pair 1st-2nd, 1st-5th, 3rd-6th,...) of values from the content
of T,whose sum is same as one of the values in T

Input:

Output:
Program-8
Q8. 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 My Days and Office Days, My Days
should havecontent from keys 2,4 and 7 and rest from W to be the content of Office
Days.
h. To display the contents of My Days and Office Days

Input:
Output:
Program-9
Q9. 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

Input:
Output:

You might also like