wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Year 8 CAT

Total questions: 40

Worksheet time: 3600secs

Name
Class
Date
1.

What will be the result of the code below

x, y, z = "Orange", "Banana", "Cherry"

print(x)

a)

"Orange", "Banana", "Cherry"

b)

"Banana", 

c)

"Banana", "Cherry"

d)

"Orange"

2.

x = y = z = "Mango"

print(x)

a)

print(x)

b)

"Mango"

c)

banana

d)

orange

3.

What is the result of the code below?

fruits = ["apple", "banana", "cherry"]

x, y, z = fruits

print(z)

a)

"apple"

b)

 "cherry"

c)

banana

d)

None

4.

The Python print statement is often used to output variables.

a)

True

b)

False

c)

None

5.

Run the code below

x = "awesome"

print("Python is " + x)

a)

"Python awesome is "

b)

"awesome is "

"Python

c)

Python is awesome

d)

None

6.

x = "Python is "

y = "awesome"

z = x + y

What code will you write to bring out the result of z

a)

print(z)

b)

print(x)

c)

print(y)

d)

print(yz)

7.

x = "awesome"

def myfunc():   

print("Python is " + x)

myfunc()

a)

"Python is

b)

"Python is awesome"

c)

"Python is banana"

d)

"Python is apple"

8.

When you create a variable inside a function, that variable is local, and can only be used inside that function.

a)

True

b)

False

c)

None

d)

All

9.

What type of variable is this?

myVariableName = "John"

a)

Pascal Case

b)

Camel Case

c)

Snake Case

d)

All

10.

Is this variable name acceptable?

2myvar = "John"

a)

Yes

b)

No

c)

I dont know

11.

Change the following line of code to a comment.

print("Hello World")

a)

+print("Hello World")

b)

#print("Hello World")

c)

&print("Hello World")

d)

print("Hello World")

12.

Which of the following Python operators is used for variable assignment?

a)

=

b)

+

c)

/

d)

*

13.

Which of the following is not a data type in Python?

a)

Integer

b)

String

c)

Float

d)

Figures

14.

What do we use the float() function for?

a)

To change a value to float

b)

To change a value to a string

c)

To change a value to an integer

d)

None of the Above

15.

What is the output of the following code on the Python Shell?

a = 10

b = 2

c = a/b

print(c)

a)

2

b)

4

c)

1

d)

5

16.

What is the output of the following code on the python shell 5+3-5?

a)

3

b)

-3

c)

5

d)

-5

17.

What type of comment can you see below?

#This is a comment

#written in

#more than just one line

a)

Line comment

b)

commenters

c)

comment

d)

Multi Line comment

18.

________ is a container for storing data.

a)

Comment

b)

Variable

c)

Casting

d)

None

19.

One of the following is the reason for adding comment to lines of codes.

a)

To make to code run faster

b)

To make the code readable

c)

To make the code looks funny

d)

None of the above

20.

What was your first code written in this program?

a)

print("Hello,World")

b)

Print ("Hello, World")

c)

print ("Hello, World)

21.

str(3)

int(5 .5)

The codes above are examples of ______.

a)

Line Comment

b)

Variable

c)

Variable names

d)

Casting

22.

Look at the code below

A=5

B=10

A=7

print(A+B)

What will be the output?

a)

27

b)

17

c)

15

d)

10

23.

Is this a legal variable name?

my_name

a)

True

b)

False

c)

Not sure

24.

Is variable name case sensitive?

a)

Yes

b)

No

25.

String variables can be declared either by using single or _______ quotes.

a)

Multiple

b)

Double

c)

Frequent

d)

Lonely

26.

FOR loops are

a)

loops which run an unknown number of times

b)

loops which run for a specific number of times

c)

the same as if statements

d)

not part of programming

27.

WHILE loops are

a)

loops which run an unknown number of times

b)

loops which run for a specific number of times

c)

the same as if statements

d)

not part of programming

28.

A condition is

a)

a statement that is either True or False

b)

a string

c)

an integer

d)

a list

29.
To repeat until a particular condition is true use
a)
while loop
b)
for loop
c)
if loop
d)
indentation
30.
The condition for a while loop to continue could include which of the following?
a)
While something equals something
b)
While something is greater than something
c)
While something is True
d)
All of these
31.

Which kind of loop would be used?


I need a program that will keep letting me add money to a piggy bank until I get to £100.

a)

FOR Loop

b)

WHILE Loop

32.

Which kind of loop would be used?


I need a program that will keep letting me add a monthly payment for 12 months.

a)

FOR Loop

b)

WHILE Loop

33.

Which kind of loop would be used?


I need a guessing game program that will let me keep guessing until I get the right answer.

a)

FOR Loop

b)

WHILE Loop

34.

Which kind of loop would be used?


I need a revision program that will run through revision questions 4 times.

a)

FOR Loop

b)

WHILE Loop

35.

Look at the following code, what will it generate

a)

1,2,3,4,5,6,7,8,9,10,11,12

b)

0,1,2,3,4,5,6,7,8,9,10,11,12

c)

1,2,3,4,5,6,7,8,9,10,11,12,13

d)

0,1,2,3,4,5,6,7,8,9,10,11,12,13

36.

What does the following program display?

a)

1,2,3,4

b)

1,2,3,4,5

c)

counter,counter,counter,counter,counter

d)

0,1,2,3,4,5

37.
a)
b)
c)
d)

1,2,3,4

38.

what is the name of the variable used in the following code?

a)

counter

b)

print

c)

for

d)

#

39.
What is the name of the environment in Python that write your programs and then test them out?
a)
Shell
b)
Window
c)
IDLE
d)
CLI
40.
What symbol do you use to make a comment in Python?
a)
@
b)
¬
c)
;
d)
#