Class XII
Computer Science
Practical File (Part A)
1. Write a function in Python Convert() to replace elements having even values with its
half and elements having odd values with twice its value in a list. (Hints: if the list
contains 3,4,5,16,9 then rearrange the list as 6,2,10,8,18)
2. Write a function distinction(marks) in Python, that takes the dictionary marks as an
argument and displays the subjects (in upper case) for which marks are greater than
or equal to 75. For example, consider the following dictionary marks = {‘eng’:78,
‘phy’:69, ‘chem’:74, ‘math’:75, ‘cs’:84} The output should be: ENG MATH CS.
3. Write a function EVEN_LIST(L), where L is the list of elements passed as argument
to the function. The function returns another list named ‘even list’ that stores only
even numbers in the list. For example: If L contains [1,2,3,4,5,6,7,8] The even list
will have - [2,4,6,8]
4. Write a function count_city(CITY) in Python, that takes the dictionary, CITY as an
argument and displays the names (in uppercase) of the cities whose names are
smaller than 6 characters. For example, Consider the following dictionary CITY =
{1:"Ahmedabad", 2:"Pune", 3:"Baroda", "Simla", 5:"Surat"} The output should be:
PUNE SIMLA SURAT
5. Write a function in Shift(Lst), Which accept a List ‘Lst’ as argument and swaps the
elements of every even location with its odd location and store in different list eg. if
the array initially contains 2, 4, 1, 6, 5, 7, 9, 2, 3, 10 then it should contain 4, 2, 6, 1,
7, 5, 2, 9, 10, 3
6. Write a function, VowelWords(Str), that takes a string as an argument and returns a
tuple containing each word which starts with an vowel from the given string For
example, if the string is "An apple a day keeps the doctor away”, the tuple will have
(“An”,”apple”,”a”, “away”)
7. Write a function countEU() in Python, which should read each character of a text file.
IMP.TXT should count and display the occurrence of alphabets E and U (including small
cases e and u too).
8. Write a python program to create and read the city.txt file in one go and print the contents
on the output screen.
9. Write a function VowelCount() in Python, which should read each character of a text file
Story.txt, should count and display the occurrence of alphabet vowels.