PYTHON QUIZ2

Quiz
•
Computers
•
University - Professional Development
•
Hard
MSK PSGRKCW
Used 9+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
1. Which of the following is correct with respect to the python code d = {"a":3,"b":7}?
Dictionary d is created.
a and b are the keys of dictionary d.
3 and 7 are the values of dictionary d
All of the above.
2.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
2. What will be the output of the Python code?
d1={"abc":5,"def":6,"ghi":7}
print(d1[0])
abc
5
{“abc”:5}
Error
3.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
3. What will be the output of the following Python code snippet?
>>> d = {"john":40, "peter":45}
>>> d["john"]
40
45
“john”
“peter”
4.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
4. Suppose d = {“john”:40, “peter”:45}. To obtain the number of entries in dictionary which command do we use?
d.size()
len(d)
size(d)
d.len()
5.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
5. What will be the output of the following Python code snippet?
a = {i: i * i for i in range(6)}
print (a)
Dictionary comprehension doesn’t exist
{0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6:36}
{0: 0, 1: 1, 4: 4, 9: 9, 16: 16, 25: 25}
{ 0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
6.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
6. To read two characters from a file object infile, we use ________.
infile.read(2)
infile.read()
infile.readline()
infile.readlines()
7.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
7. Which of the following command is used to open a file “c:\temp.txt” in read-mode only?
infile = open(“c:\temp.txt”, “r”)
infile = open(“c:\\temp.txt”, “r”)
infile = open(file = “c:\temp.txt”, “r+”)
infile = open(file = “c:\\temp.txt”, “r+”)
Create a free account and access millions of resources
Similar Resources on Wayground
11 questions
Linux Commands

Quiz
•
University
11 questions
Python Round 3

Quiz
•
University
8 questions
CSE 15L Lab 9

Quiz
•
University
10 questions
DIS08_1_Shell

Quiz
•
University
10 questions
LINUX 4TH MODULE QUIZ

Quiz
•
University
10 questions
Windows 10 System Management Tools

Quiz
•
9th Grade - University
13 questions
SAS PG2 - Reading Raw Data Files

Quiz
•
University
15 questions
Python Programming Intermediate-1

Quiz
•
University
Popular Resources on Wayground
15 questions
Hersheys' Travels Quiz (AM)

Quiz
•
6th - 8th Grade
20 questions
PBIS-HGMS

Quiz
•
6th - 8th Grade
30 questions
Lufkin Road Middle School Student Handbook & Policies Assessment

Quiz
•
7th Grade
20 questions
Multiplication Facts

Quiz
•
3rd Grade
17 questions
MIXED Factoring Review

Quiz
•
KG - University
10 questions
Laws of Exponents

Quiz
•
9th Grade
10 questions
Characterization

Quiz
•
3rd - 7th Grade
10 questions
Multiply Fractions

Quiz
•
6th Grade