0% found this document useful (0 votes)
57 views5 pages

String MCQ Test

The document consists of a series of multiple-choice questions (MCQs) related to Python programming, covering topics such as string manipulation, operators, and code output predictions. Each question provides options for answers, and some require true or false responses. The questions are designed to test knowledge of Python syntax and behavior.

Uploaded by

svvsuganyacbse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views5 pages

String MCQ Test

The document consists of a series of multiple-choice questions (MCQs) related to Python programming, covering topics such as string manipulation, operators, and code output predictions. Each question provides options for answers, and some require true or false responses. The questions are designed to test knowledge of Python syntax and behavior.

Uploaded by

svvsuganyacbse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

String MCQ test.

1. Select the correct output of the code:


Str=“Computer” S
tr=Str[-4:]
print(Str*2)

a. uter b. uterretu c. uteruter d. None of these


2. What will the following expression be evaluated to in Python? 10*1*2**4-4//4
3. Find output generated by the following code:
mystr = “Hello I am a Human.”
print(mystr[::-3])
4. State True or False
“The characters of string will have two-way indexing.”
5. Select the correct output of the following code :
s=“I#N#F#O#R#M#A#T#I#C#S”
L=list(s.split(‘#’,3))
print(L)

a) [I#N#F#O#R#M#A#T#I#C#S] b) [‘I’, ‘N’, F#O#R#M#A#T#I#C#S]]


c) [‘I N F O R M A T I C S’] d) [‘I’,’N’,’F’, O#R#M#A#T#I#C#S’]
6. Which of the following statement(s) would give an error after executing the following code?
str= “Python Programming” #statement 1
x= ‘2’ #statement 2
print(str*2) #statement 3
print(str*x) #statement 4

a) statement 1 b) statement 2 c) statement 3 d) statement 4


7. Which of the following is a mutable datatype in Python?
(a) String (b) List (c)Integer (d) Tuple
8. Consider the given expression:
not False or False and True

Which of the following will be correct output if the given expression is evaluated?

(a) True b)False c)NONE d) NULL

9. Predict the output of the following code :


Str = "KENDRIYA VIDYALAYA SANGATHAN JAMMU REGION"
Str = Str.split()
NewStr = Str[0] + "#" + Str[1] + "#" + Str[4]
print (NewStr)
10. Which of the following statement(s) would give an error after executing the following code?
P ="FIRST PRE BOARD" # Statement 1
print(P) # Statement 2
P = P[1:7] + "Questions" # Statement 3
P[0] = '&' # Statement 4
P =P + "Over" # Statement 5
(a) Statement 3 b) Statement 4 (c) Statement 5 d) Statement 4 and 5
11. What is the output of the following?
print('KV Sangathan'.split('an'))

(a) ['KV S', 'gath', ' '] (b) [‘KV Sangathan’,’an’]

(c) [‘KV’,’Sang’,’athan’] (d) All of them

12. What will be the output of the following code?


name="Kendriya Vidyalaya Sangathan"
print(name[10:19])
13. Evaluate the following expressions:
65 > 55 or not 8 < 5 and 0 != 55
14. State True or False
“variable declaration is implicit in Python”
15. What is the output of the following code.
Str1=”Hello World”
Str1.replace('o','*',1)

(a) Hell* World (b) Hell* W*rld (c) Hello W*rld (d) Error
16. STRING=“WELCOME” Line1
NOTE= “ ” Line2
for S in range[0,8]: Line3
print(STRING[S]) Line4
print(S STRING) Line5

Which statement is wrong in above code:


a) Line3 and Line4 b) Line4 and Line5
c) Line2 and Line3 d) Line3 and Line5
17. Select the correct output of the code:
mystr = ‘Python programming is fun!’
mystr = mystr.partition(‘pro’)
mystr=’$’.join(mystr)
(a) Python $programming is fun! (b) Python $pro$gramming is fun!
(c) Python$ pro$ gramming is fun!$ (d) P$ython $p$ro$gramming is $fun!
18. State weather True or False:
“ The expression 2**2**3 is evaluated as (2**2)**3.
19. Consider the given Python string declaration:
mystring = ‘Programming is Fun’
Write the output of:
print(mystring[-50:10:2].swapcase())

20.If the following code is executed, what will be the output of the following
code?

mystr1 = ‘Sequence with labels’


mystr2 = ‘$’
print(mystr2*6+mystr1+mystr2*5)
21.State True or False The value of the expression 5/(6*(4-2)) and 5/6*(4-2) is the same.
22.Which function is used to remove the given characters from trailing end i.e. right end
of a string?
(a) strip( ) (b) remove( ) (c) lstrip( ) (d)
rstrip( )
23.Write the output after evaluating he following expressions:
m= (8>9 and 12>3 or not 6>8)
print(m)
24.Which of the following is the output of the following python code?
str1="TamilNadu"
print(str1[::-1])
(a) Tamilnadu (b) Tmlau (c) udanlimaT d) udaNlimaT
25.What will be the output of the following code? str1 = "Chennai Schools" str1[7] = "-"
(a) Chennai-Schools (b) Chenna-School
(c) Type error (d) Chennai
26. What will be the output of the following Python code? 31 What will be the output of the
. following Python code?
>>> str1 = 'hello'
>>> str2 = ',' >>>str1="helloworld"
>>> str3 = 'world' >>>str1[::-1]
>>> str1[-1:]
a) olleh b) hello c) h d) o

27. What arithmetic operators cannot be used with 32 What will be the output of the
strings? . following Python code?
a) + b) * c) – d) All of the mentioned
>>>example = "snow world"
>>>print("%s" % example[4:7])
a) wo b) world c) sn d) rl

28. What will be the output of the following Python code? 33 What will be the output of the
. following Python code?
>>>max("what are you")
>>>example = "helle"
>>>example.find("e")

29. What will be the output of the following Python code? 34 What will be the output of the
. “hello” +1+2+3?
a) hello123 b) hello c) Error d)
>>>example="helloworld" hello6
>>>example[::-1].startswith("d")
30. What is “Hello”.replace(“l”, “e”)? 35 What will be the output of the
a) Heeeo b) Heelo c) Heleo d) None . following Python code?
print("abc DEF".capitalize())
a) abc def
b) ABC DEF
c) Abc def
d) Abc Def

2 marks
1. Write the output of the following code

2. Predict the output of the following code:

3. Predict the output of the following code:

4. Predict the output of the following code:


5. What will be the output of the following string operation?
str="PYTHON@LANGUAGE"
print(str[2:12:2])
6. Predict the output of the python code given below:
st= "python programming"
count=4
while True:
if st=="p":
st=st[2:]
elif st[-2]=="n":
st =st[:4]
else:
count+=1
break
print(st)
print(count)

You might also like