Xii Wsheet
Xii Wsheet
Write a function countNow(PLACES) in Python, that takes the dictionary, PLACES as an argument
and displays the names (inuppercase)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 function, lenWords(STRING), that takes a string as an argument and returns 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 the Python statement for each of the following tasks using BUILT-IN
functions/methods only:
(i) To insert an element 200 at the third position, in the list L1.
(ii) To check whether a string named, message ends with a full stop
/ period or not.
4. Write a function in Python to read a text file, Alpha.txt and displays those lines which begin with
the word ‘You’.
5. Write a function, vowelCount() in Python that counts and displays the number of vowels in the
text file named Poem.txt.
1. Write a function countNow(PLACES) in Python, that takes the dictionary, PLACES as an argument
and displays the names (inuppercase)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 function, lenWords(STRING), that takes a string as an argument and returns 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 the Python statement for each of the following tasks using BUILT-IN
functions/methods only:
(i) To insert an element 200 at the third position, in the list L1.
(ii) To check whether a string named, message ends with a full stop
/ period or not.
4. Write a function in Python to read a text file, Alpha.txt and displays those lines which begin with
the word ‘You’.
5. Write a function, vowelCount() in Python that counts and displays the number of vowels in the
text file named Poem.txt.
Answers
1.
2.
(i) L1.insert(2,200)
(ii) message.endswith('.')