Write a Python program to:

ICSE Class 10 Robotics & AI PYQ · 2027 Specimen · Section B

4(iii)Written · 2027 · Section B · 2027 Specimen

Write a Python program to:

1. Create a string "Hardwork pays"

2. Print the characters from index 3 to 9

3. Convert the string str to upper case and store in str1

4. Check if the string ends with 'S'. Print a boolean value as the output.

5. Replace the word 'Hardwork' with 'Earnest work'

6. Print the new string

7. Join the word 'OFF' at the end of the string

Show SolutionHide Solution↓
str = "Hardwork pays"

print(str[3:10])

str1 = str.upper()
print(str1.endswith('S'))

str2 = str.replace('Hardwork', 'Earnest work')
print(str2)

str3 = ' '.join([str2, 'OFF'])
print(str3)
dwork p
True
Earnest work pays
Earnest work pays OFF

← Previous questionNext question →

Browse the free Robotics & AI sample bank