WorksheetsPython
Total questions: 26
Worksheet time: 19mins
What is the difference between the data types "int" and "float"?
'int' represents whole numbers, while 'float' represents sequences of characters.
'int' represents characters, while 'float' represents numbers.
'int' represents whole numbers, while 'float' represents decimal numbers.
'int' represents positive numbers, while 'float' represents negative numbers.
What are variables in Python?
Variables in Python are used to look cool and awesome.
What are booleans?
How do you check if two values are equal in Python?
What is the difference between "=" and "==" in Python?
What is the output to the python code?
X = 5
Y = 5
print(X == Y)
What is the output to this Python code?
X = 5
Y = 3
print(X == Y)
What is the purpose of Conditional statements in Python?
These are long sets of characters in quotation marks.
Which of the following operators is used to check if two values are not equal in Python?
!=
==
<>
>
How do you write an if statement to check if `x` is greater than 10?
if x > 10:
if x is > 10:
if x >> 10:
if x gt 10:
Which logical operator is used in Python to combine two boolean conditions and returns True if both conditions are true?
OR
AND
NOT
XOR
In Python, what is the correct way to write an if statement that checks if `x` is either 10 or 20?
if x == 10 or x == 20:
if x = 10 || x = 20:
if x == 10 | x == 20:
if x == (10 or 20):
Which of the following is a valid comparison operator in Python for checking greater than or equal to?
>=
=>
>+
=<
What is the correct way to use logical operators for combining conditions in Python?
if condition1 && condition2:
if condition1 and condition2:
if condition1 & condition2:
if condition1 + condition2:
In Python, how do you write an if statement to check if `x` is between 5 and 10, inclusive?
if x > 5 and x < 10:
if 5 <= x <= 10:
if x >= 5 or x <= 10:
if x == 5 and x == 10:
Which of the following is the correct way to define a function in Python?
myFunction() = def:
function myFunction():
define myFunction:
def myFunction():
What is the purpose of the 'return' statement in a function?
To print output to the console
To end the program
To return a value from a function
To define a function
What is the purpose of the 'break' statement in a loop?
To continue to the next iteration
To exit the loop immediately
To skip the current iteration
To pause the loop for a moment
