wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python introduction

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What command will display the text 'Hello world!' on the screen?

a)

print(Hello world!)

b)

print "Hello world!"

c)

print("Hello world!")

d)

print = "Hello world!"

2.

What command will ask the user his/her age correctly?

a)

age = input("How old are you?")

b)

age = input(How old are you?)

c)

input("How old are you?") = age

d)

how_old_are_you = input()

3.

What function will convert a number to a string?

a)

int()

b)

str()

c)

chr()

d)

ord()

4.

What is the result of this command: print ("5" + "3")

a)

8

b)

"8"

c)

"5" + "3"

d)

53

5.

Which function will convert a string containing only digits to a number?

a)

int()

b)

srt()

c)

chr()

d)

ord()

6.

Which conditional statement will be executed if the variable x is less than 20?

a)

if x > 20:

b)

if x <> 20:

c)

if x == 20:

d)

if x < 20:

7.

Which of these tests checks if the variable x is the same as 'Hello'?

a)

x = "Hello"

b)

x != "Hello"

c)

x == "Hello"

d)

x <> "Hello"

8.

What is the effect of the # character?

a)

It tells Python that this is a very important line of code.

b)

It tells Python to ignore the rest of the line.

c)

It tells Python to tweet when this line of code is executed.

d)

It does nothing. Python ignores this character

9.

What is a variable (in Python)

a)

A data "storage" that you can change

b)

A data "storage" that you cannot change

c)

A coding technique

d)

A special file

10.

What does the "input()" function do?

a)

Allows users to change the program

b)

Converts data types

c)

Allows users to solve a task

d)

Allows users to enter data

11.

What data type is 3.95?

a)

Integer

b)

Float

c)

String

d)

Boolean

12.

What output should this code give if the user enters the value 70?

a)

Pass

b)

Fail

c)

Distinction

d)

Merit

13.

What is the output of this program?

a)

22

b)

50

c)

38

d)

Nothing, it will not be executed due to errors in the code.

14.

myName = input()

Is myName a string, a function, a variable, or a method?

a)

string

b)

function

c)

variable

d)

method

15.

How will we fix this code?

a)

Remove the ' ' around Bob

b)

Remove the '=' character

c)

Remove the ( ) around Name

d)

Make 'Name' lowercase