wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Review Quiz

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

In Python, given `x = 15` and `y = 4`, what is the result of the expression `x // y`?

a)

1

b)

4

c)

3

d)

3.75

2.

According to the four steps of problem-solving presented in the lecture, which step involves writing pseudocode?

a)

Carry out the plan

b)

Understand the problem

c)

Make a plan/choosing a strategy

d)

Evaluate

3.

When opening a file in Python, which file mode should be used to add new content to the end of the file without deleting its existing content?

a)

w+

b)

r

c)

a

d)

w

4.

Given the Python dictionary `student = {"name": "Marie Deane", "course": "Computer Science"}`, which syntax correctly accesses the value "Computer Science"?

a)

student["course"]

b)

student.course

c)

student("course")

d)

student[1]

5.

What is the primary advantage of using the `with open(...) as ...:` statement for file handling in Python?

a)

It ensures the file is automatically closed, even if errors occur within the block

b)

It reads the entire contents of the file into a single string automatically

c)

It removes the need to handle 'IOError' exceptions

d)

It makes the file open faster than using a standard 'open()' call

6.

What is the Python comparison operator equivalent to the mathematical notation for not equal?

a)

<>

b)

==

c)

not=

d)

!=

7.

In object-oriented programming, what is the main purpose of getter and setter methods as described in the lecture?

a)

To decrease the memory usage of an object.

b)

To protect an object's attributes by controlling access to them

c)

To add new attributes to an object dynamically after its creation

d)

To initialize an object's attributes when it is first created

8.

Which Python code snippet will print the numbers 1, 2, and 3, each on a new line?

a)

for count in range(1,3): print(count)

b)

for count in range(1,4): print(count)

c)

for count in range(4): print(count)

d)

count = 1
while count < 3:

print(count)
count++

9.

According to the provided precedence table, which operation is performed last in the expression `not x > y or z == 1`?

a)

x > y

b)

or

c)

z == 1

d)

not

10.

Which Python list method is used to add a single item to the very end of the list?

a)

list.append(item)

b)

list.extend(another_list)

c)

list.insert(index, item)

d)

list.add(item)