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)
application
Application
ApplicAtion
applicAtion
Solution
The output of the given Python code will be "AplicAtion".
Here's the step by step explanation:
- We have a string
str1
with 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,
str2
will be "AplicAtion". - When we print
str2
, it will output "AplicAtion".
Similar Questions
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'))
2. What will be the output of the following Python code?>>>str="hello">>>str[:2]>>>
What will be the output of the following Python code snippet?print('codetantra'.replace('ea', '90'))Optionscod9t0ntracod90tantracod9tantr0codetantra
What is the output when following code is executed ?>>> str1 = 'hello'>>> str2 = ','>>> str3 = 'world'>>> str1[-1:]
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.