Python - O - Pedia

60 Questions | Total Attempts: 68

SettingsSettingsSettings
Please wait...
Python - O - Pedia

.


Questions and Answers
  • 1. 
     Which of the following is not a keyword?
    • A. 

      Eval

    • B. 

      Assert

    • C. 

      Nonlocal

    • D. 

      Pass

  • 2. 
    All keywords in Python are in
    • A. 

      Lowercase

    • B. 

      UPPER CASE

    • C. 

      Capitalized

    • D. 

      None of the mentioned

  • 3. 
    Which one of these is floor division?
    • A. 

      /

    • B. 

      //

    • C. 

      %

    • D. 

      None of the mentioned

  • 4. 
    Operators with the same precedence are evaluated in which manner:
    • A. 

      Left to Right

    • B. 

      Right to Left

    • C. 

      Can’t say

    • D. 

      None of the mentioned.

  • 5. 
    Which of these is not a core data type?
    • A. 

      Lists

    • B. 

      Dictionary

    • C. 

      Tuples

    • D. 

      Class

  • 6. 
    What will be the output of the following Python Code?     1.>>>str=”hello”     2.>>>str[:2]     3.>>>
    • A. 

      He

    • B. 

      Lo

    • C. 

      Olleh

    • D. 

      Hello

  • 7. 
    What is the return type of function id?
    • A. 

      Int

    • B. 

      Float

    • C. 

      Bool

    • D. 

      Dict

  • 8. 
    What error occurs when you execute the following Python code snippet? apple=mango
    • A. 

      SyntaxError

    • B. 

      NameError

    • C. 

      ValueError

    • D. 

      TypeError

  • 9. 
    What datatype is the object below? L=[1, 23, “Hello” , 2]
    • A. 

      List

    • B. 

      Dictionary

    • C. 

      Array

    • D. 

      Tuple

  • 10. 
    Which data type use key-value pair?
    • A. 

      List

    • B. 

      Dictionary

    • C. 

      Array

    • D. 

      Tuple

  • 11. 
    Which of the following is not a complex number?
    • A. 

      K=2+3j

    • B. 

      K=complex(2,3)

    • C. 

       k=2+3I

    • D. 

      K=2+3J

  • 12. 
    What does ~4 evaluate to?
    • A. 

      -5

    • B. 

      -4

    • C. 

      -3

    • D. 

      +3

  • 13. 
    Which of the following operators has its associativity from right to left?
    • A. 

      +

    • B. 

      //

    • C. 

      %

    • D. 

      **

  • 14. 
    The value of the expressions 4/(3*(2-1)) and 4/3*(2-1) is the same.
    • A. 

      True

    • B. 

      False

  • 15. 
    What is the value of the following expression? float (22//3+3/3)
    • A. 

      8

    • B. 

      8.0

    • C. 

      8.3

    • D. 

      8.33

  • 16. 
    Which of the following expressions is an example of type conversion?
    • A. 

      4.0+float(3)

    • B. 

      5.3+6.3

    • C. 

      5.0+3

    • D. 

      3+7

  • 17. 
    What will be the output of the following code snippet? bool(‘False’) bool()
    • A. 

      True True

    • B. 

      . False   True

    • C. 

      False False

    • D. 

      True False

  • 18. 
    What will be the output of the following Python code? class Truth:     pass x=Truth() bool(x)
    • A. 

      Pass

    • B. 

      True

    • C. 

      False

    • D. 

      Error

  • 19. 
    What will be the output of the following Python code? if (9 < 0) and (0 < -9):     print("hello") elif (9 > 0) or False:     print("good") else:     print("bad")
    • A. 

      Error

    • B. 

      Hello

    • C. 

      Good

    • D. 

      Bad

  • 20. 
    What will be the output of the following Python code? i = 1 while True:     if i%2 == 0:         break     print(i)     i += 2
    • A. 

      1

    • B. 

      1 2

    • C. 

      1 2 3 4 5 6

    • D. 

      1 3 5 7 9 11

  • 21. 
    What will be the output of the following Python code? x = ['ab', 'cd'] for i in x:     i.upper() print(x)
    • A. 

      [‘ab’, ‘cd’]

    • B. 

      [‘AB’, ‘CD’]

    • C. 

      [None, None]

    • D. 

      None of the mentioned

  • 22. 
    What will be the output of the following Python code? x = "abcdef" while i in x:     print(i, end=" ")
    • A. 

      A b c d e f

    • B. 

      Abcdef

    • C. 

      Iiiiii…

    • D. 

      Error

  • 23. 
    What will be the output of the following Python code? x = "abcdef" i = "a" while i in x[:-1]:     print(i, end = " ")
    • A. 

      A a a a a

    • B. 

      A a a a a a

    • C. 

      A a a a a a …

    • D. 

      A

  • 24. 
    What will be the output of the following Python code? d = {0: 'a', 1: 'b', 2: 'c'} for x in d.values():     print(d[x])
    • A. 

      0 1 2

    • B. 

       a b c

    • C. 

      0 a 1 b 2 c

    • D. 

      None of the mentioned 

  • 25. 
    What will be the output of the following Python code? ⦁    class father: ⦁        def __init__(self, param): ⦁            self.o1 = param ⦁      ⦁    class child(father): ⦁        def __init__(self, param): ⦁            self.o2 = param ⦁      ⦁    >>>obj = child(22) ⦁    >>>print "%d %d" % (obj.o1, obj.o2)
    • A. 

      None None

    • B. 

      None 22

    • C. 

      22 None

    • D. 

      Error is generated

Back to Top Back to top