Open In App

Python-Quizzes | Python List Quiz | Question 25

Find the output of the following program: 




def REVERSE(L):
    L.reverse()
    return(L)
def YKNJS(L):
    List = []
    List.extend(REVERSE(L))
    print(List)
 
L = [1, 3.1, 5.31, 7.531]
YKNJS(L)

(A)



[1, 3.1, 5.31, 7.531]

(B)



[7.531, 5.31, 3.1, 1]

(C)

IndexError

(D)

AttributeError: ‘NoneType’ object has no attribute ‘REVERSE’

Answer: (B)
Explanation:

REVERSE() reverses the list and returns it. YKNJS() adds reverse of a list L to the empty list List. L = [1, 3.1, 5.31, 7.531], gets reversed and becomes [7.531, 5.31, 3.1, 1].

Quiz of this Question
Please comment below if you find anything wrong in the above post

Article Tags :