WorksheetsProgramming Variables (Python)
Total questions: 17
Worksheet time: 9mins
Which variable type is used to hold whole numbers?
Floating-Point
Character
Integer
Boolean
What type of variable is used to store a single character?
String
Character
Integer
Boolean
Which of the following is an example of a floating-point variable?
int score = 10;
temperature = 36.5;
grade = 'A';
isPlayerAlive = true;
What type of variable can hold a sequence of characters?
Integer
Boolean
String
Character
Which variable type can have values TRUE or FALSE?
Integer
Boolean
Floating-Point
String
What does the "IF" statement do in programming?
Executes a block of code if a specified condition is true.
Repeats a block of code a specified number of times.
Specifies a new condition if the previous condition was false.
Executes a block of code as long as a specified condition is true.
Which statement is used to execute a block of code if the preceding "IF" statement is false?
IF
ELSE
ELSE IF
WHILE
What is the purpose of the "ELSE IF" statement?
Repeats a block of code a specified number of times.
Executes a block of code if a specified condition is true.
Specifies a new condition if the previous "IF" condition was false.
Executes a block of code as long as a specified condition is true.
Which control flow statement repeats a block of code a specified number of times?
IF
ELSE
FOR
WHILE
What does the "WHILE" statement do in programming?
Executes a block of code if a specified condition is true.
Repeats a block of code a specified number of times.
Specifies a new condition if the previous condition was false.
Repeats a block of code as long as a specified condition is true.
What does the logical operator "&&" represent?
OR
NOT
AND
XOR
Which logical operator returns TRUE if at least one operand is TRUE?
&&
||
!
XOR
What is the function of the "!" logical operator?
Returns true if both operands are true
Returns true if at least one operand is true
Inverts the boolean value
Combines two conditions
What does the relational operator "==" mean?
Is not equal to
Is greater than
Is equal to
Is less than
Which relational operator would you use to check if a value is not equal to another value?
==
!=
>
<=
In the expression "if (coinsCollected > requiredCoins)", what is the purpose of the ">" operator?
To check if coinsCollected is less than requiredCoins
To check if coinsCollected is equal to requiredCoins
To check if coinsCollected is greater than requiredCoins
To check if coinsCollected is not equal to requiredCoins
Which relational operator is used to determine if a value is less than or equal to another value?
>=
==
<
<=
