Write a Python program that performs the following operations on a string:

ICSE Class 10 Robotics & AI PYQ · 2026 Paper · Section B

8(iii)Written · 2026 · Section B · 2026 Paper · 🔁 also 2025

Write a Python program that performs the following operations on a string:

Show SolutionHide Solution↓
s = "Machine Learning"

lower_s = s.lower()
print("Lowercase string:", lower_s)

replaced_s = s.replace("Machine", "Deep")
print("After replacement:", replaced_s)

ends = s.endswith("Learning")
print("Ends with 'Learning':", ends)

count_n = s.count('n')
print("Number of occurrences of 'n':", count_n)
Lowercase string: machine learning
After replacement: Deep Learning
Ends with 'Learning': True
Number of occurrences of 'n': 3
← Previous question

Browse the free Robotics & AI sample bank