wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Basics 3

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

To display something on the screen, use this command:

a)

print()

b)

Print()

c)

screen()

d)

write()

e)

display()

2.

To display the following on screen

Hello World!

the following command should be used:

a)

print(Hello World!)

b)

print("Hello World!")

c)

print("Hello World" + !)

d)

print"(Hello World!)"

3.
Which symbol do we use if we want to add a comment to our code?
a)

@

b)

#

c)

*

d)

&

4.
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
5.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
6.

Which operator performs a division?

a)

-

b)

+

c)

/

d)

*

7.

Which operator checks if a value is equal to another value?

a)

+

b)

=

c)

==

d)

!=

8.

Which operator checks if a value is not equal to another value?

a)

==

b)

+=

c)

!=

d)

=

9.
If you want more than one option for your code, what do you use (after if)?
a)
elif
b)
else
c)
ifif
10.

The character that must be at the end of the line for if, while, or for statements, and etc.

a)

:

b)

;

c)

.

d)

,

11.
Converts a number to a string
a)
str()
b)
int()
c)
parseInt()
d)
convert
12.
a data type than can have one of two values: True or False
a)
boolean
b)
variable
c)
modulo
d)
interpreter
13.
Which of the following is a float?
a)

new_var = 1234

b)

new_var = True

c)

new_var = 1.234

d)

new_var = "True"

14.
Which of the following is not a string?
a)

new_var = "True"

b)

new_var = "3123"

c)

new_var = "3.123"

d)

new_var = False

15.
Numbers with a decimal point belong to a type called...
a)
pointing
b)
integers
c)
decimal
d)
float
16.

When you have an error in your code what is the term to summarize finding and fixing that error?

a)

Error checking

b)

Debugging

c)

Syntax finder

d)

Error finder

17.
Why is it called 'Python'?
a)
The guy who created it loves snakes
b)
The guy who created it loves Monty Python films
c)
You can create a game on python called snake
d)
It was created by someone called Mr Python
18.
Python is an example of a....
a)
Text-based programming language
b)
Object orientated programming language
c)
language written in java script
d)
Visual-based programming language
19.

Which of the following is correct?

a)

Comments are for programmers to better understand the program.

b)

Python Interpreter ignores comments.

c)

You can write multi-line comments in Python using triple quotes, either ''' or """.

d)

All of the above

20.

What is used to take input from the user in Python?

a)

cin

b)

scanf()

c)

input()

d)

<>

21.

When would a while loop be a better control structure to use than a for loop?

a)

when the repeat is based upon the user's input

b)

when you do not know how many times something will need to repeat

c)

when you need to repeat something 10 times

d)

when you need to repeat multiple commands

22.

Which of the following for loops will give the same values for i as the loop below?

for i in range(10):

a)

for i in range(11, 0):

b)

for i in range(0, 10):

c)

for i in range(10, 0, -1):

d)

for i in range(0, 12, 1):

23.

Which of the following for loops would print the following numbers?

0

1

2

3

4

a)

for i in range(4):

print(i)

b)

for i in range(1,4,1):

print(i)

c)

for i in range(5):

print(i)

d)

for i in range(0,4,1):

print(i)

24.

Three of the for loops below will provide identical values for i. Which for loop has a value that will not match the others?

a)

for i in range(0,10):

b)

for i in range(10):

c)

for i in range(10,0,1):

d)

for i in range(0,10,1):

25.

Which of the following while loops would continue to loop as long as num has values between the range of 5-15, exclusive?

a)

while num>15 and num<5:

b)

while num<15 or num<5:

c)

while num<=15 and num>=5:

d)

while num<15 and num>5: