Home / CSE MCQs / Python MCQs :: Discussion

Discussion :: Python MCQs

  1. What is the output of the following piece of code?

    a=list((45,)*4)
    print((45)*4)
    print(a)
  2. A.

    180

    [(45),(45),(45),(45)].

    B.

    (45,45,45,45).

    [45,45,45,45].

    C.

    180

    [45,45,45,45].

    D.
    Syntax error

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    (45) is an int while (45,) is a tuple of one element. Thus when a tuple is multiplied, it created references of itself which is later converted to a list.


Be The First To Comment