wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Codehs

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which Python code segment will display “Hello, world!” on the screen?

a)

"Hello, world!"

b)

print "Hello, world!"

c)

print("Hello, world!")

d)

display Hello, world!

2.

What does the following Python code display?

print("Hello")

print("World")

a)

HelloWorld

b)

Hello

World

c)

Hello World

d)

"Hello"

"World"

3.

What type is the following variable?

x = "Hi there"

a)

boolean

b)

integer

c)

float

d)

string

4.

What does the following Python program print?

x = "I am"

y = 6

z = "feet tall"

print(x)

print(y)

print(z)

a)

I am6feet tall

b)

I am 6 feet tall

c)

I am

6

feet tall

d)

x

y

z

5.

What is the type of the variable x in the following Python program?

x = input("Enter a number from 1-10: ")

a)

integer

b)

float

c)

string

d)

The type cannot be determined

6.

What does the following Python program print?

x = 9 + 6 / 3 * 2 - 1

print(x)

a)

12

b)

9

c)

14

d)

20

7.

Which of the following operators is used for exponentiation (exponents) in Python?

a)

^

b)

(( ))

c)

**

d)

%

8.

What does the following Python program print?

x = 12 % 4

print(x)

a)

3

b)

0

c)

3R0

d)

36

9.

Which of the following Python programs will NOT run?

a)

x = 4

print(x + 5)

b)

x = 4

y = 5

print(x + y)

c)

x = 4

y = 5.5

print(x + y)

d)

x = 4

y = "hi"

print(x + y)

10.

Which of the following best describes the main purpose of comments?

a)

Comments warn the people running the program about potential problems with the program.

b)

Comments create better spacing in programs.

c)

Comments describe your program so other people can read it more easily.

d)

Comments allow you to test just the portion of the code written in a comment before testing the whole program.