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

Loops and Repetition in Code

שאלות 10

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

  1. רב־ברירהמדעי המחשבשפות תכנותpurpose of loopsrepetitioncontrol flowprogram structureloop basics

    What a loop does

    Which statement best describes the purpose of a loop in a computer program?

    1. To store data permanently on a hard drive

    2. To display an error message to the user

    3. To connect the computer to the internet

    4. To repeat a set of instructions multiple times


    Think about why a program would need to do the same task over and over without writing it many times.
  2. רב־ברירהמדעי המחשבשפות תכנותfor looploop countingPseudocoderepetitioniteration count

    Counting with a for loop

    How many times will the following pseudocode print the word Hello? for i from 1 to 5: print Hello

    1. 6 times

    2. 5 times

    3. 1 time

    4. 4 times


    Count how many values i takes when it goes from 1 up to 5, including both 1 and 5.
  3. רב־ברירהמדעי המחשבשפות תכנותwhile looploop conditioncontrol flowrepetitionloop types

    Loop that repeats while a condition holds

    Which type of loop repeats its instructions as long as a certain condition is true?

    1. A function loop

    2. A variable loop

    3. A print loop

    4. A while loop


    The name of this loop starts with a word that means during the time that something is true.
  4. רב־ברירהמדעי המחשבinfinite loopsloop conditions

    Infinite loop

    What is an infinite loop?

    1. A loop that runs exactly once

    2. A loop that only runs when the computer is turned on

    3. A loop that is written with no variables

    4. A loop whose condition never becomes false, so it never stops


    Think about what happens when the stopping condition is never reached.
  5. רב־ברירהמדעי המחשבloop variablesfor loopsaccumulation

    Loop variable value

    What is the final value of total after this code runs? total = 0; for i from 1 to 4: total = total + i

    1. 7

    2. 10

    3. 4

    4. 12


    Add the numbers 1, 2, 3 and 4 together, one at a time, as the loop goes around.
  6. רב־ברירהמדעי המחשבloop efficiencyrepeated stepsdrawing with code

    Loops and repeated actions

    A programmer wants to draw a square with four sides using the same move-and-turn steps. What is the most efficient way to do this?

    1. Use a loop that repeats the move-and-turn steps four times

    2. Write the same move-and-turn steps four separate times

    3. Use a variable to store the number of sides only

    4. Write only one move-and-turn step and stop


    Consider which approach avoids writing the same code again and again.
  7. רב־ברירהמדעי המחשבwhile loopscounters

    Loop with a counter that changes

    A while loop starts with count equal to 3 and runs while count is greater than 0. Inside the loop, count decreases by 1 each time. How many times does the loop body run?

    1. 2 times

    2. 3 times

    3. 4 times

    4. 0 times


    Trace the value of count step by step: it starts at 3, and the loop stops when count reaches 0.
  8. נכון / לא נכוןמדעי המחשבrepetitioncode blocks

    Repeating a Block of Code

    A loop allows a program to repeat the same block of instructions several times without writing each instruction again.

    1. True

    2. False


    Think about why programmers use loops instead of copying the same lines of code over and over.
  9. נכון / לא נכוןמדעי המחשבloop iterationscounting loops

    Counting Loop Iterations

    In a loop that counts from 1 to 10, the loop body runs 9 times in total.

    1. True

    2. False


    Count carefully: each value from 1 up to and including 10 causes one run of the loop body.
  10. נכון / לא נכוןמדעי המחשבloop variablesrepetitionchanging values

    Loop Variables

    A loop variable, such as i, can change its value on each pass through the loop, which lets the program use a different number each time the loop repeats.

    1. True

    2. False


    Consider how a counter that goes up by one each time can help a program do something different on each repetition.

פרטים

Questions on repeating actions in code with loops, counting steps, and finding and fixing simple loop errors.
קהל יעד
בית ספר יסודי · כיתות ה׳–ו׳
רמת קושי
4 מתוך 10
שפה
אנגלית
מי יכול לראות
כולם
הושלם על ידי AI
מה שמסומן בניצוץ נוסף על ידי AI.
נוצר באמצעות AI
Claude Haiku 5.5
נוצר

תגובות

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