wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Chap 2-4

Total questions: 42

Worksheet time: 29mins

Name
Class
Date
1.

What will print to the screen?


age = 5

print(type<age>)

a)

<type 'float'>

b)

<type 'int'>

c)

<type 'bool'>

d)

<type 'string'>

2.

What will print to the screen?


age = 5

young = age < 20

print(type<young>)

a)

<type 'float'>

b)

<type 'int'>

c)

<type 'bool'>

d)

<type 'string'>

3.

What will be the output of this program?


a)

A
B
C

b)

A

c)

I need to work on my grade.

d)

prints nothing.  The program doesn't compile.

4.

What will the result of this code be?


var = True and True


print(var)

a)

True

b)

False

c)

var

d)

none of these

5.

What will the result of this code be?


var = True or True


print(var)

a)

True

b)

False

c)

var

d)

none of these

6.

What will the result of this code be?


var = True and False


print(var)

a)

True

b)

False

c)

var

d)

none of these

7.

What is the result of this code?

a)

8

b)

8

9

10

c)

8

9

10

11

d)

8

11

e)

8

10

8.

What is the result of this code?

a)

Issue Driver's License

b)

Almost eligible for Driver's License

c)

No requirements met.

d)

none of these

9.
What will the lines of code print?
a)
A
b)
B C
c)
A B C
d)
A C
10.

What is the output?

a)

more than 7

b)

more than 23

c)

spam

d)

7

11.
Which statement will check to see if a is equal to b?
a)
if a == b
b)
if a = b:
c)
if a != b:
d)
if a == b:
12.
What will the following lines of code print?
a)
A
b)
B C
c)
A C
d)
Nothing, it will return an error.
13.
What will the lines of code print?
a)
A
b)
B C
c)
A B C
d)
A C
14.

If you want to test more than one condition (chained condition), what do you use after if statement?

a)

elif

b)

else

c)

ifif

d)

else if

15.

Which symbol means "not equal to"?

a)

==

b)

<=

c)

>=

d)

!=

16.

Data type that can only be true or false

a)

int

b)

string

c)

boolean

d)

float

17.

Which character must be at the end of the line for if?

a)

:

b)

;

c)

.

d)

{

18.

Which of the following is true about if-elif-else statements?

a)

After using if, an elif can be added as an additional test

b)

The bodies of multiple elif’s can run

c)

You can use an elif without an if

d)

Code in an else body runs if all the tests before it were True

19.

What is the output of this code?

w=50

q="Cathy"

a)

50

b)

50

Cathy

c)

No Output

20.

G="Joyce"

G='Joyce'

print G


This code will display what?

a)

Joyce

b)

No Output

c)

joyce

21.

Given this code:

M=25

M="Charlotte"

print(M)


What is the output?

a)

Charlotte

b)

"Charlotte"

c)

25

22.

What will this print to the screen?


print(2*4)

a)

2*4

b)

8

c)

4

d)

error

23.

What do we use variables for?

a)

To store data

b)

Print data

c)

Produce functions

24.

To get the users input what function do we use?

a)

input

b)

input<>

c)

input()

d)

INPUT()

25.

What does int() represent?

a)

internet

b)

integer

c)

intel

d)

input

26.

Choose what / performs.

a)

multiply

b)

add

c)

subtract

d)

divide

27.

Why would I get a syntax error?

a)

Line 1 doesn't make sense

b)

Line 2 needs to be indented

c)

No need for quotation marks on line 2

d)

No such thing as an if statement

28.

What would be printed to the screen for print(z)?

a)

Orange

b)

Banana

c)

Cherry

d)

Hello World!

29.

What will be printed to the screen?

a)

5

b)

10

c)

5 + 10

d)

15

30.
What will the output be from the following code?
print("Hello" + str(2) + "world!")
a)
Hello world! Hello world!
b)
Hello2world!
c)
Hello Hello world! world!
d)
SyntaxError
31.

Which statement prints 7 (Select 2 answers)

a)

print 7

b)

print("7"

c)

print("7")

d)

print(3 + 4)

32.

Which of the following is a command to have a message appear on the screen?

a)

print

b)

write

c)

msg

d)

input

33.

Which of the following is used in Python to give a value to a variable

a)

:=

b)

==

c)

=

34.

How do you create a variable with the numeric value 5?

a)

Both are correct

b)

x=5

c)

x=int(5)

35.

How do you insert COMMENTS in Python code?

a)

/*This is a comment*/

b)

#This is a comment

c)

//This is a comment

d)

Any of the Above

36.

What can be used to store information and values so that it can be used later?

a)

Graphic

b)

Variable

c)

Print

d)

Output

37.

What will be the output?

name = 'Dave'

print (name)

a)

name

b)

print

c)

Dave

d)

error

38.

What would print (10 + 16) produce?

a)

10

b)

16

c)

24

d)

26

39.

What is a input?

a)

To plug in something.

b)

A function that allows us to ask the user to enter some data.

c)

Data displayed on a screen.

d)

A function

40.

Why do we learn Python?

a)

It's a really big snake

b)

It's the name of a very funny comedy show

c)

It's simple and easy to learn

d)

It's so rare that no one else knows it

41.
What will the output be from the following code?
print("Hello world!")
a)
SyntaxError
b)
Hello world!
c)
"Hello world!"
d)
print(Hello world!)
42.

Whata data type would you use to store the number of students in a classroom

a)

boolean(true/ false)

b)

float (decimal numbers)

c)

integers(No decimal/ whole numbers)

d)

string(words/ letters)