Multiple Choice Questions -list & Dictionary

28 Questions | Attempts: 1278
Share

SettingsSettingsSettings
Multiple Choice Questions -list & Dictionary - Quiz

.


Questions and Answers
  • 1. 
    Which of the following commands will create a list?  
    • A. 

      List1 = list()

    • B. 

      List1 = []

    • C. 

      List1 = list([1, 2, 3])

    • D. 

      All of the mentioned

  • 2. 
    What is the output when we execute list(“hello”)?
    • A. 

      [‘h’, ‘e’, ‘l’, ‘l’, ‘o’]

    • B. 

      [‘hello’]

    • C. 

      [‘llo’]

    • D. 

      [‘olleh’]

  • 3. 
    Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)?
    • A. 

      5

    • B. 

      4

    • C. 

      None

    • D. 

      Error

  • 4. 
    Suppose list1 is [2445,133,12454,123], what is max(list1)?
    • A. 

      2445

    • B. 

      133

    • C. 

      12454

    • D. 

      123

  • 5. 
    Suppose list1 is [1, 5, 9], what is sum(list1)?
    • A. 

      1

    • B. 

      9

    • C. 

      15

    • D. 

      Error

  • 6. 
    Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?
    • A. 

      Error

    • B. 

      None

    • C. 

      25

    • D. 

      2

  • 7. 
    Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?
    • A. 

      [2, 33, 222, 14]

    • B. 

      Error

    • C. 

      25

    • D. 

      [25, 14, 222, 33, 2]

  • 8. 
    Suppose list1 is [1, 3, 2], What is list1 * 2?
    • A. 

      [2, 6, 4]

    • B. 

      [1, 3, 2, 1, 3]

    • C. 

      [1, 3, 2, 1, 3, 2]

    • D. 

      [1, 3, 2, 3, 2, 1]

  • 9. 
    To add a new element to a list we use which command?
    • A. 

      List1.add(5)

    • B. 

      List1.append(5)

    • C. 

      List1.addLast(5)

    • D. 

      List1.addEnd(5)

  • 10. 
    Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.reverse()?
    • A. 

      [3, 4, 5, 20, 5, 25, 1, 3]

    • B. 

      [1, 3, 3, 4, 5, 5, 20, 25]

    • C. 

      [25, 20, 5, 5, 4, 3, 3, 1]

    • D. 

      [3, 1, 25, 5, 20, 5, 4, 3]

  • 11. 
    Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.extend([34, 5])?
    • A. 

      [3, 4, 5, 20, 5, 25, 1, 3, 34, 5]

    • B. 

      [1, 3, 3, 4, 5, 5, 20, 25, 34, 5]

    • C. 

      [25, 20, 5, 5, 4, 3, 3, 1, 34, 5]

    • D. 

      [1, 3, 4, 5, 20, 5, 25, 3, 34, 5]

  • 12. 
    Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.pop(1)?
    • A. 

      [3, 4, 5, 20, 5, 25, 1, 3]

    • B. 

      [1, 3, 3, 4, 5, 5, 20, 25]

    • C. 

      [3, 5, 20, 5, 25, 1, 3]

    • D. 

      [1, 3, 4, 5, 20, 5, 25]

  • 13. 
    Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.pop()?
    • A. 

      [3, 4, 5, 20, 5, 25, 1]

    • B. 

      [1, 3, 3, 4, 5, 5, 20, 25]

    • C. 

      [3, 5, 20, 5, 25, 1, 3]

    • D. 

      [1, 3, 4, 5, 20, 5, 25]

  • 14. 
    What will be the output of the following Python code? >>>"Welcome to Python".split()
    • A. 

      [“Welcome”, “to”, “Python”]

    • B. 

      (“Welcome”, “to”, “Python”)

    • C. 

      {“Welcome”, “to”, “Python”}

    • D. 

      “Welcome”, “to”, “Python”

  • 15. 
    What will be the output of the following Python code? >>>list("a#b#c#d".split('#'))
    • A. 

      [‘a’, ‘b’, ‘c’, ‘d’]

    • B. 

      [‘a b c d’]

    • C. 

      [‘a#b#c#d’]

    • D. 

      [‘abcd’]

  • 16. 
    To which of the following the “in” operator can be used to check if an item is in it?
    • A. 

      Lists

    • B. 

      Dictionary

    • C. 

      Set

    • D. 

      All of the mentioned

  • 17. 
    What will be the output of the following Python code? list1 = [1, 2, 3, 4] list2 = [5, 6, 7, 8] print(len(list1 + list2))
    • A. 

      2

    • B. 

      4

    • C. 

      5

    • D. 

      8

  • 18. 
    Which of the following statements create a dictionary?
    • A. 

      D = {}

    • B. 

      D = {“john”:40, “peter”:45}

    • C. 

      D = {40:”john”, 45:”peter”}

    • D. 

      All of the mentioned

  • 19. 
    What will be the output of the following Python code snippet? d = {"john":40, "peter":45}
    • A. 

      “john”, 40, 45, and “peter”

    • B. 

      “john” and “peter”

    • C. 

      40 and 45

    • D. 

      D = (40:”john”, 45:”peter”)

  • 20. 
    What will be the output of the following Python code snippet? d = {"john":40, "peter":45} "john" in d
    • A. 

      True

    • B. 

      False

    • C. 

      None

    • D. 

      Error

  • 21. 
    Which of these about a dictionary is false?
    • A. 

      The values of a dictionary can be accessed using keys

    • B. 

      The keys of a dictionary can be accessed using values

    • C. 

      Dictionaries aren’t ordered

    • D. 

      Dictionaries are mutable

  • 22. 
    Which of the following is not a declaration of the dictionary?
    • A. 

      {1: ‘A’, 2: ‘B’}

    • B. 

      Dict([[1,”A”],[2,”B”]])

    • C. 

      {1,”A”,2”B”}

    • D. 

      { }

  • 23. 
    What will be the output of the following Python code snippet? a={1:"A",2:"B",3:"C"} for i,j in a.items():     print(i,j,end=" ")
    • A. 

      1 A 2 B 3 C

    • B. 

      1 2 3

    • C. 

      A B C

    • D. 

      1:”A” 2:”B” 3:”C”

  • 24. 
    What will be the output of the following Python code snippet? a={1:"A",2:"B",3:"C"} print(a.get(1,4))
    • A. 

      1

    • B. 

      A

    • C. 

      4

    • D. 

      Invalid syntax for get method

  • 25. 
    What will be the output of the following Python code snippet? a={1:"A",2:"B",3:"C"} print(a.get(5,4))
    • A. 

      Error, invalid syntax

    • B. 

      A

    • C. 

      5

    • D. 

      4

Back to Top Back to top
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.