You are on page 1of 7

2/14/2020 Python - Lists, Dictionaries and Loops | Print - Quizizz

NAME :

CLASS :
Python - Lists, Dictionaries and Loops
DATE :
36 Questions

1. list[a:b] will return the portion of list starting with index a and
ending before index b.

a) True b) False

2. What will be the value of last_jedi after the following code is


run?

a) ["kylo", "rey", "finn", "luke"] b) ["kylo", "rey", "finn"]

c) 3 d) 4

3. What will be the value of authors after the following code is


run?

a) ["Martin", "Rowling", "Tolkien"] b) ["Martin"]

c) ["Rowling"] d) ["Tolkien", "Rowling", "Martin"]

4. What will this code print?

a) 6 b) 1

c) pants d) "pants": 6

5. What is the correct syntax to write a for loop to iterate through


the list grades?

a) for variable: b) for variable in grades

c) variable in grades: d) for variable in grades:

6. What does the following code do?

a) It prints [0, 6]. b) It prints all numbers in range(0, 6) in a list.

c) It prints all numbers in range(0, 6) separately. d) It prints True or False.

https://quizizz.com/print/quiz/5e0dbf3bbdc0e1001c511941 1/7
2/14/2020 Python - Lists, Dictionaries and Loops | Print - Quizizz

7. Fill in the blank so that print_list(x) prints every other item in list
x:

a) range(0, len(x), -2) b) range(0, x, 2)


c) range(0, len(x), 2) d) range(0, len(x), 1)

8. What will be the value of n after the following code is run?

a) [6] b) [1, 8, 6, 4, 2]

c) [8, 6, 4, 2, 1] d) [8, 4, 2]

9. What will be the value of n after the following code is run?

a) [1, 3, 5] b) [3]
c) [1, 5, 7] d) [1, 3, 7]

10. How many lines will the code below print to the console?

a) 4 b) 5

c) 2 d) 3

11. What does the zip function do?

a) It creates pairs of elements when passed b) It creates pairs of elements when passed two
integers lists

c) It passes more lists into a function d) It pairs integers in dictionary values

12. Which function can be used to supply an index to each


element of a list as you iterate through it?

a) index() b) enumerate()

c) itemize() d) track()

https://quizizz.com/print/quiz/5e0dbf3bbdc0e1001c511941 2/7
2/14/2020 Python - Lists, Dictionaries and Loops | Print - Quizizz

13. Which of the following is the correct way to create the following
list of names: 'Tom', 'Jerry', 'Tweetie', 'Sylvester'?

a) b)

c) d)

14. Is the following list a valid Python list?

a) Yes, lists can contain multiple data types. b) No, lists can only contain one data type.

15. Which of these commands would create a list of numbers


starting at 0 and up to (but not including) 9?

a) list(9) b) list(range(10))

c) list(range(9)) d) list(range([0, 9]))

16. How could we add ['Hawaii', 'Alaska'] to the list states?

a) b)

c) d)

17. Which of the following is the correct way to create an empty


list?

a) empty_list = [] b) empty_list = {}

c) empty_list = [0] d) empty_list = None

18. Which of the following would create a range object that starts
at 3, goes up to but not including 15 where each number is 4
greater than the previous number?

a) range(3, 15, 4) b) range(3, 4, 15)


c) range(4, 15, 3) d) range(15, 4, 3)

19. Which of the following is the correct way to add the number 4
to mylist?

a) mylist + 4 b) mylist.append(4)
c) mylist.append([4]) d) 4.append(mylist)

20. Which of the following lines of code would select the list ['b', 'c']
from mylist:

a) mylist[1:3] b) mylist[1,3]

c) mylist[1,2] d) mylist[1:2]

https://quizizz.com/print/quiz/5e0dbf3bbdc0e1001c511941 3/7
2/14/2020 Python - Lists, Dictionaries and Loops | Print - Quizizz

21. Which of the following lines of code will correctly sort mylist?

a) mylist.sorted() b) sort(mylist)
c) mylist.sort d) mylist.sort()

22. Which of the following would be generated by the code


snippet?

a) ['b', 'c', 'd'] b) ['b', 'c', 'd', 'e']

c) ['c', 'd', 'e'] d) ['c', 'd', 'e', 'f']

23. Which of the following commands will return the length of the
list mylist?

a) length(mylist) b) len(mylist)

c) mylist.length() d) mylist.len()

24. Which of the following lines of code would select the letter d
from mylist:

a) mylist[4] b) mylist{4}

c) mylist[3] d) mylist(3)

25. What would be the output of this code:

a) hello! hello! hello! hello! b) 2 4 6 8


c) hello! d) 2 hello! 4 hello! 6 hello! 8 hello!

26. What would be the output of this code:

a) 0 1 2 3 4 b) 3 3 3 3 3
c) 5 5 5 d) 0 1 2

27. Fill in the blank with the appropriate while condition in order to
print the numbers 1 through 10 in order:

a) while i > 10: b) while i == range(11):

c) while i <= 10: d) while i < 10:

https://quizizz.com/print/quiz/5e0dbf3bbdc0e1001c511941 4/7
2/14/2020 Python - Lists, Dictionaries and Loops | Print - Quizizz

28. What would be the output of this code:

a) i i i i b) 1 2 3
c) 0 1 2 d) i i i

29. What would be the output of this code:

a) 1 1 2 3 b) 2

c) 1 1 d) 1 1 3

30. What would be the output of this code:

a) ["coffee", "tea", "water", "juice", "soda"] b) drink


c) "coffee" d) "coffee" "tea" "water" "juice" "soda"

31. What is the line of code to initialize an empty dictionary called


thesaurus?

a) thesaurus = new Dictionary(); b) thesaurus = {};


c) thesaurus = empty_dict(); d) thesaurus = [];

32. Which of these is an invalid dictionary (will result in a


TypeError when trying to run)?

a) b)

c) d) All of these are valid

33. What is the value of inventory after this code is run?

a) b)

c) d)

https://quizizz.com/print/quiz/5e0dbf3bbdc0e1001c511941 5/7
2/14/2020 Python - Lists, Dictionaries and Loops | Print - Quizizz

34. Which of these dictionaries has integers as the keys and


strings as the values?

a) b)

c) d)

35. What will the following code output?

a) "soda" b) KeyError
c) ["veggie burger", "salad", "soda"] d) ["hamburger", "fries", "soda"]

36. What is the output of the following code?

a) "Moonlight""Casey Affleck""Emma b) ("Best Picture", "Moonlight")("Best Actor",


Stone""Zootopia" "Casey Affleck")("Best Actress", "Emma
Stone")("Animated Feature", "Zootopia")

c) "Best Picture""Best Actor""Best d) "Best Picture" : "Moonlight""Best Actor":


Actress""Animated Feature" "Casey Affleck""Best Actress": "Emma
Stone""Animated Feature": "Zootopia"

https://quizizz.com/print/quiz/5e0dbf3bbdc0e1001c511941 6/7
2/14/2020 Python - Lists, Dictionaries and Loops | Print - Quizizz

Answer Key
1. a 10. c 19. b 28. c
2. b 11. b 20. a 29. c
3. a 12. b 21. d 30. d
4. a 13. c 22. c 31. b
5. d 14. a 23. b 32. a
6. c 15. c 24. c 33. a
7. c 16. a 25. a 34. d
8. d 17. a 26. c 35. d
9. c 18. a 27. c 36. c

https://quizizz.com/print/quiz/5e0dbf3bbdc0e1001c511941 7/7

You might also like