Friday, 10 April 2026
Lecture 8 of 73 · Unit 1
Unit 1 ⏳ Pending

String operations Theory

What We'll Learn

A quick overview of today's lecture

String operations Theory Concept ID: U1_STRING_OPS. Primary Sub-subtopic: String operations. Question-bank grouping: Revision of Python & Core Concepts. Use this lecture for theory, examples, misconceptions, and short concept checks mapped to this concept ID.
Key things we'll cover
String operations
PYQ references used by both prompts 28 included 0 excluded
Flagged questions are excluded from both Study Notes and PPT references until corrected in Paper Analyzer.
Included ID 6480 · 2021 · 1 mark(s)
Which of the following operator cannot be used with string data type? a) + b) in c) * d) /
Revision of Python & Core Concepts → String operations
Included ID 6512 · 2021 · 1 mark(s)
Find the output of the following code: Name="PythoN3.1" R="" for x in range(len(Name)): if Name[x].isupper(): R=R+Name[x].lower() elif Name[x].islower(): R=R+Name[x].upper() elif Name[x].isdigit(): R=R+Name[x-1] else: R=R+"#" print(R) a) pYTHOn##@ b) pYTHOnN#@ c) pYTHOn#@ d) pYTHOnN@#
Revision of Python & Core Concepts → String operations
Included ID 6531 · 2022 · 1 mark(s)
Select the correct output of the code: a = "Year 2022 at All the best" a = a.split('2') b = a[0] + ". " + a[1] + ". " + a[3] print(b) a) Year . 0. at All the best b) Year 0. at All the best c) Year . 022. at All the best d) Year . 0. at all the best
Revision of Python & Core Concepts → String operations
Included ID 6535 · 2022 · 1 mark(s)
Which of the following statement(s) would give an error after executing the following code? S="Welcome to class XII" # Statement 1 print(S) # Statement 2 S="Thank you" # Statement 3 S[0]= '@' # Statement 4 S=S+"Thank you" # Statement 5 a) Statement 3 b) Statement 4 c) Statement 5 d) Statement 4 and 5
Revision of Python & Core Concepts → String operations
Included ID 6091 · 2023 · 1 mark(s)
Select the correct output of the code : S= "Amrit Mahotsav @ 75" A=S.partition (" ") print (a) (a) ('Amrit Mahotsav','@','75') (b) ['Amrit', 'Mahotsav','@','75'] (c) ('Amrit', 'Mahotsav @ 75') (d) ('Amrit', '', 'Mahotsav @ 75')
Revision of Python & Core Concepts → String operations
Included ID 6288 · 2023 · 1 mark(s)
Select the correct output of the code : S="Amrit Mahotsav @ 75" A=S.split(" ",2) print (A) (a) ('Amrit', 'Mahotsav', '@', '75') (b) ['Amrit', 'Mahotsav', '@ 75'] (c) ('Amrit', 'Mahotsav', '@75') (d) ['Amrit', 'Mahotsav', '@', '75']
Revision of Python & Core Concepts → String operations
Included ID 6292 · 2023 · 1 mark(s)
Which of the following statement(s) would give an error after executing the following code ? S="Happy" # Statement 1 print (S*2) # Statement 2 S+="Independence" # Statement 3 S.append ("Day") # Statement 4 print (S) # Statement 5 (a) Statement 2 (b) Statement 3 (c) Statement 4 (d) Statement 3 and 4
Revision of Python & Core Concepts → String operations
Included ID 6572 · 2023 · 1 mark(s)
Select the correct output of the code: s = "Python is fun" l = s.split() s_new = "-".join([l[0].upper(), l[1], l[2].capitalize()]) print(s_new) a) PYTHON-IS-Fun b) PYTHON-is-Fun c) Python-is-fun d) PYTHON-Is -Fun
Revision of Python & Core Concepts → String operations
Included ID 6576 · 2023 · 1 mark(s)
Consider the statements given below and then choose the correct output from the given options: pride="#G20 Presidency" print(pride[-2:2:-2]) a) ndsr b) ceieP0 c) ceieP d) yndsr
Revision of Python & Core Concepts → String operations
Included ID 6598 · 2023 · 3 mark(s)
Predict the output of the Python code given below: Text1="IND-23" Text2="" I=0 while I<len(Text1): if Text1[I]>="0" and Text1[I]<="9": Val = int(Text1[I]) Val = Val + 1 Text2=Text2 + str(Val) elif Text1[I]>="A" and Text1[I]<="Z": Text2=Text2 + (Text1[I+1]) else: Text2=Text2 + "*" I+=1 print(Text2)
Revision of Python & Core Concepts → String operations
Included ID 6137 · 2024 · 1 mark(s)
What will be the output of the following code ? S='New Delhi' S=S.replace('e','*') print(S) (A) N*w D*lhi (B) New Delhi (C) N*w D*lhi (D) *ew D*lhi
Revision of Python & Core Concepts → String operations
Included ID 6142 · 2024 · 1 mark(s)
State True or False: The count() method of a string returns the number of occurrences of a substring in the string.
Revision of Python & Core Concepts → String operations
Included ID 6146 · 2024 · 1 mark(s)
State True or False: In Python, the upper() method returns the given string by converting all the lower case letters to upper case.
Revision of Python & Core Concepts → String operations
Included ID 6330 · 2024 · 1 mark(s)
Select the correct output of the code : S = "text#next" print(S.strip("t")) (A) ext#nex (B) ex#nex (C) text#nex (D) ext#next
Revision of Python & Core Concepts → String operations
Included ID 6334 · 2024 · 1 mark(s)
Consider the statements given below and then choose the correct output from the given options : Game="World Cup 2023" print(Game[-6::-1]) (A) CdrW (B) ce o (C) puC dlroW (D) Error
Revision of Python & Core Concepts → String operations
Included ID 6612 · 2024 · 1 mark(s)
Identify the output of the following code snippet: text = "PYTHONPROGRAM" text=text.replace('PY','#') print(text) a) #THONPROGRAM b) ##THON#ROGRAM c) #THON#ROGRAM d) #YTHON#ROGRAM
Revision of Python & Core Concepts → String operations
Included ID 6614 · 2024 · 1 mark(s)
What is the output of the expression? country='International' print(country.split("n")) a) ('I', 'ter', 'atio', 'al') b) ['I', 'ter', 'atio', 'al'] c) ['I', 'n', 'ter', 'n', 'atio', 'n', 'al'] d) Error
Revision of Python & Core Concepts → String operations
Included ID 6615 · 2024 · 1 mark(s)
What will be the output of the following code snippet? message= "World Peace" print(message[-2::-2])
Revision of Python & Core Concepts → String operations
Included ID 6356 · 2024 · 3 mark(s)
Predict the output of the Python code given below : s="India Growing" n = len(s) m="" for i in range (0, n) : if (s[i] >= 'a' and s[i] <= 'm') : m = m + s [i].upper() elif (s[i] >= 'O' and s[i] <= 'z') : m = m +s [i-1] elif (s[i].isupper()): m = m + s[i].lower() else: m = m + '@' print (m)
Revision of Python & Core Concepts → String operations
Included ID 6175 · 2025 · 1 mark(s)
Identify the correct output of the following code snippet: game="Olympic2024" print(game.index("C")) (A) 0 (B) 6 (C) -1 (D) ValueError
Revision of Python & Core Concepts → String operations
Included ID 6370 · 2025 · 1 mark(s)
Identify the output of the following code segment: s = "an apple. a toy." s=s.find('a',2) print(s) (A) 0 (B) 1 (C) 3 (D) 'a'
Revision of Python & Core Concepts → String operations
Included ID 6372 · 2025 · 1 mark(s)
What is the output of the following expression ? Sports="Paralympic Games" print (Sports.split("m")) (A) ['Paraly','m','pic Ga','m','es'] (B) ('Paraly','m','pic Games') (C) ('Paraly','pic Ga','es') (D) ['Paraly','pic Ga','es']
Revision of Python & Core Concepts → String operations
Included ID 6665 · 2025 · 1 mark(s)
What will be the output of the following Python code? str= "Soft Skills" print(str[-3::-3]) a) lSf b) Stkl c) StKi d) l
Revision of Python & Core Concepts → String operations
Included ID 6674 · 2025 · 1 mark(s)
What is the output of the given Python code? st='Waterskiing is thrilling!' print(st.split("i")) a) ['Watersk', 'ng ', 's thr', 'll', 'ng!'] b) ['Watersk', '', 'ng ', 's thr', 'll', 'ng!'] c) ['Watersk', 'i', 'ng ', 's thr', 'll', 'ng!'] d) Error
Revision of Python & Core Concepts → String operations
Included ID 6686 · 2025 · 2 mark(s)
B. Predict the output of the following Python code: text="Learn Python with fun and practice" print(text.partition("with")) print(text.count("a"))
Revision of Python & Core Concepts → String operations
Included ID 6697 · 2025 · 3 mark(s)
A. Predict the output of the following Python code: s1="SQP-25" s2="" i=0 while i<len(s1): if s1[i]>='0' and s1[i]<='9': Num=int(s1[i]) Num-=1 s2=s2+str(Num) elif s1[i]>='A' and s1[i]<='Z': s2=s2+s1[i+1] else: s2=s2+'^' i+=1 print(s2)
Revision of Python & Core Concepts → String operations
Included ID 6219 · 2026 · 1 mark(s)
Identify the output of the following code snippet : s = "the Truth" print(s.capitalize()) (A) The truth (B) THE TRUTH (C) The Truth (D) the Truth
Revision of Python & Core Concepts → String operations
Included ID 6222 · 2026 · 1 mark(s)
What will be the output of the following statement ? print("PythonProgram"[-1:2:-2])
Revision of Python & Core Concepts → String operations
.txt