Computer Sci Class 12 Holiday Homework
Computer Sci Class 12 Holiday Homework
CLASS: XII
Holiday Homework –Autumn Break
Identify the formal and actual parameters in the above code snippet. Define formal and
actual parameters in a function.
and
c = 10
def add():
global c
c=c+2
print("Inside add():", c)
add()
c=15
print("In main:", c)
output:
Inside add() : 12
In main: 15
Consider the above program and justify the output. What is the output if “global c “ is
not written in the function add().
6) Write a Python program to sum all the items in a list.
7) Write a Python program to get the largest number from a list.
8) Write a Python program to count the number of strings where the string length is 2 or
more and the first and last character are same from a given list of strings.
Sample List : ['abc', 'xyz', 'aba', '1221']
9) Write a Python program to remove duplicates from a list.
10) Write a Python program to generate and print a list of first and last 5 elements where
the values are square of numbers between 1 and 30 (both included).
11) Write a Python program to get a string from a given string where all occurrences of its
first char have been changed to '$', except the first char itself.
Sample String : 'restart'
Expected Result : 'resta$t'
12) A blood bank maintains data file “Blood.dat” that contains following information for
every donor: donor name, donor date of birth, donor address, donor phone number and
donor blood group. Write a complete program to do the following:
a) Create a file of the donor
b) Append a record in the file
c) Display the records
d) Given the blood group display name, address of the donor
e) Modify the existing information of the donor
13) Write an interactive menu driven program with the following four functions:
a) To create a text file called “Nation.txt”
b) Display the file
c) Append relevant content to the file
d) Make a copy of the file
e) Count the total number of “the” in the file
14) Create a binary file with name and roll number. search for a given roll number and
display the
name, if not found display appropriate message.
15) Write a program with a user -defined function with string as a parameter which replaces
all vowels in the string with ‘*’.
16) WAP to store students’ details like admission number, roll no, name and percentage in
a dictionary and display information on the basic of admission number.
*******