דילוג לתוכן
מבחן 10 שאלות

Robotics: Loops and Conditions

שאלות 10

מפתח התשובות מוצג למורים מחוברים.

  1. רב־ברירהמדעי המחשב

    Choosing the right loop

    A robot should keep moving forward as long as its front sensor does not detect a wall, and it does not know in advance how many steps this will take. Which programming structure is most suitable?

    1. A function that is defined but never called

    2. An if-else statement with no loop

    3. A while loop that checks a condition

    4. A for loop that repeats a fixed number of times


    Think about a repetition structure that depends on a condition that may change during the run, not on a known count.
  2. רב־ברירהמדעי המחשב

    Counting repeats in a for loop

    A robot program contains a for loop that repeats the block 'move forward 10 cm' exactly 5 times. How many times is the block 'move forward 10 cm' executed in total?

    1. 10

    2. 4

    3. 5

    4. 6


    Count how many repetitions the loop is set to perform, and remember that the loop body runs once per repetition.
  3. רב־ברירהמדעי המחשב

    The else branch

    In a robot program, an if-else statement checks whether the light sensor reading is below 30. In which situation is the else branch executed?

    1. Only when the condition is True

    2. Every time, before the if branch

    3. Only when the condition is False

    4. Only when the program is first started


    Consider what happens to the else branch when the if condition does not hold.
  4. רב־ברירהמדעי המחשב

    Behaviour of a while True loop

    A robot program contains the loop 'while True: move forward' and no statement inside the loop stops it. What is the expected behaviour of the robot?

    1. It moves forward until the program is stopped by the user or an external event

    2. It turns off its motors after 10 seconds by default

    3. It produces an error before the first movement

    4. It moves forward once and then stops automatically


    A loop whose condition never becomes False keeps repeating. Think about what can end such a loop.
  5. רב־ברירהמדעי המחשב

    Nested loops

    A robot program has an outer loop that repeats 3 times. Inside it, an inner loop repeats 2 times, and the inner loop body is 'blink the light'. How many times is 'blink the light' executed in total?

    1. 5

    2. 9

    3. 12

    4. 6


    For each repetition of the outer loop, the inner loop runs completely. Multiply the two repeat counts.
  6. רב־ברירהמדעי המחשב

    Evaluating a condition

    The robot's distance sensor reads 12 cm. Which condition, when evaluated in the program, is True?

    1. distance == 20

    2. distance < 15

    3. distance >= 20

    4. distance > 15


    Substitute the sensor reading into each condition and check which comparison holds.
  7. רב־ברירהמדעי המחשב

    When the while condition is checked

    In a while loop, when is the loop condition checked?

    1. After the whole program has finished

    2. Only after the loop body has run once

    3. Only once, when the program starts

    4. Before each repetition, including the first one


    Think about whether the robot must check the condition before entering the loop body for the first time.
  8. רב־ברירהמדעי המחשב

    Why use a loop

    A student wants the robot to drive around a square. Instead of writing four separate 'move forward 20 cm' and 'turn right 90 degrees' pairs, the student uses a loop that repeats them 4 times. What is the main benefit of this approach?

    1. The robot can drive in a circle without any turning

    2. The program is shorter and easier to change or correct

    3. The robot becomes faster than with separate commands

    4. The robot no longer needs sensors


    Compare how much code is needed and how many places must be edited if the square's side length changes.
  9. רב־ברירהמדעי המחשב

    Combining loops and conditions

    A line-following robot must keep checking its light sensor for as long as the program runs. If the sensor sees black, it moves forward; otherwise, it turns right to find the line again. Which combination of structures best describes this program?

    1. An if statement placed outside any loop

    2. A single for loop without any conditions

    3. A while loop containing an if-else statement

    4. Two separate functions with no repetition


    The robot must repeat its checking over time, and it must choose between two actions at each check.
  10. רב־ברירהמדעי המחשב

    Negating a Boolean condition

    A robot's variable obstacle_detected is True when an obstacle is in front of it. Which condition should be used so that the robot moves forward only when there is no obstacle?

    1. obstacle_detected or obstacle_detected

    2. obstacle_detected

    3. obstacle_detected and not obstacle_detected

    4. not obstacle_detected


    You need a condition that is True exactly when the Boolean variable is False. Think about which logical operator reverses a Boolean value.

פרטים

Questions about repeating actions with loops and making decisions with conditions in simple robot programs. For junior high school English classes.
מקצועות
מדעי המחשב
קהל יעד
חטיבת ביניים · כיתות ז׳–ט׳
רמת קושי
5 מתוך 10
שפה
אנגלית
מי יכול לראות
כולם
נוצר באמצעות AI
Claude Haiku 5.5
נוצר

תגובות

  1. אין תגובות עדיין.
© כל הזכויות שמורות