placeholder image to represent content

Python: Conditions

Quiz by Teran Subasinghe

Our brand new solo games combine with your quiz, on the same screen

Correct quiz answers unlock more play!

New Quizalize solo game modes
8 questions
Show answers
  • Q1
    Which of the following is a correct way to write an if statement in Python?
    if (condition) {
    if: condition
    if condition:
    if condition then:
    30s
  • Q2
    What will be the output of the following code: if x == 10: print('Equal') else: print('Not Equal') when x is 5?
    Equal
    Error
    Not Equal
    10
    30s
  • Q3
    What is the purpose of the 'elif' statement in Python?
    To check another condition if the previous if statement is false
    To end the if statement
    To create a loop
    To define a function
    30s
  • Q4
    What is the output of the following code if num = 8: if num % 2 == 0: print('Even') else: print('Odd')?
    None
    Odd
    Even
    Error
    30s
  • Q5
    In Python, which of the following will correctly check if a variable x is not equal to 5?
    if (x != 5)
    if x =! 5:
    if x <> 5:
    if x != 5:
    30s
  • Q6
    Which of the following statements will evaluate to True if a is greater than b in Python?
    a >= b
    a > b
    a < b
    a == b
    30s
  • Q7
    Which of the following constructs is used to define a block of code that executes when a condition is met in Python?
    Curly braces
    Indentation
    Parentheses
    Square brackets
    30s
  • Q8
    What is the correct way to check multiple conditions in Python using 'and'?
    if x > 0 & x < 10:
    if x > 0, x < 10:
    if x > 0 and x < 10:
    if (x > 0 and x < 10):
    30s

Teachers give this quiz to your class