Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Programming Concepts and Definitions

Total questions: 21

Worksheet time: 11mins

Name
Class
Date
1.

What is a function defined inside of a class called?

a)

module

b)

class

c)

attribute

d)

method

2.

Which of the following is used to define a block of code in Python?

a)

indentation

b)

keys

c)

brackets

d)

all of the above

3.

Which keyword is used to define a function in Python?

a)

function

b)

def

c)

fun

d)

define

4.

Which word describes the speed of a program's execution?

a)

recursion

b)

algorithm

c)

effectiveness

d)

efficiency

5.

Which data type determines the outcome of logical operations and stores a value of either True or False?

a)

boolean

b)

float

c)

integer

d)

string

6.

What is the term for a set of instructions that are executed to solve a problem?

a)

algorithm

b)

module

c)

function call

d)

dictionary

7.

What data type is shown in the code?

a)

list

b)

dictionary

c)

key:value pair

d)

array

8.

Classify the outlined portion in the block of code.

a)

attributes

b)

class

c)

object

d)

arguments

9.

What coding concept is shown in the outlined block of code?

a)

index values

b)

elements

c)

arguments

d)

parameters

10.

__ defines the set of attributes and methods for a particular category of object.

a)

A method

b)

A constructor

c)

A class

d)

Object-oriented programming

11.

A(n) __ loop can be used to iterate through the items in a string, list, or dictionary.

a)

while

b)

iterable

c)

forever

d)

for

12.

__ is data that a computer or device receives from a user.

a)

Typecasting

b)

Input

c)

A dataframe

d)

Output

13.

Which method below could be used to add the element, 5, to a list?

a)

.addEnd(5)

b)

.append(5)

c)

.add(5)

d)

.addLast(5)

14.

Which line of code creates a dictionary?

a)

d = { }

b)

d = {15 : "Imani", 17 : "Skylar"}

c)

d = {"Quinn" : 18, "Amir" : 16}

d)

all of the above

15.

To use functions in the random module, which line of code must be added at the top of the program?

a)

import random

b)

random.module

c)

import.random

d)

random.random

16.

What is the expected output for the program?

a)

0123

b)

0120

c)

012

d)

Error

17.

What is the expected output?

a)

cd + ef

b)

bcef

c)

cdef

d)

cd ef

18.

What will the code print?

a)

true

b)

true

false

c)

false

true

d)

true

false

true

19.

Select the correct way to empty the dictionary.

a)

del student

b)

clear.student[0:2]

c)

student.clear()

d)

student.del()

20.

Select the output.

a)

145

b)

the number 10 is not valid here

c)

the number 145 is not valid here

d)

150

21.

Which of the following won't be printed when the code runs?

a)

Current letter: h

b)

Current letter: P

c)

Current letter: o

d)

Current letter: t