Grade 12 - CS - Holiday Assignment
Grade 12 - CS - Holiday Assignment
HOLIDAY ASSIGNMENT
-----------------------------------------------------------------------------------------------------------------------------------
1. Write a program in Python, that takes the dictionary, PLACES as an input and displays
the names (in uppercase) of the places whose names are longer than 5 characters.
For example, Consider the following dictionary
PLACES={1:"Delhi",2:"London",3:"Paris",4:"New York",5:"Doha"}
The output should be: LONDON NEW YORK
2. Write a program in python that takes a string as an input and provides the output in a
tuple containing length of each word of a string.
For example, if the string is "Come let us have some fun",
the tuple will have (4, 3, 2, 4, 4, 3)
3. Write a program in Python, which accepts a list L of numbers as input. Thereafter, it
increments all even numbers by 1 and decrements all odd numbers by 1.
Example : If Sample Input data of the list is : L=[10,20,30,40,35,55]
Output will be : L=[11,21,31,41,34,54]
4. Write a program in Python, which accepts a list L of integers as inputs and displays the
sum of all such integers from the list L which end with the digit 3.
For example, if the list L is passed [ 123, 10, 13, 15, 23]
Then the function should display the sum of 123, 13, 23 i.e. 159 as follows:
Sum of integers ending with digit 3 = 159
5. Write a program in Python, which accepts a list num of numbers as input and will
interchange every alternate value.
E.g If the list num contain: [11, 21, 31, 41, 51, 61]
Output: [21, 11, 41, 31, 61, 51]
6. Write a program to input a Message and count the number of words beginning with
„A‟ or „a‟.
E.g If the String is : “We are from Silver Shine School and I am in 12th Class ”
Output, 3
7. Write a program to input a Message and count and display the number of capital and
small letters in each word.
E.g If the String is : “SiLver ShinE ScHOOl”
Output, Words Small Cap
SiLver 4 1
ShinE 3 2
ScHOOl 2 4
8. Write a program to replace all prime numbers by 0 in list items.
E.g If the list num contain: [2,4,7,6,9,10,14,15,13]
Output: [2,4,0,6,9,10,14,15,0]
9. Write a program to print the key of the minimum value of a dictionary.
Example:
d={4: „berry‟, 2: „mango‟ 3: „apple‟}
o/p key = 3
10. Write a program to input a dictionary which stores the fruit code as the key and and
fruit names as the values. Also display the name of the fruits in upper case if it has the
substring „apple‟ in it.
For example:
Fruits : {10: “Apple”, 45: “Grapes”, 23: “Orange”, 78: “Pine Apple”}
The output must be: APPLE , PINE APPLE
11. Write a program in python which accepts string as an input and provides the output as
a dictionary which contains the „digits‟ and „alphabets‟ as the key and the number of
occurrences of the digits and alphabets as the values.
For example if the string is : “Hi Hello 123”
The output dictionary must be : {„digits‟ : 3, „alphabets‟: 7}
12. Write a program in Python to display the elements in reverse order such that each
displayed element is twice of the original element (element *2) of the List X and store
in it in a new tuple T.
For example, if List X contains 7 integers as follows:
X=[4,8,7,5,6,2,10]
The output must be :
T=(20,4,12,10,14,16,8)
13. Find the output:
18. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
Value=30
for VAL in range(0,Value)
if val%4=0:
print (VAL*4)
elseif val%5==0:
Print (VAL+3)
else:
print(VAL+10)
19. Rewrite the following code in python after removing all syntax error(s). Underline
each correction done in the code.
10=A
for S in range (0, A)
if S%2=0:
print (S*2)
Else:
print (S+3)
20. The code given below accepts a number as an argument and returns the reverse
number. Observe the following code carefully and rewrite it after removing all syntax
and logical errors. Underline all the corrections made.