wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python basics

Total questions: 22

Worksheet time: 11mins

Name
Class
Date
1.

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

a)

input

b)

print

c)

output

d)

display

2.

The number or word we give to a variable

a)

Information

b)

key

c)

value

d)

data

3.

What is a variable?

a)

A box(memory location) where you store values

b)

Data type

c)

Data structure

d)

Value

4.

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!)"

5.

x = 5

y = 6

print("x*y")

The code above displays the following:

a)

11

b)

x*y

c)

30

d)

Syntax Error

6.

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

a)

=

b)

!=

c)

~

d)

==

7.

Which of the following is not a string?

a)

new_var = "True"

b)

new_var = False

c)

new_var = "2.4"

d)

new_var = "5+2j"

8.

Which of these is the best description of a list in Python?

a)

A list is a lot of variables

b)

A list is a lot of numbers

c)

A list is a collection of data that has an order and can be changed

d)

A list is a collection of data that cannot hold duplicated data and cannot be changed

9.

What is the output of Following code?

List = ['spam', 2.0, 5, [10, 20]]

print(List[2])

a)

2.0

b)

[10,20]

c)

5

d)

20

10.

What is the output of the following code?

list = []

list.append(1)

list.append(2.0)

list.append("vk")

print(list)

a)

['vk', 1, 2.0]

b)

Error

c)

[1, 2.0, 'vk']

d)

No Output

11.

What will the output be from the following code? print("Hello" + 2 + "world")

a)

Hello 2 world

b)

Hello2world

c)

TypeError

d)

HelloHelloworld

12.

Joining elements together to make a string is called what?

a)

Connecting

b)

Combining

c)

stringing

d)

Concatenation

13.

What syntax can you use to insert a line break between strings so that they appear over multiple lines?

a)

\\

b)

n

c)

\t

d)

\n

14.

To insert an the string "Pedro" in the first position of a the nameList we use

a)

nameList.append("Pedro, 1")

b)

nameList.insert("Pedro",0)

c)

nameList.insert(1, "Pedro")

d)

nameList.insert(0, "Pedro")

15.

What is the output of the following code?

list = [1,2,3,4,5,6,7,8,9,10]

print(list[::-1])

a)

[1,3,5,7,9]

b)

[10, 8, 6,4,2]

c)

[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

d)

No Output

16.

What is the output of the following code?

list = [1,2,3,4,5,6,7,8,9,10]

print(list[::-3])

a)

[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

b)

Compilation error

c)

[8,9,10]

d)

[10, 7, 4, 1]

17.

What will be the output of the following Python code?

x = {4,7,8,8,9}

print(x)

a)

{4,8,8,9,7}

b)

{4,9,8,7}

c)

{4,7,9}

d)

Error

18.

The result of this program:

Friday = False

if Friday:

print "Jeans day!"

else:

print "Uniform day"

a)

Jeans day!

b)

Friday

c)

Uniform day

d)

Error

19.

What is the output of the following code : print 5//2

a)

2

b)

2.5

c)

2.0

d)

1

20.

What is the output of this expression, 3*1**3?

a)

27

b)

9

c)

3

d)

1

21.

In python,a function is defined using the following keyword

a)

Fun

b)

function_name

c)

func

d)

def

22.

Who is the inventor of python language?

a)

Dennis Ritchie

b)

Bjarne Stroustrup

c)

Guido van Rossum

d)

James Gosling