Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PYTHON BASIC

Total questions: 18

Worksheet time: 9mins

Name
Class
Date
1.

Which of the following is a command to have a message appear on the screen?

a)

print

b)

write

c)

msg

d)

input

2.

Pick the Python command used to make the user type in some data (input the data)

a)

get

b)

input

c)

int

d)

float

3.

Which of the following Python command can be used for WHOLE numbers?

a)

input

b)

int

c)

float

d)

print

4.

Which of the following is a Python command to work with DECIMAL numbers?

a)

input

b)

int

c)

float

d)

print

5.

What would be printed by the command

print('12-5')

a)

12-5

b)

'12-5'

c)

7

d)

'7'

6.

Which of the operators do we use if we want at least one condition to be true?

a)

and

b)

or

c)

else

d)

not

7.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
8.

Which of the following is used in Python to give a value to a variable

a)

:=

b)

==

c)

=

9.

What is the result of the following operation?

print(1 + 4*3)

a)

11

b)

12

c)

13

d)

15

10.

What is the value(?) if theoutput is 12

x = 5

y = ?

print (x+y)

a)

"7"

b)

=7

c)

7

d)

/7

11.

What is a variable?

a)

A named block of memory, used whilst a program is running to store data.

b)

A named block of memory, where the results of a program get stored once it has been closed down.

c)

A block of computer memory that gets permanently named after the variable, even when the program is closed down.

d)

A process within the cpu, that is given a specific name by the program, so it is easier to identify.

12.

Which one is NOT a valid variable name?

a)

my_var

b)

myvar

c)

_myvar

d)

my var

13.

What is the correct file extension for Python files?

a)

.py

b)

.pt

c)

.pyt

d)

.pyth

14.

How do you create a variable with the numeric value 5?

a)

Both are correct

b)

x=5

c)

x=int(5)

15.

What will be the output of this code?


x = “2”

y = “4”

z = int(x) + int(y)

print(z)

a)

6

b)

6.0

c)

both are correct

16.

The input function prompts the user for input, and returns what they enter as a string

a)

TRUE

b)

FALSE

17.

Below is the code for printing student's name. What is the best answer to put in (?)


name = student

print ( ? )

a)

text

b)

print

c)

name

d)

student

18.

What will be the output when a user enters WILLIAM


name = input("Enter your name: ")

print("Hello, " + name)

a)

Hello name

b)

Hello William

c)

Helloname

d)

Hello WILLIAM