wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Magic

Total questions: 35

Worksheet time: 24mins

Name
Class
Date
1.

The syntax of a programming language is...

a)

the rules of the language

b)

a group of variables and costants

c)

a command

2.

Python is case sensitive

a)

True

b)

False

3.

White space is used as part of the language syntax

a)

True

b)

False

4.

A string is a collection of characters

a)

True

b)

False

5.

print () is used to:

a)

print strings or do simple maths

b)

cast an integer to a string

c)

print coloured text

6.

To concatenate 2 or more strings with print () you need to use

a)

""

b)

=

c)

&

d)

+

7.

The method to cast an integer to a string is:

a)

("Hello, World")

b)

STR()

c)

\n

8.

The method to add a new line to a string is:

a)

\n

b)

\L

c)

+

d)

=

9.

What is a input?

a)

A function that allows us to ask the user to enter some data.

b)

To plug in something.

c)

Data displayed on a screen.

d)

A function

10.

What is a output?

a)

A piece of data that is shown on the screen.

b)

Data that the user enters

c)

An output

d)

A orange

11.

What function is used to output a message in python?

a)

print("")

b)

input=name

c)

print

d)

name=input

12.

What is a variable?

a)

Holds data that may change.

b)

It outputs data.

c)

It stores data.

d)

It inputs data.

13.

What is pseudocode?

a)

A planning tool that resembles code but is not code used for humans.

b)

Syntax code

c)

A programming language.

d)

A pastry.

14.
What is Concatenation?
a)
To add variables into text
b)
To add letters to numbers
15.
What will be the output?
name = 'Dave'
print (name)
a)
Dave
b)
'Dave'
c)
name
d)
(name)
16.
When you have an error in your code what is the term to summarise finding and fixing that error?
a)
Error checking
b)
Debugging
c)
Syntax finder
d)
Error finder
17.
Which of these would work as a piece of code?
a)
IF answer == "Yes":
b)
if answer == "Yes"
c)
if answer == "Yes":
d)
if answer = "yes":
18.
What button do you press to compile (run) your program so that it runs in the shell?
a)
F3
b)
F5
c)
F7
d)
F9
19.

What does the '#' allow you to do?

a)

Repeat code

b)

Comment on code

c)

Print code

d)

End code

20.

What data type is a in this code : a = "5"

a)

integer

b)

float

c)

boolean

d)

string

21.

What command do we use to tell Python to accept an input?

a)

cin

b)

input()

c)

scanf()

d)

<>

22.
To repeat a fixed number of times use a
a)
while loop
b)
for loop
c)
if loop
d)
indentation
23.
To repeat until a particular condition is true use
a)
while loop
b)
for loop
c)
if loop
d)
indentation
24.
Data type that can only be true or false
a)
int
b)
string
c)
bool
d)
float
25.
Tells the interpreter that the code which follows is a function
a)
const
b)
int
c)
def
d)
while
26.
Converts a number to a string
a)
str()
b)
int()
c)
parseInt()
d)
convert
27.

x=10

if x>11 or x==10:

print ("hello")

a)

error

b)

x is less than 11

c)

hello

d)

10

28.
What extension must you add to the end of a file when saving?
a)
.xlsx
b)
.pptx
c)
.docx
d)
.py
29.

Choose the correct answer: 5!=3

a)

if 3 greater than 5

b)

if 5 is not equal to 3

c)

if 5 is equal to 3

d)

if 5 greater than 3

30.

Choose the correct answer: 5==3

a)

if 5 is not equal to 3

b)

if 5 is less than 3

c)

if 3 is less than 5

d)

if 5 is equal to 3

31.

Choose the correct answer: 5<=3

a)

if 5 is greater than 3

b)

if 5 is equal to 3

c)

if 5 is not equal to 3

d)

if 5 is less or equal to 3

32.

What will the output be from the following code?

a = 30

b = 55

if b > a:

print("b is greater than a")

else:

print("a is greater than b")

a)

b is greater than a

b)

b

c)

a

d)

a is greater than b

33.

What will the output be from the following code?

x = 10

if x > 0:

print(x+3)

else:

print(x-3)

a)

x+3

b)

x-3

c)

13

d)

7

34.

... is a decision between two things.

a)

if / else statement

b)

if statement

c)

statement

d)

comparison operators

35.
The number or word we give to a variable
a)
Value
b)
Bug
c)
Information
d)
Text