Page 163 - Plus_V2.2_C8_Flipbook
P. 163
fun Zone
Let's soLve
Critical Thinking
1. Application based questions.
a. Abhimanyu wants to print his name in Python. He noticed that it got printed in lowercase.
How can he change it into uppercase?
b. Your friend Devansh created multiple strings in Python. He now wishes to join the strings to
form a single string. Is this possible? How can he do this?
2. Write the output of the following programs.
a. test_str = "Good Morning" b. def countX(lst, X):
print("The original string count = 0
is : " + str(test_str)) for ele in lst:
hlf_idx = len(test_str) if(ele==X):
res = ' ' count = count + 1
for idx in range(len(test_str)): return count
if idx >= hlf_idx: lst = [5.24, 89, 5, 14, 5]
res+= test_str[idx].upper() X = 5
else: print("{} has occurred {} times".
res+= test_str[idx].upper() format(X, countX(lst, X)))
print("The resultant string ________________________________
: " + str(res))
________________________________
Let's exPLore
Experiential Learning
Surf the Internet and explore about the String in Python.
teCh PraCtiCe Computational Thinking
Write a program to:
1. Write a program that counts the total number of digits in the number 542892 and displays
it as output.
2. Type your name in Python and make the first and the last letter of your name in uppercase
and let the other letters remain lowercase.
For The Teacher
Demonstration of creating functions to the students.
Explain String in detail to the students.
Functions and String in Python 161

