Understanding the use of the three basic programming constructs

Cards (12)

  • In sequential programming, looping is allowed.
    False
  • Steps to calculate the area of a square in sequential programming
    1️⃣ Get input from the user
    2️⃣ Calculate the area of a square
    3️⃣ Display the result
  • The `if` statement executes code only if the specified condition is true
  • The `elif` statement checks a condition only if the previous `if` was false.

    True
  • The `for` loop is used when the number of iterations is known in advance
  • The `while` loop continues as long as a given condition is true.

    True
  • What is sequential programming?
    Code executes line by line
  • In sequential programming, each instruction is executed once
  • What are conditional statements used for in programming?
    To control program flow
  • Match the conditional statement with its description:
    `if` ↔️ Executes if condition is true
    `elif` ↔️ Checks additional condition
    `else` ↔️ Executes if all conditions are false
  • What is the purpose of iterative programming?
    Repeated execution of instructions
  • Match the loop type with its description:
    `for` ↔️ Iterates a specific number of times
    `while` ↔️ Continues as long as condition is true