Vidyalelo
Python · Q35

Python Built

Programming · Python · question 35

Q35

What is the output of the following code:my_list = [1, 2, 3]print(list(reversed(my_list)))

A.
[3, 2, 1]
Answer
B.
[1, 2, 3]
C.
['3', '2', '1']
D.
[1, 3, 2]

Answer: Option A

Solution

Answer: Option A
Solution:
The correct answer is Option A: [3, 2, 1].
The reversed() function in Python is used to reverse the elements of an iterable. When you pass the list [1, 2, 3] to the reversed() function and then convert the result to a list using list(), it returns a new list with the elements reversed, resulting in [3, 2, 1].