wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Basics

Total questions: 25

Worksheet time: 12mins

Name
Class
Date
1.

What is the Return type of input() function?

a)

Int

b)

float

c)

String

d)

List

2.
a)

1

b)

2

c)

3

d)

4

3.
a)

1

b)

4

c)

10

d)

11

4.

Is python an interpreter or compiler programming language?

a)

Compiler

b)

Interpreter

5.

What will be the output?

name = "Dave"

print (name)

a)

Dave

b)

'Dave'

c)

name

d)

(name)

6.
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")
7.

Evaluate the following expression:

"dog" < "Dog"

a)

They are the same word

b)

True

c)

False

8.

For strings, the + operator represents

a)

Concatenation

b)

Addition

c)

Appending

d)

Recantation

9.

What will this code do?

a)

Print Numbers 1-11

b)

Print Numbers 1-10

c)

Print Numbers 2-10

d)

Print Error

10.

What sort of loop is this?

a)

Count Controlled

b)

Condition Controlled

11.

What will this code print?

a)

Print the word 'letter'.

b)

Print a user input on one line.

c)

Print a user input one letter at a time.

d)

Print an Error.

12.

Which of these is NOT a loop in python?

a)

for loop

b)

while loop

c)

nested loop

d)

if loop

13.

Which of these operators means EQUAL TO?

a)

'='

b)

'=>'

c)

'<='

d)

'=='

14.

What will be the output of this code?

a)

1,2,3,4,5,6,7,8,9,10,11,12

b)

0,2,4,6,8,10

c)

2,4,6,8,10,12

d)

2,4,6,8,10

15.
What letter will be printed on the screen after running this code:
a)
e
b)
x
c)
t
d)
Nothing prints
16.
In the following code, "city" is an example of a what?
a)
List
b)
Loop
c)
Variable
d)
Array
17.

Each item in a string has an "address" or index. The first index in a Python string is what?

a)

0

b)

1

c)

a

d)

A

18.
What output will this code produce?
a)
Exeter
b)
4
c)
6
d)
city
19.

Returning a range of characters (part of a string) is done using which syntax?

a)

Slice

b)

Splice

c)

Cut

d)

Select

20.

What is the output from this code?

a)

ell

b)

llo

c)

ello,

d)

Hello

21.

What is the output from this code?

a)

, W

b)

Wor

c)

orl

d)

lro

22.

Look at the following code, what will it generate

a)

1,2,3,4,5,6,7,8,9,10,11,12

b)

0,1,2,3,4,5,6,7,8,9,10,11,12

c)

1,2,3,4,5,6,7,8,9,10,11,12,13

d)

0,1,2,3,4,5,6,7,8,9,10,11,12,13

23.

What does the following program display?

a)

1,2,3,4

b)

1,2,3,4,5

c)

counter,counter,counter,counter,counter

d)

0,1,2,3,4,5

24.

When do you know when you come to the end of the loop?

a)

Its states End loop

b)

The command End is given

c)

The indentation stops

25.

if you wished a loop to repeat 3 types whwt should you use?

a)

For counter in range(0,5):

b)

For counter in range(1.3):

c)

For counter in range(0.3):