What will be the output of the following Python code snippet?
d = {"john":40, "peter":45}
print(d)
Python practice quiz 6
Quiz
•
Professional Development
•
Professional Development
•
Medium
Assoc.Prof,IT Chennai
Used 1+ times
FREE Resource
18 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will be the output of the following Python code snippet?
d = {"john":40, "peter":45}
print(d)
“john”, 40, “peter”, 45
{‘john’: 40, ‘peter’: 45}
40 and 45
d = (40:”john”, 45:”peter”)
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will be the output of the following Python code snippet?
>>> d = {"john":40, "peter":45}
>>> "john" in d
true
false
none
eror
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will be the output of the following Python code snippet?
d1 = {"john":40, "peter":45}
d2 = {"john":466, "peter":45}
d1 > d2
true
false
error
none
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” what command do we use?
d.delete(“john”:40)
d.delete(“john”)
del d[“john”]
del d(“john”:40)
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will be the output of the following Python code snippet?
d = {"john":40, "peter":45}
print(list(d.keys()))
[“john”, “peter”]
[“john”:40, “peter”:45]
(“john”, “peter”)
(“john”:40, “peter”:45)
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of these about a dictionary is false?
The values of a dictionary can be accessed using keys
The keys of a dictionary can be accessed using values
Dictionaries aren’t ordered
Dictionaries are mutable
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What will be the output of the following Python code snippet?
a={1:"A",2:"B",3:"C"}
print(a.get(1,4))
1
A
4
invalid syntax for get method
20 questions
Python Code
Quiz
•
8th Grade - Professio...
14 questions
Java Collections
Quiz
•
Professional Development
20 questions
C++ Operators
Quiz
•
Professional Development
15 questions
Quiz 2 Internship on Fundamentals of Python
Quiz
•
Professional Development
13 questions
Python Quiz : Loop
Quiz
•
Professional Development
20 questions
VCE TalentNext-2021 Quiz-2
Quiz
•
Professional Development
15 questions
Pre - Qualifier Assessments - Python Training
Quiz
•
Professional Development
15 questions
Javascript basics
Quiz
•
Professional Development
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