wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python_3P_Basics

Total questions: 31

Worksheet time: 18mins

Name
Class
Date
1.

How many variables are there in this program?

a)

2

b)

3

c)

4

d)

5

2.

What would be the output of this program if the user input was 10?

a)

22.04

b)

220.4

c)

2204

d)

Error wrong data type

3.

What would be the output of this program if the user entered "yes" then "what"?

a)

Enjoy your day

b)

it is too windy for an umbrella

c)

Take an umbrella

d)

Error

4.

What data type represents a decimal number?

a)

Float

b)

Int

c)

Boolean

d)

String

5.

Which of these is the correct code for creating a list of names?

a)

nameList = John, Harry, Jesse, John, Harry, Harry

b)

nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")

c)

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

d)

nameList = [John, Harry, Jesse, John, Harry, Harry]

6.

List items have an index number. In the following list, which item has the index number of 3?

["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

"John"

b)

"Harry"

c)

"Jesse"

7.

Which of these pieces of code would return the name "Harry" from the following list?

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

nameList()

b)

nameList[1]

c)

NameList(4)

d)

nameList["4"]

8.

The list needs one more name added to the end - "Felipe". Which piece of code below would do this?

nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

nameList.append(Felipe)

b)

append(nameList,"Felipe")

c)

nameList.append["Felipe",7]

d)

nameList.append("Felipe")

9.
What output will this code produce?
a)
blue
b)
green
c)
red
d)
error
10.

Output of this code?

a)

[2,4,6,8,10]

b)

['2','4','6','8','10']

c)

[0,2,4,6,8]

d)

[10,8,6,4,2]

11.

What would the output of the program be?

thisList = ["square", "circle", "triangle", "octagon"]

if "triangle" in thisList:

print("Yes, 'triangle' is in the list")

else:

print("No triangle here!")

a)

Yes, 'triangle' is in the list

b)

"No triangle here!"

12.
If you want to create an empty list called colours, which of the following pieces of code is correct?
a)
colours = [ ]
b)
colours = ( )
c)
colours = { }
d)
colors = [ ]
13.
What output will this code produce?
a)
Exeter
b)
4
c)
6
d)
city
14.
What will print?
a)
nothing
b)
5
c)
6
d)
an error message
15.

What does the following code output?

a)

11, 9

b)

16, 16

c)

None, None

d)

225, 117

16.

What will be displayed?

a)

Nothing

b)

5, 6, 7, 8, 9

c)

1, 2, 3, 4, 5

d)

1, 1, 1, 1, 1

e)

5, 6, 7, 8, 9, 10

17.

What is the error in this code?

a)

incorrect variable name

b)

incorrect indentation

c)

incorrect speech marks

d)

incorrect loop

18.

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

19.

What is the output?

a)

next

stop

b)

next

c)

stop

d)

syntax error - program doesn't work

20.

What will the output be for the code shown here?

a)

3,2,1,0

b)

0,1,2,3

c)

3,2,1

d)

1,2,3

21.

¿Cuál de las siguientes opciones sería el contenido de una variable de tipo String?

a)

Hola

b)

P

c)

"Soy una variable"

d)

18.9

22.

Forma correcta para declarar la condición if

a)

if a<18;

b)

if a<18:

c)

if a<18 {

23.

Se pueden escribir tantos bloques elif como sean necesarios.

a)

Falso

b)

Verdadero

24.

¿Cuál es el resultado esperado al ejecutar el siguiente programa?

a)

b)

c)

d)

25.
  1. ¿Cuál es la forma correcta de escribir un ciclo while en Python?

a)

A) while i < 10:

b)

B) for i in range(10):

c)

C) do while i < 10:

d)

D) repeat until i < 10:

26.

Valor de la siguiente operación: 5 + 8 + 3

a)

15

b)

15.0

c)

16

d)

16.0

e)

Error

27.

¿Cuál de las siguientes opciones es una variable de tipo Float?

a)

-7.12

b)

5

c)

'8.2'

d)

10.4

28.

Complete el comando de python en el siguiente programa

a)

elseif

b)

elif

c)

else

d)

else if

29.

¿Cual de las siguientes opciones es correcta?

a)
b)
c)
d)
30.

¿Con qué palabra se especifica el valor que queremos que la función nos devuelva?

a)

return

b)

result

c)

def

d)

back

31.

¿Cuál es la palabra correcta para definir funciones en Python?

a)

function

b)

func

c)

def

d)

define