Find the correct output of the following Python program segment: T=('1')…
2023
Find the correct output of the following Python program segment: T=('1') print(T*3)
- A.
3 / 3
- B.
('1','1','1') / ('1','1','1')
- C.
111 / 111
- D.
('3')
Attempted by 2041 students.
Show answer & explanation
Correct answer: C
Answer: 111
Explanation:
T is assigned the string '1'.
Multiplying a string by an integer repeats the string: '1' * 3 -> '111'.
print displays the resulting string without quotes, so the output shown is 111.
Notes: If T were the integer 1, print(T*3) would output 3. If T were a tuple like ('1',), multiplying it by 3 would produce ('1','1','1').