What will be the output of below Python code?str1="Aplication"str2=str1.replace('a','A')print(str2)applicationApplicationApplicAtionapplicAtion
Question
What will be the output of below Python code?str1="Aplication"str2=str1.replace('a','A')print(str2)applicationApplicationApplicAtionapplicAtion
Solution
The output of the given Python code will be "AplicAtion".
Here's the step by step explanation:
- We have a string
str1with the value "Aplication". - The
replace()function in Python replaces the old substring with a new substring. In this case, it replaces 'a' with 'A'. - However, the
replace()function is case sensitive. So, it will only replace the lowercase 'a', not the uppercase 'A'. - In the string "Aplication", there is only one lowercase 'a'. So, the
replace()function will only replace this 'a' with 'A'. - Therefore,
str2will be "AplicAtion". - When we print
str2, it will output "AplicAtion".
Similar Questions
What will be the output of the following code?str1="HellO{}niNja"str1 = str1.replace(" {} ", " ")str1=str1.lower()pos=str1.find("o")print(str1+str(pos))
Subject: PythonWhat is the output of below python code?s = 'SIKANDAR's.replace('A','E')print(s)
t the correct answerWhat will be the output of the following Python code snippet?print('codetantra'.replace('ea', '90'))
What will be the output of the following Python code snippet?print('codetantra'.replace('ea', '90'))Optionscodetantracod9t0ntracod90tantracod9tantr0
2. What will be the output of the following Python code?>>>str="hello">>>str[:2]>>>
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.