KnowledgeBoat Logo

Computer Science

Write the output of the following:

s = "Strings in Python"
print(s.capitalize())
print(s.title())
s6 = s.replace("in", "data type")
print(s6)

Python

Python String Manipulation

1 Like

Answer

Strings in python
Strings In Python
Strdata typegs data type Python

Working

The s.capitalize() method capitalizes the first letter of the string and converts the rest to lowercase, resulting in "Strings in python". The s.title() method capitalizes the first letter of each word, producing "Strings In Python". The s.replace("in", "data type") method replaces occurrences of "in" with "data type", giving "Strdata typegs data type Python" as output.

Answered By

3 Likes


Related Questions