Python 3

Quiz
•
Computers
•
9th - 12th Grade
•
Hard
Used 6+ times
FREE Resource
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
Similar Resources on Wayground
25 questions
Aplikasi Pengolah Kata

Quiz
•
12th Grade
26 questions
Python set 1

Quiz
•
9th - 12th Grade
25 questions
InDesign q1

Quiz
•
9th - 12th Grade
30 questions
Python Basics

Quiz
•
8th - 10th Grade
26 questions
COP NSDA L3 =0011

Quiz
•
12th Grade
25 questions
PYTHON QUIZ 1

Quiz
•
11th - 12th Grade
27 questions
Python Fundamentals - II

Quiz
•
11th - 12th Grade
25 questions
Data Types- Python

Quiz
•
7th - 11th Grade
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