Page 1 - Home Assignment - STRINGS
P. 1
Home Assignment
Computer Science
Class – XI
Topic: STRINGS
1. Specify why the following code is incorrect as per Python syntax:
Result = 'PROGRAM' * '@'
2. Identify which of the following are valid strings in Python:
i) "CORRECT" ii) "CORRECT' iii) 'correct' iv) {correct}
3. Carefully observe the code and write the output of the code:
a="Python"
a = '#' + a + '#'
a = 2*a
print(a)
a) 2Python b) #Python#
c) error d) #Python##Python#
4. What is the output when following statement is executed ?
>>>"abcdefgh"[-6:-2]
a) bcde b) cdef c) defg d) None of above
5. What is the output when following code will be executed ?
a) print(sorted("pqabxy09", reverse=True)
b) 'computer SCIENCE'.capitalize()
c) 'computer SCIENCE'.title()
d) 'PYTHON program'.islower()
e) 'PYTHON program'.upper()
f) 'split() is a string function'.split()
g) 'ababcabcd'.find('bc')
h) 'ab abc abcd'.count('bc')
i) '$'.join('PROGRAM')
j) 'hello world'.replace('o', 'oo')
k) 'This is my book'.partition('is')