Home / CSE MCQs / Python MCQs :: Python Strings

CSE MCQs :: Python MCQs

  1. What is the output when following code is executed ?

    print r"\nhello"
    The output is
  2. A.
    a new line and hello
    B.
    \nhello
    C.
    the letter r and then hello
    D.
    Error

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What is the output of the following code ?

    example = "snow world"
    example[3] = 's'
    print example
  4. A.
    snow
    B.
    snow world
    C.
    Error
    D.
    snos world

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What is the output of "hello+1+2+3 ?
  6. A.
    hello123
    B.
    hello
    C.
    Error
    D.
    hello6

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Suppose i is 5 and j is 4, i + j is same as
  8. A.
    i.__add(j)
    B.
    i.__add__(j)
    C.
    i.__Add(j)
    D.
    i.__ADD(j)

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What is the output of the following?

    print('*', "abcdef".center(7), '*')
  10. A.
    * abcdef *
    B.
    * abcdef *
    C.
    *abcdef *
    D.
    * abcdef*

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What is the output of the following?

    print("Hello {1} and {0}".format('bin', 'foo'))
  12. A.
    Hello foo and bin
    B.
    Hello bin and foo
    C.
    Error
    D.
    None of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What is the output of the following?

    print('The sum of {0} and {1} is {2}'.format(2, 10, 12))
  14. A.
    The sum of 2 and 10 is 12
    B.
    Error
    C.
    The sum of 0 and 1 is 2
    D.
    None of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What is the output of the following?

    print('ab'.isalpha())
  16. A.
    True
    B.
    False
    C.
    None
    D.
    Error

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What is the output of the following?

    print('1.1'.isnumeric())
  18. A.
    True
    B.
    False
    C.
    None
    D.
    Error

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What is the output of the following?

    print('a'.maketrans('ABC', '123'))
  20. A.
    {97: 49, 98: 50, 99: 51}
    B.
    {65: 49, 66: 50, 67: 51}
    C.
    {97: 49}
    D.
    1

    View Answer

    Workspace

    Discuss Discuss in Forum