0% found this document useful (0 votes)
111 views3 pages

Python String and List Operations Quiz

Uploaded by

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

Python String and List Operations Quiz

Uploaded by

l4957852
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1. What will be the output of the following python statement?

s = "HOME ALONE"
p = [Link]("O")
print(p[1][:2]+p[-1])
a) ALNE b) MENE c) MEONE d) MEAL
2. What will be the output of the following python code?
s="finaLeXam"
print([Link]())
a) FinaL Exam b) FinalExam c) Finalexam d) Error
3. What is the output of print("hello".find('E'))?
a) 1 b) 2 c) -1 d) Error
4. [Link] will be the correct output of the following string operation?
"MALAYALAM".partition("MA")
a) ("MA","LAYAL", "AM") b) ("","MA","LAYALAM")
c) ("MA","LAYALA","AM") d) ("MALAYAL","AM","")
5. [Link] will be the output of the following python statement?
s = "MONGO"
print(sorted(s))
a) "GMNOO" b) ["GMNOO"] c) ["G","M","N","O","O"] d) Error
6. What will be the output of the following string operations:
s="Python is some good"
i) print([Link]('o',13,20)) Ans: 16
ii) print(s[2:4]+s[14]) Ans: th
7. [Link] will be the output of the following list operations?
data = [10,20,30,[40,50,60],[70,80]]
a) print(data[3]+data[-1]) Ans:[40,50,60,70,80]
b) print(data[-2][-2]) Ans:50
8. 20. What will be the output of the following python program:
data = [10,20,30, 60,70]
data[3:3]=[40,50]
print(data)
[Link](3)
print(data)
[Link]([10,20])
print(len(data))
9. Ganga is learning to use python Lists. Help her to get the answers of the following
operations based on the given list:
data = [10,20,30]
data[1:3]=[5,10]
print(data)
[Link]([3,4])
x =[Link](10)
print(data[x:])
[Link]()
print(data)
print([Link](2))
10. For the given list
d=[10,30,20,15,45,50,80,90]
what will be the output of the following slicing operation:
d[2:7:2]
a) [20,15,45] b) [20, 45, 80] c) [30, 15, 50] d) [20, 45]
11. What will be the output of the python code given below:
P = [20, 50]
Q = [5, 8]
[Link](Q)
print(P)
a) [20, 50, 5, 8] b) [20, 50, [5, 8]] c) [20, 50] d) [5, 8, 20, 50]
12. 24. Consider the following string declaration in python:
S = ‘PROCEDURE’
Which of the following statements will produce output as ‘RUDE’?
a) print(S[4:8]) b) print(S[-2:3:-1]) c) print(S[-2:-6]) d) print(S[7:-5:-1])
13. 25. Which of the following statement(s) will not create dictionary D?
a) D = {2:2, 'A':'A'} b) D = {(2,):(2,),('A'):('A')}
c) D = {[2]:[2], ['A']:['A']} d) D = {(2):[2], ('A'):['A']}
14. 26. Select the correct output of the code:
a = "Good bye 2022. Welcome 2023"
a = [Link]('0')
b = a[1] + ". " + a[0] + ". " + a[2]
print (b)
a) 22. Welcome 2. Good bye 2. 23
b) Good bye 2. 2322. Welcome 2.
c) 22. Welcome 2. 232. Good bye
d) 22. Good bye 2. 23 Welcome 2.
15. Select the correct output of the following python code:
str="My program is program for you"
t = [Link]("program")
print(t)
a) ('My ', 'program', ' is ', 'program', ' for you')
b) ('My ', 'program', ' is program for you')
c) ('My ', ' is program for you')
d) ('My ', ' is ', ' for you')
16. Select the correct output of the code:
a = "assistance"
a = [Link]('a')
b = a[0] + "-" + a[1] + "-" + a[2]
print (b)
a) -a-ssistance b) -a-ssist-nce c) a-ssist-nce d) -a-ssist-ance
17. 35. What will be the output of the following python statement?
L=[3,6,9,12]
L=L+15
print(L)
a)[3,6,9,12,15] b) [18,21,24,27] c) [5,3,6,9,12,15] d) error
18. 36.x="Annual Meet at the Campus"
x=[Link]('a')
y=x[0]+"."+x[1]+"."+x[2]+x[3]
print(y)
a) Annu.l Meet .t the Cmpus b) nnu.l Meet .t the Cmpus
c) Error d) Annu.l Meet .t the Campus
19. What will be the output of the following code?
msg="**BUSINESSCONFERENCE Held in 2024**"
print(msg[::-2])
a) **4202 nidlehH ECNEREFNOCSSENISUB**
b) *40 ide CEENCSNSB*
c) *BSNSCNEEC edi o4*
d) *UNSNRC e i 24
20. [Link] L = [2, 3, 4, 5, 6], what is the output of print(L[-2])?
a) 6 b) Error c) 5 d) 3
21. Predict the output of the following statement:
print(5 + 3**2 / 2)
a)32 b) 8.0 c) 9.5 d) 32.0
22. 47. Given s = "Wonders of World", what will be the output of:
print([Link]('o') + [Link]('o'))
a) 3 b) 4 c) 2 d) 1
23. [Link] L= [6,12,9,40,2,1], which of the following statements will arrange the list
in reverse order?
a) [Link]() b) [Link]()
c) [Link](reverse=True) d) [Link](reverse=False)
24. [Link] will be the output of the given code?
Lst = [45,100,20,30,50]
print(Lst[: :])
a) [45, 100, 20, 30, 50] b) [] c) Error d) [45]
25. .Write the output of the given code:
s1 = 'Hello'
s2 = 'World'
s = s1 + s2
print(s)
a) Hello World b) HelloWorld c) 'Hello''World' d) Error
26. [Link] will be the value of X in the followingPython expression?
X=2+9*((3*12)-8)/10
a)30.0 b)30.8 c)28.4 d)27.2
27. Whatwillbetheoutputofthefollowingcodesnippet?
message="HaiPython”
print(message[-2::-2])
a) iyhn b) oiyH c) otPiH d) oyi
28. Evaluate the following expression and identify the correct answer:
16 + 4 * (5 – 1) ** 2 / 4
a) 35 b) 35.0 c) 32 d)32.0

You might also like