Python 3

Python 3

9th - 12th Grade

30 Qs

quiz-placeholder

Similar activities

Unit 4 Assessment Review

Unit 4 Assessment Review

9th - 12th Grade

25 Qs

Programming and data structures revision

Programming and data structures revision

9th - 10th Grade

25 Qs

The Internet

The Internet

6th - 9th Grade

25 Qs

Transmisi

Transmisi

11th Grade

25 Qs

Hardware 5 (The Processor)

Hardware 5 (The Processor)

10th Grade

25 Qs

TDP112 Introduction to Laravel

TDP112 Introduction to Laravel

8th - 10th Grade

25 Qs

Python new

Python new

3rd Grade - University

26 Qs

PRETEST BK TIK KELAS 12

PRETEST BK TIK KELAS 12

12th Grade

25 Qs

Python 3

Python 3

Assessment

Quiz

Computers

9th - 12th Grade

Hard

Used 6+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?