0% found this document useful (0 votes)
55 views

Class Test-Strings

The document contains 9 multiple choice and coding questions related to strings in Python. The questions cover string functions like ord(), string slicing and indexing, string manipulation operations like replacement and counting characters. Solutions to the questions would demonstrate knowledge of built-in string methods and how to perform common string processing tasks in Python.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Class Test-Strings

The document contains 9 multiple choice and coding questions related to strings in Python. The questions cover string functions like ord(), string slicing and indexing, string manipulation operations like replacement and counting characters. Solutions to the questions would demonstrate knowledge of built-in string methods and how to perform common string processing tasks in Python.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

COMPUTER SCIENCE

CLASS :XI CLASS TEST -STRINGS

1. Which of the following functions accepts only integers as arguments?


a) ord() b) min() c) chr() d) any()
2. What is the output of the functions shown below? ord(65) ord(‘A’)
a) A and 65 b) Error and 65 c) A and Error d) Error and Error
3. What is the output of the following string operation?
str "My roll no. is 12" print(str.isalnum())
(a) True (b) False (c) Error (d) No Output
4. Which of the following functions will return the always a tuple of 3 elements ?
(a) find (b) index() (c) partition() (d) split()
5. Select the correct output of the following String operations
Str1='Waha'
print(str1[:3] + 'Bhyi'+str1[-3:])
(a) Wah Bhyi Wah b) Wah Bhyi aha (c) WahBhyiWah (d) WahBhyiaha

6. Find the output

str="PROGRAMM"

for i in range(len(str)):

print(str[i:len(str)-i%2])

7.
s="Cbse Exam 2019-2020"
l=['a','e','i','o','u','A','E','I','O','U']
print(s)
r=""
x=0
while x <len(s):
i=s[x]
p=s.find(i)
if i in l:
r+=str(l[p: ])
elif i.isdigit():
r+=str(l[0])
else:
r=r+i
x+=1
print(r)
8. Consider the string s1=”Global Warning”.
Write statements in python to implement the following:
(a) To replace the first occurrences of letter ‘a’ in the string with “*” .
(b) To display the starting index for the substring ‘vo’.
(c) To remove ‘Gre’ from the left of the string.
(d) Write the script and output to return the string as list using separator ‘a’ and join
them into one string using separator ‘a’
(e) Write the script and output replicate the string with 3 times and count the no of
characters in the replicated string using count()
(f) Write the script to return the index of character ‘W ‘ by specifying start, end(display
the output using two methods)
9. Given the following code, write down the output?

a=3
b=1
for I in range(a):
for j in range (b):
Print (“hello”*i+”oswal”*j)

You might also like