wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Midterm spring 2023 review

Total questions: 100

Worksheet time: 51mins

Name
Class
Date
1.

What is a file?

a)

It is an object on a computer that stores data, information, settings, or commands used with a computer program.

b)

It is an area on the computer containing other directories and files.

2.

“cute cat.png” is the _______ of an image.

a)

file name

b)

file extension

c)

file size

3.

“.png” is the _______.

a)

file name

b)

file extension

c)

file size

4.

The computer understands that files ending with ______ are Python files.

a)

.cs

b)

.java

c)

.js

d)

.py

e)

.html

5.

The (a)   is a user interface that is navigated by typing commands at prompts, instead of using a mouse.

6.

What command should you use to run a Python file named hello world.py?

a)

run world.py

b)

python world.py

c)

run python world.py

d)

command .py world.py

7.

What is the statement to display “Hello world!” using Python.

a)

print("hello world")

b)

print(hello world)

c)

display("hello world")

d)

display(hello world)

8.

Which of these variable names is not valid in python?

a)

&ones

b)

turnover25

c)

HOOP_RADIUS

d)

short_angle

9.

What is a string in Python?

a)

A string is what shoes have so they don’t fall off your feet.

b)

A string is the representation of numbers in Python.

c)

A string is a collection of items of any data type.

d)

A string is a series of characters.

10.

How is a string represented in Python?

a)

Between single quotes or double quotes.

b)

Only using single quotes (’).

c)

Only using double quotes (").

d)

No option is correct.

11.

What is the method .title() used for?

a)

It changes a string to all lowercase.

b)

It creates a title.

c)

It changes each word to Title Case, where each word begins with a capital letter.

d)

It changes a string to all UPPERCASE.

12.

What does the method .upper() do?

a)

It changes a string to all lowercase.

b)

It creates a title.

c)

It changes each word to Title Case, where each word begins with a capital letter.

d)

It changes a string to all UPPERCASE.

13.

What does the method .lower() do?

a)

It changes a string to all lowercase.

b)

It creates a title.

c)

It changes each word to Title Case, where each word begins with a capital letter.

d)

It changes a string to all UPPERCASE.

14.

What do we use to format strings and use variables inside strings?

a)

Python Lists

b)

f-strings

c)

The format method from Javascript

d)

Strings between backslashes (\)

15.

What character combination can we use to add a newline inside a string?

a)

\n

b)

\t

c)

\an

d)

\at

16.

What character combination can we use to add a tab inside a string?

a)

\n

b)

\t

c)

\an

d)

\at

17.

Which of the following is NOT a way to create a string and will throw an error?

a)

message = "One of Python’s strengths is its diverse community."

b)

’message = ’One of Python’s strengths is its diverse community.’

c)

message = f"One of Python’s strengths is its diverse community."

d)

message = f’One of Python s strengths is its diverse community.’

18.

What is the symbol for addition in Python?

a)

+

b)

-

c)

*

d)

/

19.

What is the symbol for subtraction in Python?

a)

+

b)

-

c)

*

d)

/

20.

What is the symbol for multiplication (×) in Python?

a)

+

b)

-

c)

*

d)

/

21.

What is the symbol for division (÷) in Python?

a)

+

b)

-

c)

*

d)

/

22.

What is the result of the following operation: >>> 2 + 3 * 4

a)

23333

b)

14

c)

234

d)

20

23.

What is the result of the following operation: >>> (2 + 3) * 4

a)

23333

b)

14

c)

234

d)

20

24.

What is the result of the following operation: >>> 4/2

a)

2/1

b)

2.0

c)

2

d)

’2’

25.

Does Python have a built-in constant type?

a)

yes

b)

no

26.

How do you write a comment in Python?

a)

comment(’Say hello to everyone’)

b)

// Say hello to everyone

c)

writeCommentPlease(’Say hello to everyone’)

d)

# Say hello to everyone

27.

What is a list?

a)

A list is the representation of numbers in Python.

b)

A list is a collection of items in a particular order.

c)

A list is a series of characters.

d)

A list is a method that we use to list the name of variables in Python.

28.

What is the correct statement to create a list?

a)

bicycles = [’trek’, ’cannondale’, ’redline’, ’specialized’]

b)

python createList()

c)

bicycles = ’trek’, ’cannondale’, ’redline’, ’specialized’

d)

bicycles = (’trek’, ’cannondale’, ’redline’, ’specialized’)

29.

Which of the following will access to the first element of a list?

a)

bicycles[1]

b)

bicycles(0)

c)

bicycles[-1]

d)

bicycles[0]

30.

What is it the correct statement to modify the second element of the following list:

>>> motorcycles = [’honda’, ’yamaha’, ’suzuki’]

a)

motorcycles[1] = ’ducati’

b)

motorcycles[2] = ’ducati’

c)

’ducati’ = motorcycles[2]

d)

motorcycles[1].change(ducati)

31.

Which statement will delete the last element of the following list?

students = ["Anna", "Alan, "Coco", "Grace"]

a)

del students[4]

b)

del students[-1]

c)

students[-1].delete()

d)

delete students["last"]

32.

What is the result of running the following Python code?

name = "ada lovelace"

name.title()

print(name)

a)

ada lovelace

b)

Ada Lovelace

c)

Ada Lovelace title

d)

ADA LOVELACE

33.

What is it the correct statement to add an element at the end of a list?

a)

bicycles.append(’element’)

b)

bicycles.insert(0, ’element’)

c)

popped item = bicycles.pop()

d)

bicycles.remove(’element’)

34.

What is it the correct statement to add an element at a specific position of a list?

a)

bicycles.append(’element’)

b)

bicycles.insert(0, ’element’)

c)

popped item = bicycles.pop()

d)

bicycles.remove(’element’)

35.

What is it the correct statement to remove an element of a list and save it in a variable?

a)

bicycles.append(’element’)

b)

bicycles.insert(0, ’element’)

c)

popped item = bicycles.pop()

d)

bicycles.remove(’element’)

36.

What is it the correct statement to remove an element of a list using the value of the element?

a)

bicycles.append(’element’)

b)

bicycles.insert(0, ’element’)

c)

popped item = bicycles.pop()

d)

bicycles.remove(’element’)

37.

What is it the correct statement to order a list alphabetically and permanently?

a)

sorted(cars)

b)

cars.sort(reverse=True)

c)

cars.reverse()

d)

cars.sort()

38.

What is it the correct statement to order a list in reverse alphabetical order and permanently?

a)

sorted(cars)

b)

cars.sort(reverse=True)

c)

cars.reverse()

d)

cars.sort()

39.

What is it the correct statement to order a list alphabetically and temporarily?

a)

sorted(cars)

b)

cars.sort(reverse=True)

c)

cars.reverse()

d)

cars.sort()

40.

What is it the correct statement to reverse the order of a list?

a)

sorted(cars)

b)

cars.sort(reverse=True)

c)

cars.reverse()

d)

cars.sort()

41.

How you can find the length of a list?

a)

cars.len()

b)

len cars

c)

len(cars)

d)

cars.find(’length’)

42.

What is the correct syntax for the "for" loop?

a)

for magician in magicians:

b)

for each magician in magicians:

c)

for magicians of magician:

d)

for magician of magicians:

43.

What error will throw python interpreter with the code that you can use on the image?

a)

IndentationError: expected an indented block

b)

IndentationError: unexpected indent

c)

SyntaxError: invalid syntax

d)

ZeroDivisionError: division by zero

44.

What error will throw python interpreter with the code that you can use on the image?

a)

IndentationError: expected an indented block

b)

IndentationError: unexpected indent

c)

SyntaxError: invalid syntax

d)

ZeroDivisionError: division by zero

45.

What error will throw python interpreter with the code that you can use on the image?

a)

IndentationError: expected an indented block

b)

IndentationError: unexpected indent

c)

SyntaxError: invalid syntax

d)

ZeroDivisionError: division by zero

46.

Which is the function that makes easy to generate a series of numbers?

a)

range()

b)

len()

c)

list()

d)

random()

47.

What numbers will generate the following statement?

range(1, 5)

a)

1 2 3 4

b)

0 1 2 3

c)

1 2 3 4 5

d)

0 1 2 3 4

48.

Which function can we use to convert the result of a range() into a list?

a)

range()

b)

len()

c)

list()

d)

random()

49.

What is it the statement to make a list of the numbers from one to one million?

a)

list(range(1,1000001))

b)

list(range(1,1000000))

c)

list(range(0,1000001))

d)

list(range(0,1000000))

50.

Which is the function to find the minimum of a list of numbers?

a)

min()

b)

max()

c)

sum()

d)

len()

51.

Which is the function to find the maximum of a list of numbers?

a)

min()

b)

max()

c)

sum()

d)

len()

52.

Which is the function to find the sum of a list of numbers?

a)

min()

b)

max()

c)

sum()

d)

len()

53.

What is the name of a a specific group of items in a list?

a)

slice

b)

small group of a list

c)

listy

d)

comand

54.

If we have the following list:

players = ['charles', 'martina', 'michael', 'florence', 'eli']

What will be the output of the following statement:

print(players[0:3])

a)

['charles', 'martina', 'michael']

b)

['martina', 'michael', 'florence']

c)

['charles', 'martina', 'michael', 'florence']

d)

['michael', 'florence', 'eli']

55.

If we have the following list:

players = ['charles', 'martina', 'michael', 'florence', 'eli']

What will be the output of the following statement:

print(players[1:4])

a)

['charles', 'martina', 'michael']

b)

['martina', 'michael', 'florence']

c)

['charles', 'martina', 'michael', 'florence']

d)

['michael', 'florence', 'eli']

56.

If we have the following list:

players = ['charles', 'martina', 'michael', 'florence', 'eli']

What will be the output of the following statement:

print(players[:4])

a)

['charles', 'martina', 'michael']

b)

['martina', 'michael', 'florence']

c)

['charles', 'martina', 'michael', 'florence']

d)

['michael', 'florence', 'eli']

57.

If we have the following list:

players = ['charles', 'martina', 'michael', 'florence', 'eli']

What will be the output of the following statement:

print(players[2:])

a)

['charles', 'martina', 'michael']

b)

['martina', 'michael', 'florence']

c)

['charles', 'martina', 'michael', 'florence']

d)

['michael', 'florence', 'eli']

58.

What is the correct statement to copy the following list list?

my_foods = ['pizza', 'falafel', 'carrot cake']

a)

friend_foods = my_foods[:]

b)

friend_foods = my_foods

c)

friend_foods = copy(my_foods)

d)

my_foods.copy(friend_foods)

59.

What is the main difference between a tuple and a list?

a)

Tuples cannot be change and list can.

b)

Tuples only can have 2 elements.

c)

Tuples can be change and list cannot.

d)

There isn't a method to create tuples.

60.

What is the output?

a)

True

b)

False

c)

condition1

d)

condition2

61.

What is the output?

a)

next

stop

b)

next

c)

stop

d)

syntax error - program doesn't work

62.

What is the output?

a)

True

b)

NIL

c)

True

NIL

d)

True

NIL

NIL

63.

What will be outputted?

a)

number is bigger than 10

b)

nothing

c)

an error

d)

NUMBER IS BIGGER THAN 10

64.

How do we call the condition inside the if statement that can be evaluated as True or False?

a)

conditional test

b)

slice

c)

python evaluation

d)

logical operator

65.

How do we check if a value is in a list?

a)

Using the "for" loop.

b)

Using the "in" keyword.

c)

Using the function isIn().

d)

There is no way to check that.

66.

Consider the following statement:


If you just need to work with the keys of a dictionary, then you can use .keys(), which is a method that returns a new view object containing the dictionary’s keys.


Is this statement True or False?

a)

False

b)

True

67.

Which of the following create an empty dictionary called person?

a)

person = dict()

b)

person = ()

c)

person = []

d)

person = {}

68.
What data type is this?
quiz = {"Do you help out at home? ":"yes",        
"Do you beleive in Santa? ":"yes"
}
a)

list

b)

string

c)

dictionart

d)

dictionary

69.
is this code correct?
quiz = ("Do you help out at home? ":"yes"      }
a)
No
b)
Yes
c)
Both
70.

Which is the correct statement to delete a key-value pair from a dictionary called alien_11?

a)

alien_11.delete()

b)

alien_11.discard()

c)

alien_11.remove()

d)

del alien_11['keyName']

71.

________________method will returns number of key-value pairs in the given dictionary.

a)

len( )

b)

pop( )

c)

del( )

d)

keys( )

e)

values( )

72.

How much information can a dictionary store in python?

a)

Almost limitless amount of information.

b)

Less than 1 Kilobyte.

c)

A very limited amount of information.

d)

A infinite amount, a dictionary can contain all the data in the world and more.

73.

What is a string in Python?

a)

A string is what shoes have so they don’t fall off your feet.

b)

A string is the representation of numbers in Python.

c)

A string is a collection of items of any data type.

d)

A string is a series of characters.

74.

What is it a dictionary in python?

a)

It is a collection of key-value pairs.

b)

It is the representation of numbers in Python.

c)

It is a set of values associated with each other.

d)

It is a series of characters.

75.

What is it a key-value pair?

a)

It is a collection of key-value pairs.

b)

It is the representation of numbers in Python.

c)

It is a set of values associated with each other.

d)

It is a series of characters.

76.

What type of data can it be a key value?

a)

A key’s value can be a number, a string, a list, or even another dictionary.

b)

A key’s value only can be a number.

c)

A key’s value only can be a string.

d)

A key’s value only can be a list.

77.

How many key-value pairs does the following dictionary have?

 

alien_0 = {'color': 'green', 'points': 5, 'power': 50}

(a)  

78.

1.       Underline the keys of the following dictionary’s key-value pairs.

alien_0 = {'color': 'green', 'points': 5, 'power': 50}

(a)  

79.

Can you add new key-value pairs to dictionaries?

a)

Yes

b)

No

80.

Does python allow you to loop through a dictionary?

a)

Yes

b)

No

81.

What method can we use to print all the key-value pairs of a dictionary as a list?

a)

items()

b)

keys()

c)

values()

d)

set()

82.

What method can we use to loop through all the keys of a dictionary?

a)

items()

b)

keys()

c)

values()

d)

set()

83.

What method can we use to loop through all the values of a dictionary?

a)

items()

b)

keys()

c)

values()

d)

set()

84.

What function can you use to loop through all the values of a dictionary avoiding duplicated values?

a)

items()

b)

keys()

c)

values()

d)

set()

85.

What is nesting in python?

a)

It is a natural instinct experienced by many expecting mothers, most commonly in the last trimester.

b)

Are dynamic structures, and you can add new key-value pairs

to a dictionary at any time.

c)

It is to store multiple dictionaries in a list, or a list of

items as a value in a dictionary.

86.

What is the correct way to declare a function in Python?

a)

function myFunc():

b)

def myFunc():

c)

var myFunc():

d)

func myFunc():

87.

What is the correct way to call a function in Python?

a)

function myFunc()

b)

myFunc()

c)

call myFunc()

d)

myFunc.call()

88.

What is a default argument in a function?

a)

An argument that is required to call the function.

b)

An argument that is optional to call the function.

c)

An argument that is used to define the function.

d)

An argument that is returned by the function.

89.

What is a parameter in a function?

a)

A variable that is only available inside the function.

b)

A value that is returned by the function.

c)

A value that is passed to the function when it is called.

d)

A value that is stored in the function.

90.

What is the purpose of a return statement in a function?

a)

To stop the execution of the function.

b)

To print a message to the console.

c)

To return a value from the function.

d)

To define a new function.

91.

How do you define a function in Python?

a)

By using the keyword "define".

b)

By using the keyword "function".

c)

By using the keyword "def".

d)

By using the keyword "return".

92.

What is a function in Python?

a)

A loop that repeats a set of instructions.

b)

A way to store and manipulate data.

c)

A block or a piece of code that performs a specific task.

d)

A data structure that stores values.

93.

What is the hash sign?

a)

#

b)

@

c)

&

d)

*

94.

What is the representation of the hyphen?

a)

/

b)

|

c)

&

d)

-

95.

What is the representation of underscore?

a)

/

b)

|

c)

_

d)

+

96.

What is the representation of the parenthesis?

a)

<>

b)

{}

c)

[]

d)

()

97.

What is the representation of the square brackets?

a)

<>

b)

{}

c)

[]

d)

()

98.

What is the representation of the colon?

a)

,

b)

:

c)

;

d)

.

99.

What function do we use to ask for input to the user?

a)

input()

b)

len()

c)

print()

d)

list()

e)

name()

100.

What is a folder?

a)

It is an object on a computer that stores data, information, settings, or commands used with a computer program.

b)

It is an area on the computer containing other directories and files.