2(x)
What will be the output of the following Python code?
s = "Great Day"
print(s.count('a'))
print(s.startswith('g'))Show SolutionHide Solution↓
2
False
In the string "Great Day":
The statement
s.count('a')counts the number of occurrences of lowercase'a'in the string. It appears 2 times, hence the output is 2.The statement
s.startswith('g')checks whether the string starts with lowercase'g'. Since the string starts with uppercase'G', it returns False as Python is case-sensitive.
Hence, the output is:
2
False