wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Final-Exam

Total questions: 21

Worksheet time: 17mins

Name
Class
Date
1.
What is the word (command) used to display numbers and text on the screen?
a)
print
b)
input
c)
output
d)
command
2.
What is a variable?
a)
A box(memory location) where you store values
b)
a type of graphics
c)
Data type
d)
a type of memory
3.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
4.

What will be the output?

name = "Dave"

print (name)

a)

Dave

b)

'Dave'

c)

name

d)

(name)

5.
What Python command lets the user enter an answer to a question?
a)
answer()
b)
open()
c)
print()
d)
input()
6.
What will the output be from the following code?
print(3*4+5)
a)
27
b)
17
c)
12
d)
SyntaxError
7.

A condition is

a)

a statement that is either True or False

b)

a string

c)

an integer

d)

a list

8.
Which of the following symbols is used in Python to mean "Equal to"?
a)
=
b)
!=
c)
==
d)
>=
9.
What is printed when this program is run:
days = 5 
if days > 6:  
   print(“Month”)

else:  
   print(“Week”)
a)
Month
b)
Week
c)
Day
d)
4
10.

Which of the following input commands would allow the user to receive and store a character from the keyboard?

a)

character = input("Please enter a character:")

b)

character = int(input("Please enter a character:"))

c)

character = float(input("Please enter a character:"))

d)

character = bool(input("Please enter a character:"))

11.
Which statement correctly assigns the string "Tanner" to the variable name?
a)
name  = print( "Tanner")
b)
input("Tanner")
c)
name = "Tanner"
d)
name = input("Tanner")
12.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
13.

The punctuation requirements for printing a string in Python are:

a)

( ) , ! and " "

b)

( ) and !

c)

( ) and " "

d)

" " and !

14.

name=input("What is your name? ")

print("Your name is " + name)

What will be displayed if the user types in "Bob"?

a)

Your name is name

b)

name

c)

Bob

d)

Your name is Bob

15.

What will print to the screen when the following program is run?


number = 5

greater_than_zero = number > 0

print(type(number))

a)

5

b)

True

c)

<type ‘int’>

d)

<type ‘bool’>

16.

What will the following program print when run?


number_one = 5

number_two = 10


if number_one == 5:

print(1)

if number_one > 5:

print(2)

if number_two < 5:

print(3)

if number_one < number_two:

print(4)

if number_one != number_two:

print(5)

a)

1

b)

1

3

5

c)

1

4

d)

1

4

5

17.

What will the following program print when run?


number_one = 5

number_two = 10


if number_one == 5:

print(1)

elif number_one > 5:

print(2)

elif number_two < 5:

print(3)

elif number_one < number_two:

print(4)

elif number_one != number_two:

print(5)

else:

print(6)

a)

1

b)

1

3

5

c)

1

4

d)

1

4

5

18.

What does this program print?


height = 65

gender = "female"


if height < 62:

print "You are below average height"

elif height > 69:

print "You are above average height"

else:

print "You are average height"

a)

You are below average height

b)

You are above average height

c)

You are average height

d)

You are below average height

You are above average height

19.

What is output when the code runs?

a)

Hi!

Have A Nice Day

b)

Hi!

c)

Good Afternoon

d)

Good Afternoon

Have a Nice Day

20.

What does the following Python code snippet print?

x = 20

if not x > 20:

print("x is not greater than 20")

else:

print("x is greater than 20")

a)

x is not greater than 20

b)

x is greater than 20

21.

How do you insert COMMENTS in Python code?

a)

/*this is a comment

b)

//this is a comment

c)

#this is a comment