Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Y10 - Programming EOU

Total questions: 158

Worksheet time: 2hrs 43mins

Name
Class
Date
1.

What type of data is the following?: X = "195.67"

a)

Float

b)

String

c)

Boolean

d)

Integer

2.

What type of variable is the following?: Y = False

a)

Float

b)

String

c)

Integer

d)

Boolean

3.

Variables have three things:

a)

Numeric, string, Boolean

b)

Integer, float, string

c)

name, type, value

d)

function, value, name

4.

When you want to print something to the screen you should use

a)

The keyboard to type it

b)

The computer Display

c)

A monitor

d)

a print statement

5.

print("Python " * 3); will print out what

a)

Python 3 Python 3 Python 3

b)

Python Python Python

c)

PythonPythonPython

d)

Python*3 Python*3 Python*3

6.

Which one to the following Python programs will not run?

a)

num = 4

greeting = "Hello"

print(num + greeting)

b)

grade = 98.7

letterGrade = "A+"

print(str(grade) + letterGrade

c)

studentNum =80

print("studentNum")

d)

print("Hello World!")

7.

Which of the following is NOT a program that will produce the following output?

SeasonSeasonSeason

a)

word = "Season" * 3

print(word)

b)

word = "Season" + "Season" + "Season"

print(word)

c)

num = 3

word = "Season" * 3

print(word)

d)

word = "Season"

print(word)

print(word)

print(word)

8.

float, integer, boolean, and string are all examples of what?

a)

Variables

b)

Data Types

c)

Words

d)

Concatenation

9.

The following statement/code snippet is an example of what?

color = blue

a)

All is correct

b)

Variable/variable assignment

c)

Variable declaration

d)

Variable initialization

10.

What will be the output of

print (a + b)

a)

12

b)

3

c)

1 + 2

d)

"a + b"

11.

What will be the output of

print (c + d)

a)

34

b)

7

c)

3 + 4

d)

"3 + 4"

12.

What will be the output of

print (a x b)

a)

12

b)

1

c)

2

d)

"1x2"

13.

What will be the output of

print (a x c)

a)

"axc"

b)

"1x3"

c)

"3"

d)

3

14.

What will be the output of

print (a x d)

a)

"axd"

b)

"1x4"

c)

"4"

d)

4

15.

What will be the output of

print (a x "c")

a)

c

b)

"1c"

c)

"c"

d)

1 x "c"

16.

What will be the output of

print (b x "d")

a)

b x "d"

b)

dd

c)

2 x 4

d)

8

17.

What do we use variables for?

a)

To store data

b)

Print data

c)

Produce functions

18.

What does int() represent?

a)

internet

b)

integer

c)

intel

d)

input

19.

To get the users input what function do we use?

a)

input

b)

input<>

c)

input()

d)

INPUT()

20.

What type of data is the following?: X = "195.67"

a)

Float

b)

String

c)

Boolean

d)

Integer

21.

What type of variable is the following?: Y = False

a)

Float

b)

String

c)

Integer

d)

Boolean

22.

What will be the output of

print (a + b)

a)

12

b)

3

c)

1 + 2

d)

"a + b"

23.

What will be the output of

print (c + d)

a)

34

b)

7

c)

3 + 4

d)

"3 + 4"

24.

What will be the output of

print (a x b)

a)

12

b)

1

c)

2

d)

"1x2"

25.

What will be the output of

print (a x c)

a)

"axc"

b)

"1x3"

c)

"3"

d)

3

26.

What will be the output of

print (a x d)

a)

"axd"

b)

"1x4"

c)

"4"

d)

4

27.

What is the process of converting one data type to another called?

a)

Data conversion.

b)

Type Casting.

c)

Type Conversion.

d)

Concatenation.

28.

What function converts the data in a variable into a 'integer'?

a)

int()

b)

str()

c)

bool()

d)

float()

29.

What function converts the data in a variable into a 'float'?

a)

int()

b)

flt()

c)

bool()

d)

float()

30.

What function converts the data in a variable into a 'string'?

a)

str()

b)

float()

c)

bool()

d)

string()

31.

What does this built-in function do?

input()

a)

Opens the CD tray.

b)

Prompts the user to enter data.

c)

Displays the word 'input'.

d)

Exits the program.

32.

How do you ask for the user to input their name?

a)

name = int("what is your name")

b)

print("What is your name?")

c)

input = name("what is your name?")

d)

name = input("what is your name?")

33.

By default any data inputted by the user is of data type string in python.

a)

True

b)

False

34.

What will be the output of the following command?

x = int(3.6)

print(x)

a)

3

b)

4

c)

Logical error - Can't cast a float value to an integer as data will be lost.

35.

What will be the output of the following command?

x = float(3)

print(x)

a)

Logical error - Can't cast a integer value to an float as data will be added.

b)

3.0

c)

3

36.

What will be the output of the following command?

x = str(3)

print(x)

a)

3

b)

3.0

c)

'3'

37.

What will be the output of the following program, if the user entered 20 and then 41?

Number1 = input("Enter the first number: ")

Number2 = input("Enter the second number: ")

print(Number1 + Number2)

a)

20 41

b)

Syntax error.

c)

61

d)

2041

38.

What can you add to the following code so that python recognises that they are numbers?

Number1 = input("Enter the first number: ")

Number2 = input("Enter the second number: ")

print(Number1 + Number2)

a)

int()

b)

float()

c)

Use a print statement to tell the user to enter a number.

d)

integer()

39.

Fill in the missing section for the code below:

areaOfSquare = (a)   (input("Enter area of square: "))

40.

What will be the output of the following program?

gameOnePoints = 200

gameTwoPoints = "456"

print(gameOnePoints + gameTwoPoints)

a)

Logical error - Can't add an integer and string together.

b)

656

c)

"656"

41.

Enter the missing keyword for the program below:

name =_____("Enter name: ")

a)

input

b)

print

c)

Bob

d)

Input

42.

Which of the following variable names can be used in a Python program?

a)

first_name

b)

Name_1

c)

First Name

d)

Name

43.

Which one of the following is the most appropriate name for a variable that stores data about how tall someone is?

a)

Num1

b)

Value

c)

x

d)

height

44.

Which of the following correctly describes the programming concept sequencing?

a)

When a set of instructions is repeated

b)

When a set of instructions is carried out in order

c)

Involves asking a question to which the answer is either true or false

d)

Programs that use blocks of instructions that work with each other

45.

What will the program output?

animal = 'zebra'

print(animal)

a)

'Zebra'

b)

zebra

c)

Animal

d)

Zebra

46.

What is wrong with this line of code:

input('What is your name?')

a)

Input should be changed with Print

b)

There is no variable assigned to the input

c)

The question mark should not be included

d)

The brackets are positioned in a wrong way

47.

A variable name must start with a letter and it cannot start with a number

a)

True

b)

False

48.

Variable names are case sensitive. Which means name, Name, NAME are all different variables.

a)

True

b)

False

49.

What will be the output of this code?

a)

Hello name pleased to meet you

b)

John

c)

Hello John pleased to meet you

d)

HelloJohnPleased to meet you

50.

When you work with decimal numbers in Python, which data type is the most suitable?

a)

Integer

b)

Float

c)

String

51.

A list is given below:

veg = ["carrot", "onion", "cabbage", "potato", "leek"]

Which vegetable would be retrieved with

veg[1]?

a)

carrot

b)

onion

c)

cabbage

d)

potato

e)

leek

52.

Here is a list:

veg = ["carrot", "onion", "cabbage", "potato", "leek"]

How would you retrieve the element from the list that contains the word leek?

a)

veg[5]

b)

veg[4]

c)

veg[3]

d)

veg[2]

53.

Consider the code given here. What will be the output of the given line of code?

print (fruits)

a)

[raspberry, apple, pear, banan, orange]

b)

[apple, pear, banana, orange,rasberry]

c)

the code will not run

54.
Which of the following is an example of a sequence in Python?
a)
For loop
b)
While loop
c)
List
d)
Dictionary
55.
What is the purpose of an iteration statement in Python?
a)
To repeat a set of instructions
b)
To specify the order of the instructions
c)
To break down the instructions
d)
To assign values to variables
56.
What is the main function of a selection statement in Python?
a)
To execute a set of instructions
b)
To stop a loop
c)
To test a condition
d)
To exit a program
57.
Which of the following is an example of a selection statement in Python?
a)
For loop
b)
While loop
c)
If statement
d)
Switch statement
58.
Which of the following is not a loop statement in Python?
a)
For loop
b)
While loop
c)
If statement
d)
Do-while loop
59.
What type of loop will repeat a set of instructions until a certain condition is met?
a)
For loop
b)
While loop
c)
If statement
d)
Do-while loop
60.
What type of loop will repeat a set of instructions at least once?
a)
For loop
b)
While loop
c)
If statement
d)
Do-while loop
61.
Which of the following is not a selection statement in Python?
a)
If statement
b)
Switch statement
c)
While loop
d)
For loop
62.
Which of the following is an example of a sequence in Python?
a)
For loop
b)
While loop
c)
Tuple
d)
Dictionary
63.
What type of loop will repeat a set of instructions until a certain condition is no longer true?
a)
For loop
b)
While loop
c)
If statement
d)
Do-while loop
64.

What is the name of the variable in this program?

a)

print

b)

colour

c)

input

d)

" "

65.

What will this code print?

a)

access denied

b)

access granted

c)

error

d)

password

66.

If the user enters 60, what is the output?

a)

You are old!

b)

You are middle-aged!

c)

You are young!

d)

Error message

67.
What does “==” represent in Python programming?
a)
less than
b)
equal to
c)
greater than
d)
not equal to
68.
Choose the correct Python code.
if age is less than 20 then
a)
if age > 20:
b)
if age < 20:
69.

What symbol must you place at the end of an if statement?

a)

)

b)

:

c)

;

d)

}

70.

What is an indentation in Python?

a)

A line of code that returns a value

b)

A subroutine

c)

A block of code that creates a variable

d)

A code block (body of a function, loop etc.) starts with indentation and ends with the first unintended line.

71.

1==0

a)

True

b)

False

72.

What will this code display?

a = 6

if a => 6:

print("pass")

else:

print("fail")

a)

pass

b)

fail

c)

nothing because there will be an error

d)

passfail

73.

what does != mean

a)

not

b)

swap value

c)

not equal

d)

equal

74.

What will this code print?

a)

access denied

b)

access granted

c)

error

d)

password

75.
Stores a piece of data, and gives it a specific name
a)
variable
b)
whitespace
c)
interpreter
d)
modulus
76.
A line of text that Python won't try to run as code
a)
comment
b)
modulus
c)
variable
d)
boolean
77.

What is the correct way to declare a variable 'a' with the value 100 in Python?

a)

var a = 100

b)

int a = 100

c)

a = 100

d)

declare a = 100

78.

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

a)

list

b)

array

c)

dictionary

d)

tuple

79.

What is the output of the following code snippet? ```python if 9 > 2: print("Nine is greater than two!") else: print("Two is greater than nine!") ```

a)

Nine is greater than two!

b)

Two is greater than nine!

c)

Error

d)

None of the above

80.

Which of the following is used to represent a boolean value of 'true' in Python?

a)

true

b)

True

c)

1

d)

Both B and C

81.

How do you find the length of the string "Python" in Python?

a)

len("Python")

b)

length("Python")

c)

size("Python")

d)

"Python".length()

82.

What is the result of the following code snippet? ```python x = int(2.8) ```

a)

2

b)

2.8

c)

3

d)

Error

83.

Which of the following is a constant in Python by convention?

a)

CONSTANT

b)

constant

c)

Constant

d)

_constant_

84.

What is the correct way to concatenate two strings, `a = "Hello"` and `b = "World"`?

a)

a + b

b)

a.concat(b)

c)

concat(a, b)

d)

a & b

85.

What is the output of the following code snippet? ```python print(bool("False")) ```

a)

False

b)

True

c)

0

d)

Error

86.

How do you convert the string "123" into an integer in Python?

a)

int("123")

b)

str(123)

c)

"123".toInt()

d)

parseInt("123")

87.

What is the name of the variable in this program?

a)

print

b)

colour

c)

input

d)

there is no variable

88.

What will happen when this program is run?

a)

Syntax error

b)

One will be displayed

c)

Zero will be displayed

d)

One then Zero will be displayed

89.

What will this code print?

a)

access denied

b)

access granted

c)

error

d)

password

90.

What will the code do?

a)

nothing

b)

display Hello Bob

c)

display I don't know you

d)

display Hello

91.

If the user enters 60, what is the output?

a)

You are old!

b)

You are middle-aged!

c)

You are young!

d)

Error message

92.
In python the ' BOOLEAN data type' can be defined as...?
a)
holds alphanumerical data
b)
holds whole numbers
c)
holds a number with a decimal point
d)
holds either true or false
93.
In python the ' FLOAT data type' can be defined as...?
a)
holds alphanumerical data
b)

holds whole numbers

c)

holds a decimal point in a number

d)
hold either true or false
94.
In python the ' INTEGER data type' can be defined as...?
a)
holds alphanumeric data as text
b)
holds whole numbers
c)
holds numbers with a decimal point
d)
holds either ‘true’ or ‘false’
95.

Logical operators:


True if both operands are true

a)

x and y

b)

x or y

c)

not x

96.

Logical Operators:


True if either of the operands is true

a)

x and y

b)

x or y

c)

not x

97.

Logical Operators:


true if operand is false

a)

x and y

b)

x or y

c)

not x

98.

Comparison Operators:


Select the correct operator for Greater Than:

a)

>

b)

<

c)

^

d)

v

99.

Comparison Operators:


Select the correct operator for Less than

a)

>

b)

<

c)

^

d)

v

100.

Comparison Operators:


Select the correct operator for equals to

a)

=

b)

==

c)

===

d)

====

101.

Comparison Operators:


Select the correct operator for not equal to

a)

=!=

b)

!

c)

=!

d)

!=

102.

Comparison Operators:


Select the correct operator for Greater than or Equal to:

a)

>=

b)

=>

c)

=)

d)

<=

103.

Comparison Operators:


Select the correct operator for less than or equal to

a)

<=

b)

=>

c)

>=

d)

==

104.
In programming, what is iteration?
a)
The repetition of steps within a program
b)
The order in which instructions are carried out
c)
A decision point in a program
d)
Testing a program to make sure it works
105.
Why is iteration important?
a)
It determines the order in which instructions are carried out
b)
It allows code to be simplified by removing duplicated steps
c)
It allows multiple paths through a program
d)
It ensures the code works correctly
106.
Which two statements are used to implement iteration?
a)
IF and WHILE
b)
ELSE and WHILE
c)
FOR and WHILE
d)
IF and ELSE
107.
Which type of loop iterates until instructed otherwise?
a)
FOR loop
b)
A count-controlled loop
c)
Repeat-once loop
d)
WHILE loop
108.
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
109.
Which of the following symbols is used in Python to mean "Equal to"?
a)
=
b)
!=
c)
==
d)
>=
110.
Which of the following symbols is used in Python to mean "Not equal to"?
a)
==
b)
!=
c)
<>
d)
><
111.
Which of the following symbols is used in Python to mean "Greater than or equal to"?
a)
<=
b)
>>
c)
>=
d)
=>
112.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
113.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
114.
a)
5
4
3
2
1
b)
5  4  3  2  1
c)
4
3
2
1
0
d)
4  3  2  1  0
115.
a)
10  8  6  4  2
b)
10
8
6
4
2
c)
2  4  6  8  10
d)
10  9  8  7  6  5  4  3  2  1
116.
a)
12  9  6  3  0
b)
0  3  6  9  12
c)
9  6  3  0
d)
0  3  6  9
117.
a)
0  5  10
b)
5  10
c)
0  5  10  15  20  25  30  35  40  45  50  55  60  65  70  75  80  85  90  95  100  105  110  115  120  125  130  135  140......etc
d)
12  7  2
118.
a)
12  17   22
b)
5
c)
12
d)
5  10
119.
a)
Hello world!
b)
Hello world
c)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
......(repeated continuously)
d)
Error
120.
a)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
(repeated continuously)
b)
Hello world!
c)
Hello world!
break              
d)
Error
121.
Which of the following symbols is used in Python to mean "Less than or equal to"?
a)
<<
b)
=<
c)
<=
d)
!=
122.
a)
Hello world!
b)
Error
c)
Hello world!
False
d)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
(repeated continuously)
123.
a)
Welcome
b)
Try again!
c)
Error
d)
Enter your password
124.

What is a for loop used for in Python?

a)

Iterating over a sequence

b)

Defining a function

c)

Creating a class

d)

Handling exceptions

125.

Which of the following is NOT a sequence that a for loop can iterate over?

a)

Integer

b)

Dictionary

c)

Tuple

d)

List

126.

What does the break statement do in a for loop?

a)

Skips the current iteration

b)

Continues with the next iteration

c)

Stops the loop before it has looped through all the items

d)

Restarts the loop

127.

What does the continue statement do in a for loop?

a)

Exits the loop

b)

Skips the current iteration and continues with the next

c)

Stops the loop

d)

Restarts the loop

128.

What does the range() function do?

a)

Returns a sequence of numbers

b)

Returns a list of strings

c)

Returns a dictionary

d)

Returns a set of tuples

129.

What will be the output of the following code? for x in range(2, 6): print(x)

a)

2 3 4 5 6

b)

2 3 4 5

c)

0 1 2 3 4 5

d)

3 4 5 6

130.

What is the purpose of the else block in a for loop?

a)

To execute a block of code if the loop is infinite

b)

To execute a block of code if the loop is skipped

c)

To execute a block of code before the loop starts

d)

To execute a block of code when the loop is finished

131.

What will be the output of the following code? for x in range(6): if x == 3: break print(x) else: print('Finally finished!')

a)

0 1 2 3

b)

0 1 2

c)

0 1 2 3 4 5 Finally finished!

d)

0 1 2 Finally finished!

132.

What is a nested loop?

a)

A loop with a break statement

b)

A loop inside a loop

c)

A loop that runs infinitely

d)

A loop with a continue statement

133.

What will be the output of the following code? for x in range(1, 10, 2): print(x)

a)

1 2 3 4 5 6 7 8 9

b)

1 3 5 7 9

c)

2 4 6 8 10

d)

1 2 3 4 5 6 7 8 9 10

134.

What will be the output of the following code? for x in range(4): if x == 2: continue print(x)

a)

0 1 2 3

b)

0 1 3

c)

0 1 2

d)

1 2 3

135.

What is the purpose of the pass statement in a for loop?

a)

To exit the loop

b)

To skip the current iteration

c)

To do nothing and continue

d)

To restart the loop

136.

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

a)

counter

b)

print

c)

for

d)

#

137.
a)
b)
c)
d)

1,2,3,4

138.

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

139.

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

140.

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

141.

When would you use a FOR loop?

a)

When you know how many times you want something to loop

b)

When you don't know how many times you want it to loop

142.

A FOR Loop is...

a)

A condition controlled loop

b)

A count controlled loop

143.

A WHILE Loop is...

a)

A condition controlled loop

b)

A count controlled loop

144.

The following array is created in a program: " DIREWOLVES = ["Nymeria","Shaggy Dog","Ghost","Lady","Grey Wind","Summer"]


What is the item stored in DIREWOLVES [2] ?

a)

"Shaggy Dog"

b)

"Ghost"

145.

Which of the following facts about arrays is TRUE?

a)

Arrays can contain items of different data types

b)

Arrays can only contain items of a single data type

c)

Lists and arrays are the same thing

d)

An arrays is a type of variable

146.

A program contains a 2D array ("CUSTOMER") storing customer numbers, first names and surnames


What data is held in stored in CUSTOMER (2,3)?

a)

Amrit

b)

Kahn

c)

Taylor

d)

1003

147.

A program contains a 2D array ("CUSTOMER") storing customer numbers, first names and surnames

What data is held in stored in CUSTOMER (0,2)?

a)

1004

b)

Smith

c)

Amrit

d)

1003

148.

A program contains a 2D array ("CUSTOMER") storing customer numbers, first names and surnames


Where in the array is the data item "Kahn" stored?

a)

(2,3)

b)

(4,1)

c)

(2,2)

d)

(3,3)

149.

Arrays are an example of...

a)

Dynamic Data Structures

b)

Static Data Structures

c)

Strings

d)

Integers

150.

Which of the following statements about ARRAYS are true?

a)

Arrays are more useful than individual variables for storing related data items

b)

Arrays are less wasteful that lists in terms of memory

c)

It is possible to iterate through the items in an array

d)

The memory used to store the data in an array, is allocated when the array is set up

151.

A programmer wants to store a set of data about the top grossing films of all time. He wants to include Film Name, Director, Genre, Year of release, and Money earned. Which data structure would be appropriate?

a)

A list

b)

An array

152.

In an array, what is the first numbered position in which data can be stored?

a)

Position 0

b)

Position 1

153.

What term is used to describe an individual position of an element in an array?

a)

Index

b)

Pointer

c)

Variable

d)

List

154.

Which of the following would be an appropriate use of a 2D array?

a)

Storing a list of colours

b)

Storing a list of random numbers

c)

Storing positions on chessboard

d)

Storing a list of first names

155.

Here is a data structure created in a program. Which of the following statements most accurately describes this data..?

a)

"hogwarts" is a list

b)

"hogwarts" is an array

c)

"hogwarts" could be both an array and a list

d)

"hogwarts" cannot be an array

156.

What is printed by the following lines of code?

a)

eggs

b)

bread

c)

2

d)

sugar

157.
What is the output from the following program?
a)
undefined
25
b)
20
25
c)
25
undefined
d)
20
20
158.

A programmer is creating a simple grid based video game. The blue square represents start position of the player, which is stored in a 2D array. Which of the following is correct?

a)

Player_pos = [1,5]

b)

Player_pos=[2,5]

c)

Player_pos=[5,1]

d)

Player_pos=[5,2]