Professional Documents
Culture Documents
XICSWinterbreak HW
XICSWinterbreak HW
CLASS XI CS
Winter Break Homework
String
Q.1 Write a python script that traverses through an input string and prints its characters in
different lines – two characters per line
Q. 2 Suggest appropriate functions for the following tasks –
(a) To check whether the string contains digits.
(b) To find the occurrence a string within another string.
(c) To convert the first letter of a string to upper case.
(d) To convert all the letters of a string to upper case.
(e) To check whether all the letters of the string are in capital letters.
(f) to remove all the white spaces from the beginning of a string.
Q. 3 Find the output – if we give input as “Hello”
Q. 6 Write a program that takes a string with multiple words and capitalizes the first letter of
each word and
forms a new string out of it.
LIST
Q.1 How are lists different from strings when both are sequences?
Q. 2 Predict the output
–
Tuples
Q. 1 Find out the output generated by following code fragments:
(a) plane = (“Passengers”, ”Luggage”)
plane [1] = “Snakes”
(b) (a, b, c) = (1,2,3)
(c) (a, b, c, d) = (1,2,3)
(d) a, b, c, d = (1,2,3)
(e) a, b, c, d, e = (p, q, r, s, t) = t1
(f) T1=(1,)*3
T1[0]=2
Print(T1)
(g) TupleA=’m’,’n’
TupleB=(‘m’,’n’)
Print(TupleA==TupleB)
Q. 2 WAP that creates a tuple storing first 9 items of Fibonacci Series.
Q.3 What are the two ways to add something to a list ? How are they different from tuple?
Dictionary
Q.1 . Dictionary is a mutable type, which means you can modify its contents ? What all is
modifiable in a dictionary ? Can you modify the keys of a dictionary ?
2. Vidyarthi Gurukul conducts physical training camps for the physical well being of its
students. This camp is held for one week on the outskirts of the city. The entire group of
students are represented as a list. The list stores the roll numbers of the participants for
camp activities. As part of this training, the entire stream of students are divided into two
halves. When the first group of students goes for physical training, the other half goes for
aerobics classes and in the later half these groups are swapped.
Write a Python program that maintain and display details about the swapping of activity
classes and award them stars on completion of each activity.
Write a program in Python that repeatedly asks the user to enter product names and
prices. Store all of them in a dictionary whose keys are product names and values are
prices. Also write a code to search an item from the dictionary.
4. The above shopping destination for groceries, Rajmandir, stores phone numbers of its
customers. Phone numbers are to be stored in the form of a dictionary. Write a Python
program to input ‘n’ names and phone numbers to store them in a dictionary and to input
any name and to print phone number of that particular customer.