Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

NTRC DAY 4 QUIZ

Total questions: 20

Worksheet time: 34mins

Name
Class
Date
1.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

d)

nameList = [John, Harry, Jesse, John, Harry, Harry]

2.

List items have an index number. In the following list, which item has the index number of 3?

["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

"John"

b)

"Harry"

c)

"Jesse"

3.

Is this the correct code for a list?

register = {"Sam", "Pheobe", Georgia", Richard"}

a)

Yes

b)

No

4.
What output will this code produce?
a)
blue
b)
green
c)
red
d)
error
5.

Consider this list, what will be the highest index the list can have:

li=[1,2,3,4,5]

a)

2

b)

3

c)

4

d)

5

6.

What is the index of “grape” in the list

[“apple”, “grape”, “orange”, “watermelon”]?

a)

0

b)

1

c)

2

d)

3

7.

mylist = ["a","b"]

mylist[1] = "c"'

print(mylist)

a)

["a","c"]

b)

["a","b"]

c)

["a","b","c"]

d)

mylist

8.

In a list called "players" if you wanted to delete the item with an index of 3 which of the following examples of code would be correct?

a)

players.pop[3]

b)

players.delete(3)

c)

players.remove(3)

d)

players.pop(3)

9.

list1 = ["hello", "hey", "hi"]

print(list1)

How many items will be printed?

a)

1

b)

2

c)

3

d)

0

10.

Which of the following keywords marks the beginning of the function block?

a)

Func

b)

define

c)

def

d)

function

11.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
12.

What character should be placed at the end of the function "def" line, after the parentheses?

a)

Hashtag (#)

b)

Colon(:)

c)

Exclamation (!)

d)

Dash (-)

13.

The program above

a)

prints all the odd numbers between 1 and 20

b)

prints all even numbers between 1 and 20

c)

print all the odd numbers between 1 and 21

d)

prints all the even numbers between 1 and 21

14.
What does the print function do in python?
a)
It's a variable.
b)
It can input data.
c)
It displays something like a string or integer
d)
It loops the code.
15.
What type of loop is used when you know how many times you want to repeat something?
a)
A WHILE Loop
b)
An IF function
c)
A FOR Loop
d)
A Variable
16.

What is the output of program below?


mariana_islands = ['Saipan', 'Tinian', 'Rota']

mariana_islands.remove('Tinian')

print(mariana_islands)

a)

['Saipan', 'Tinian', 'Rota']

b)

['Tinian', 'Rota']

c)

['Saipan', 'Tinian']

d)

['Saipan', 'Rota']

17.

What is the purpose of a return statement?

a)

It prints the output of the function.

b)

It stops the function from executing further.

c)

It defines the input parameters of the function.

d)

It specifies the value to be returned by the function

18.

What is a function in Python?

a)

a) A single value representing a piece of data.

b)

b) A block of code that performs a specific task and can be reused throughout the program

c)

c) A built-in module that provides mathematical functions.

d)

d) An error that occurs when the program encounters an unexpected condition.

19.

What is the output of the expression (4+2)==6 OR 3<2?

a)

True

b)

False

20.

The "and " operator runs true if

a)
Both operands are true
b)
Either operand is true
c)
Both operands are false
d)
Either operand is false