(a) Error (b) -1 (c) 1 (d) 0
Grade: XI Subject: CS 8. What is the output of the following code ?
Chapter 10 – String Manipulation example=”helloworld”
example[::-1].startswith(“d”)
1. Output of the given code will be:
str="computer" (a) dlrowolleh (b) True (c) -1 (d) None
print(str[2:3])
9. What will be the output of the following code?
2. What is the output of the following? print('RachnaSagar'.split('na')) Msg=”CompuTer”
Msg1=”
3. What will be the output? for i in range(0, len(Msg)):
Test=”hello world” if Msg[i].isupper():
Test[6]=’t’ Msg1=Msg1+Msg[i].lower()
print(Test) elif i%2==0:
Msg1=Msg1+’*’
4. The__________ function returns the exact copy of the string with the else:
first letter in uppercase Msg1=Msg1+Msg[i].upper()
(a) find() (b) copy() print(Msg1)
(c) upper() (d) capitalize()
(a) cO*P*t*R (b) Co*p*t*R
5. What will be printed when the following executes? (c) co*p*t*r (d) cOP*tR
str = "This is fun"
str = str[5] 10. What is “Hello”.replace(“l”, “e”)?
print(str) (a) Heeeo (b) Heelo
A.i B. ' ' C. is fun D. This is fun (c) Heleo (d) None
6. What will be the output of the following programming code? 11. What is the output of the following?
x=”AmaZing” print(‘ab,12’.isalnum())
print(x[3:],”and”,x[:2]) (a) True (b) False (c) None (d) Error
(a) Amazing and ZI (b) aZing and Zin
(c) Zing and Am (d) Azing and zin 12. What is the output of the following?
print(‘ab cd ef’.title())
7. What is the output of the following code? (a) Ab cd ef (b) Ab cd eF
example = “helle” (c) Ab Cd Ef (d) None of the mentioned
[Link](“e”)
13. What is the output of the following? 21. Which function should I use to convert String "welcome to the
print(‘Ab!2’.swapcase()) beautiful world of python" to "Welcome To The Beautiful World Of
Python"
(a) AB!@ (b) ab12
(c) aB!2 (d) aB1@ 22. What is printed by the following statements?
s = "ball"
14. r = ""
myTuple = (“Joe”, “Peter”, “Vicky”) for item in s:
x = “#”.join(myTuple) r = [Link]() + r
print(x) will produce output print(r)
(a) Joe#Peter#Vicky (b) #JoePeterVicky a. Ball b. BALL c. LLAB d. TypeError
(c) JoePeterVicky (d) JohnPete#Vicky#
23. What will be printed when the following executes?
15. What is the output of the following? str = "His shirt is red"
print(‘abcdefcdghcd’.split(‘cd’)) pos = [Link]("is")
(a) [‘ab’, ‘ef’, ‘gh’] (b) [‘ab’, ‘ef’, ‘gh’, ”] print(pos)
(c) (‘ab’, ‘ef’, ‘gh’) (d) (‘ab’, ‘ef’, ‘gh’, ”) a. 1 b. 9 c. 2 d. pos
16. What is the output of the following? 24. Which of the following will give "Simon" as output?
print(‘a@ 1,’.islower()) If str1="John,Simon,Aryan"
(a) True (b) False (c) None (d) Error a. print(str1[-7:-12])
b. print(str1[-11:-7])
17. What is the output of the following? c. print(str1[-11:-6])
print(“abcdef”.find(“cd”) == “cd” in “abcdef”) d. print(str1[-7:-11])
(a) True (b) False
(c) Error (d) None of the mentioned 25. What will the below Python code will return?
list1=[0,2,5,1]
18. When you write S[-5] for a five letter word, python will return str1="7"
for i in list1:
a) S[0] b) S[1] c) S[5] d) S[-5] str1=str1+i
19. To print first 4 letters from the string, which of the option(s) is/are print(str1)
correct?
a. 70251 b. 7 c. 15 d. Error
a) s[:3] b) s[0:4] c) s[:4] d) s[0:3]
20. Which of the following is not a correct string operation in python?
a) ‘Tut’ + ‘or’ b) ‘Tutor’ * 2 c) ‘Tutor’ + 2 d) 2 * ‘Tutor’