Python 3
Quiz
•
Computers
•
9th - 12th Grade
•
Hard
Used 6+ times
FREE Resource
Enhance your content in a minute
30 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
You have the following code:
y=2
x=0
while x*Y < 8:
if x == 3:
pass
while x < 2:
x = x+1
x +=1
What will be the value of x?
6
5
7
4
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
You have the following code:
n= 4
x = 1
You need to print out a multiplication table for 4 X 1 through 4 X 10, with each output on a separate line.
The first output should be : 4 X 1 = 4
The last output should be : 4 X 10 = 40
Which code segment should you use?
while x < 11:
print(str(n) + 'x' + str(x) + ' = ' + str(n*x))
x +=1
while x <= 11:
print(str(n) + 'x' + str(x) + ' = ' + str(n*x))
x +=1
while x <11:
print(str(n) + 'x' + str(x) + ' = ' + (n*x))
x += 1
while x < 11:
print(str(n) + 'x' + str(x) + ' = ' + str(n*x))
x += 1
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
You have the following code:
n = 2
x = 7
for i in range (5,x):
while i < 6:
n = n +1
if n == 2:
pass
else:
n += 1
i += 1
What will be the value of n?
5
6
7
4
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
You need to write the following list to a CSV file:
students = [["Mark", "A"], ["Bryan", "B"], ["Lisa", "B"], ["Jessica", "C"],["Tim", "A"]]
Which code segment should you use?
import csv
with open("students.csv", "w", newline="") as f:
f.writerows(students)
import csv
with open("students.csv", "w", newline="") as f:
writer = csv.writer(f)
writer.writerows(students)
import csv
with open("students.csv", "w", newline="") as f:
writer = csv.writer(f)
writer.write(students)
import csv
with open("students.csv", "wb", newline="") as f:
writer = csv.writer(f)
writer.writerows(students)
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
You have the following snippet:
import pickle
course_count = [["C++", "24"], ["Java", "32"], ["Python", "38"], ["JavaScript", "29"], ["C#", "40"]]
# add missing code here
with open("languages.bin", "rb") as f:
course_count2 = pickle.load(f)
print(course_count2)
You need to add the missing code to write the list to a binary file.
Which code fragment should you use?
with open("languages.bin", "wb") as f:
pickle.write(course_count, f)
with open("languages.bin", "wb" as f:
writer = pickle.writer(f)
writer.dump(course_count)
with open("languages.bin", "wb") as f:
pickle.dump(course_count, f)
with open("languages.bin", "b") as f:
pickle.dump(course_count, f)
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
You need to write some contents to a file named file_name that will be in the following format:
Hello World!
Which code segment should you use?
f = open('file_name')
f.write('Hello World!')
f.close()
f = open('file_name', 'w')
f.write('Hello World!')
f.close()
f = open('file_name', 'r')
f.write('Hello World!')
f.close()
f = open('file_name', 'b')
f.write('Hello World!')
f.close()
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
You have a file named studentfile with the following content:
Dave, 100, 90, 77
Sam, 55, 90, 80
You need to write code to read all of the contents of the file.
Which code segment should you use?
with open('studentfile') as f:
file_data = f.read()
with open('studentfile', 'r') f:
file_data = f.read()
with open('studentfile', 'w') as f:
file_data = f.read()
with open('studentfile') as f:
file_data = f.readline()
Create a free account and access millions of resources
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?
Similar Resources on Wayground
25 questions
PEMROG. P. BERGERAK
Quiz
•
11th Grade
25 questions
Новогодние хацкеры🖥️🧑🏻🎄
Quiz
•
9th - 12th Grade
25 questions
AAG Academy Breakout Session - January
Quiz
•
10th Grade
25 questions
OCR GCSE Computer Science: 1.4 Networks (Part 2)
Quiz
•
10th Grade
33 questions
R081 - Pre-Production documents HWK
Quiz
•
9th - 10th Grade
26 questions
IGCSE CH 1, 2, and 3 Revision and Support 2
Quiz
•
9th - 10th Grade
27 questions
Functions of Operating Systems
Quiz
•
8th - 12th Grade
25 questions
Client Server Model
Quiz
•
11th - 12th Grade
Popular Resources on Wayground
10 questions
Ice Breaker Trivia: Food from Around the World
Quiz
•
3rd - 12th Grade
20 questions
MINERS Core Values Quiz
Quiz
•
8th Grade
10 questions
Boomer ⚡ Zoomer - Holiday Movies
Quiz
•
KG - University
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
Adding Integers
Quiz
•
6th Grade
20 questions
Multiplying and Dividing Integers
Quiz
•
7th Grade
10 questions
How to Email your Teacher
Quiz
•
Professional Development
15 questions
Order of Operations
Quiz
•
5th Grade
