wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Basics Python

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which commands might be correct? (Multiple answers)

a)

random. random(1, 10)

b)

print(random.random( ))

c)

print(random. randint(1,10))

d)

import.random(2.7)

2.

How do you define(assign) variables?

a)

var="String"

b)

func==Hello

c)

var : 123

d)

word= Hello

3.

Which one does take you to next line?

a)

\t

b)

\n

c)

/n

d)

\\

4.

What is the word (command) used to display numbers and text on the screen?

a)

Input

b)

Output

c)

Print

d)

Command

5.

What symbol is used in python to assign values to a variable?

a)

:

b)

*

c)

=

d)

==

6.

Which of these would work as a piece of code?

a)

if string="Dove"

b)

if string=="Dove"

c)

IF string="Dove":

d)

if string=="Dove":

7.

What is the end after if statements?

a)

if

b)

Elif

c)

Else

d)

While

8.

Which of the following is a correctly-formatted comment?

a)

*Comment

b)

"Comment"

c)

#comment

d)

(comment)

9.

A line of text that Python won't try to run as code

a)

Integer

b)

Comment

c)

Strings

d)

Input

10.

A data type than can have one of two values: True or False

a)

Boolean

b)

Basic Calculation

c)

For

d)

While

11.

Data type for a whole number

a)

Float

b)

Boolean

c)

Integer

d)

String

12.

A Python data type that holds positive and negative whole numbers

a)

String

b)

int

c)

str

d)

input

13.

The Boolean operator that returns true if EITHER of its operands are true

a)

and

b)

or

c)

not

d)

equal

14.

print(boolean(None, "String", False, "False", 0,"value")

What is the output?

a)

False, True, True, False, False, True

b)

False, True, False, True, False, True

c)

True, True, False, False, True, False

d)

False, False, True, True, False, True

15.

Which of the following sequences would be generated by the given line of code?

range (10, 0, -5)

a)

10,9,8,7,6,5

b)

10, 5

c)

0, 5, 10

d)

10, 5, 0

16.

In a Python program, what would be the increment value for the looping variable in the FOR LOOP code?

for x in range (25, 10, -5)

a)

10

b)

-5

c)

25

d)

5

17.

Which of the following pieces of code defines a list of all the numbers from 4 to 12?

a)

range(4,12)

b)

range(4, 13)

c)

range( 3,12)

d)

range(3, 13)

18.

// means:

a)

two times division

b)

integer division

c)

exact division with floating number

d)

Put a slash

19.

What does symbol % do?

a)

Integer exact division

b)

Percentage

c)

Division

d)

Remainder

20.

What does "\t " make?

a)

Goes to next line

b)

Horizontal space between two strings

c)

Give a title

d)

Add a slash