What is the output of the following code?
fruits = ['apple', 'banana', 'cherry']
print(fruits[1])
Python-Lists_Dictionaries
Quiz
•
Computers
•
University
•
Hard
Anik Acharjee
Used 2+ times
FREE Resource
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the output of the following code?
fruits = ['apple', 'banana', 'cherry']
print(fruits[1])
apple
banana
cherry
['apple', 'banana', 'cherry']
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
How do you add an element to the end of a list?
list.add(element)
list.append(element)
list.insert(element)
list.push(element)
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the correct way to create an empty dictionary?
dict = {}
dict = []
dict = ()
dict = set()
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
How do you access the value of a key in a dictionary?
dict[key]
dict(key)
dict.get(key)
Both dict[key] and dict.get(key)
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the output of the following code?
numbers = [1, 2, 3, 4, 5]
print(len(numbers))
4
5
6
[1, 2, 3, 4, 5]
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
How do you remove the last element from a list?
list.remove()
list.pop()
list.delete()
list.cut()
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the correct way to check if a key exists in a dictionary?
if key in dict:
if key exists in dict:
if dict.haskey(key):
if dict.contains(key):
15 questions
Python Basics
Quiz
•
University
15 questions
Python revision
Quiz
•
10th Grade - University
20 questions
GirlsWhoML Workshop 0
Quiz
•
University
20 questions
[Python For All] Quiz 2 - Rewind.py
Quiz
•
University
15 questions
Quiz3
Quiz
•
University
17 questions
VISUAL BASIC
Quiz
•
University
20 questions
1212 Midterm Review
Quiz
•
University
15 questions
General Linux
Quiz
•
University
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade