Introduction To Python

10 Questions | Total Attempts: 78

SettingsSettingsSettings
Please wait...
Programming Quizzes & Trivia

.


Questions and Answers
  • 1. 
    What is the output of the following?elements = [0, 1, 2]def incr(x):    return x+1print(list(map(elements, incr))) 
    • A. 

      [1, 2, 3]

    • B. 

      [0, 1, 2]

    • C. 

      Error

    • D. 

      None of the mentioned

  • 2. 
    Carefully observe the code and give the answer.def example(a):    a = a + '2'     a = a*2    return a>>>example("hello") 
    • A. 

      Indentation Error

    • B. 

      cannot perform mathematical operation on strings

    • C. 

      hello2

    • D. 

      Hello2hello2

  • 3. 
    . What is the output of the following?x = ['ab', 'cd']for i in x:    x.append(i.upper())print(x) 
    • A. 

      [‘AB’, ‘CD’].

    • B. 

      [‘ab’, ‘cd’, ‘AB’, ‘CD’].

    • C. 

      [‘ab’, ‘cd’].

    • D. 

      None of the mentioned

  • 4. 
    What is the output of the following?x = "abcdef"i = "a"while i in x:    print(i, end = " ") 
    • A. 

      No output

    • B. 

      I i i i i i …

    • C. 

      A a a a a a …

    • D. 

      A b c d e f

  • 5. 
    What is the output of the following?for i in range(5):    if i == 5:        break    else:        print(i)else:             print("Here") 
    • A. 

      0 1 2 3 4 Here

    • B. 

      0 1 2 3 4 5 Here

    • C. 

      0 1 2 3 4

    • D. 

      1 2 3 4 5

  • 6. 
    What is the output of the following?print('Ab!2'.swapcase()) 
  • 7. 
    What is the output when following code is executed ?
    1. >>> str1 = 'hello'
    2. >>> str2 = ','
    3. >>> str3 = 'world'
    4. >>> str1[-1:]
    • A. 

      Olleh

    • B. 

      Hello

    • C. 

      H

    • D. 

      O

  • 8. 
    What is the output when following code is executed ?print 0xA + 0xB + 0xC
    • A. 

      0xA0xB0xC

    • B. 

      Error

    • C. 

      0x22

    • D. 

      33

  • 9. 
    What is the output when following code is executed ?
    1. myList = [1, 2, 3, 4, 5, 6]
    2. for i in range(1, 6):
    3.     myList[i - 1] = myList[i]
    4.  
    5. for i in range(0, 6):
    6.     print(myList[i], end = " ")
    • A. 

      2 3 4 5 6 1

    • B. 

      6 1 2 3 4 5

    • C. 

      2 3 4 5 6 6

    • D. 

      1 1 2 3 4 5

  • 10. 
    What will be the output?
    1. d1 = {"john":40, "peter":45}
    2. d2 = {"john":466, "peter":45}
    3. d1 > d2
    • A. 

      True

    • B. 

      False

    • C. 

      Error

    • D. 

      None