Programming in Python, Quiz 1
Consider the following code:
text = " >>> Hello, Python! <<< "
to_strip = " <>"
A = text.strip(to_strip)
B = text.lstrip(to_strip)
C = text.rstrip(to_strip)
D = text.strip()
print(A)
print(B)
print(C)
print(D)
Which of the following is the correct output?
Consider the following code:\ text = " \>\>\> Hello, Python! \<\<\< "\ to\_strip = " \<\>"\ A = text.strip(to\_strip)\ B = text.lstrip(to\_strip)\ C = text.rstrip(to\_strip)\ D = text.strip()\ print(A)\ print(B)\ print(C)\ print(D)\ Which of the following is the correct output? Consider a Python program that takes a sentence (which may contain both uppercase and lowercase letters, spaces, and punctuation) and prints the number of vowels present.\ **Snippet-1**\ sentence = input()\ count = 0\ vowels = set("aeiouAEIOU")\ **for** char **in** sentence:\ **if** char **in** vowels:\ count += 1\ print(count)\ **Snippet-2**\ sentence = input()\ count = 0\ **for** char **in** sentence.lower():\ **if** char **in** \['a', 'e', 'i', 'o', 'u'\]:\ count += 1\ print(count)\ Which of these two snippets is correct? What is the output of the following Python code?\ data = \["alpha", "beta", "gamma"\]\ data\[1\] = data\[1\].replace("e", data\[0\]\[1\])\ data\[2\] = data\[2\]\[::-1\].replace("a", data\[0\]\[3\])\ print(data)