wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Basics

Total questions: 9

Worksheet time: 6mins

Name
Class
Date
1.

What does the print() function do?

a)

Connects to the nearest printer and prints the current file

b)

Displays the written contents of the entire file

c)

Displays the output of the code in the function

d)

Displays the code written in the function

2.

What are the pieces of a for loop?

a)

Colon; :

b)

Parenthesis; ()

c)

Range function; range(int)

d)

Placeholder variable; count

e)

While keyword; while

3.

In your own words, explain the problem(s) with this code

x = "Akash"

print("Knock knock)

print("Who's there?")

print("It's " + y)

4 lines
4.

What are the errors in this code?

Select all that apply.

var1 = "A"

2nd_var = "B#"

if var1 = 2nd_var:

print("Harmony")

else:

print("Discord")

a)

Nothing is wrong

b)

Invalid variable name

c)

Invalid use of special characters in String

d)

Incorrect Boolean comparison operator

e)

Incorrect syntax for if statement

5.

What must be added? (Look carefully)

pageCount = 500

if pageCount > 500:

print("This book 500 pages or more!")

else:

print("Find a longer book.")

a)

Add an equal sign to the greater than sign

b)

Add the str() function to 500 in the print statement

c)

Add parenthesis to the if statement

d)

Another ! to the first print statement

6.

What do the str(), int(), and float() functions have in common? Select all that apply.

(Hint: These functions can "convert" their own types too)

a)

All can properly convert '16' without error

b)

All convert any value to a specified data type

c)

All can convert each other's types always

d)

All can properly use '42.5' without error

e)

All convert one data type to another

7.

Find the problem

counter = 0

while counter < 10:

print(counter + 1)

a)

Missing parenthesis from while function

b)

counter variable never increases

c)

Operation within print function

d)

Missing quotation marks from print function

8.

What is the main reason one would use a while loop over a for loop?

a)

While is faster because it loops on its own without a Boolean expression

b)

While can be used when the end of the loop is unknown

c)

While ends whenever the Boolean expression is False

d)

While can create infinite loops which can throw an error

9.

What did you think about using Quizizz and this quiz style?

a)

I thought it was great!

b)

I liked it.

c)

It was ok...

d)

I think we should use something else (etc. Kahoot?)

e)

Yeah... I'll pass on these.