Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Programming Variables (Python)

Total questions: 17

Worksheet time: 9mins

Name
Class
Date
1.

Which variable type is used to hold whole numbers?

a)

Floating-Point

b)

Character

c)

Integer

d)

Boolean

2.

What type of variable is used to store a single character?

a)

String

b)

Character

c)

Integer

d)

Boolean

3.

Which of the following is an example of a floating-point variable?

a)

int score = 10;

b)

temperature = 36.5;

c)

grade = 'A';

d)

isPlayerAlive = true;

4.

What type of variable can hold a sequence of characters?

a)

Integer

b)

Boolean

c)

String

d)

Character

5.

Which variable type can have values TRUE or FALSE?

a)

Integer

b)

Boolean

c)

Floating-Point

d)

String

6.

What does the "IF" statement do in programming?

a)

Executes a block of code if a specified condition is true.

b)

Repeats a block of code a specified number of times.

c)

Specifies a new condition if the previous condition was false.

d)

Executes a block of code as long as a specified condition is true.

7.

Which statement is used to execute a block of code if the preceding "IF" statement is false?

a)

IF

b)

ELSE

c)

ELSE IF

d)

WHILE

8.

What is the purpose of the "ELSE IF" statement?

a)

Repeats a block of code a specified number of times.

b)

Executes a block of code if a specified condition is true.

c)

Specifies a new condition if the previous "IF" condition was false.

d)

Executes a block of code as long as a specified condition is true.

9.

Which control flow statement repeats a block of code a specified number of times?

a)

IF

b)

ELSE

c)

FOR

d)

WHILE

10.

What does the "WHILE" statement do in programming?

a)

Executes a block of code if a specified condition is true.

b)

Repeats a block of code a specified number of times.

c)

Specifies a new condition if the previous condition was false.

d)

Repeats a block of code as long as a specified condition is true.

11.

What does the logical operator "&&" represent?

a)

OR

b)

NOT

c)

AND

d)

XOR

12.

Which logical operator returns TRUE if at least one operand is TRUE?

a)

&&

b)

||

c)

!

d)

XOR

13.

What is the function of the "!" logical operator?

a)

Returns true if both operands are true

b)

Returns true if at least one operand is true

c)

Inverts the boolean value

d)

Combines two conditions

14.

What does the relational operator "==" mean?

a)

Is not equal to

b)

Is greater than

c)

Is equal to

d)

Is less than

15.

Which relational operator would you use to check if a value is not equal to another value?

a)

==

b)

!=

c)

>

d)

<=

16.

In the expression "if (coinsCollected > requiredCoins)", what is the purpose of the ">" operator?

a)

To check if coinsCollected is less than requiredCoins

b)

To check if coinsCollected is equal to requiredCoins

c)

To check if coinsCollected is greater than requiredCoins

d)

To check if coinsCollected is not equal to requiredCoins

17.

Which relational operator is used to determine if a value is less than or equal to another value?

a)

>=

b)

==

c)

<

d)

<=