Home / CSE MCQs / Python MCQs :: Discussion

Discussion :: Python MCQs

  1. What is the output of the following?

    print('abcd'.translate({'a': '1', 'b': '2', 'c': '3', 'd': '4'}))
  2. A.
    abcd
    B.
    1234
    C.
    error
    D.
    none of the mentioned

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    The function translate expects a dictionary of integers. Use maketrans() instead of doing the above.


Be The First To Comment