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

Variables and Loops

שאלות 10

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

  1. רב־ברירהמדעי המחשבשפות תכנותvariablesValuesprogram state

    Purpose of a variable

    What is the main purpose of a variable in a computer program?

    1. To permanently fix a value that can never change

    2. To draw graphics on the screen

    3. To store a value that can be referenced and changed later

    4. To connect the computer to the internet


    Think about a labeled box that holds information the program can use and update.
  2. רב־ברירהמדעי המחשבשפות תכנותdata typesstringfloatbooleaninteger

    Integer data type

    Which data type is most appropriate for storing the number of students in a classroom?

    1. String

    2. Float

    3. Boolean

    4. Integer


    The number of students is a whole number that cannot be fractional.
  3. רב־ברירהמדעי המחשבc#data typesboolean

    Boolean values

    Which data type can only hold the values True or False?

    1. String

    2. Integer

    3. Character

    4. Boolean


    This type is named after a mathematician and is used for yes/no conditions.
  4. רב־ברירהמדעי המחשבc#data typesstringtext data

    Text data

    What data type is used to store text such as a person's name?

    1. String

    2. Float

    3. Integer

    4. Boolean


    A sequence of characters enclosed in quotation marks is stored with this type.
  5. רב־ברירהמדעי המחשבc#data typesdecimal numbersfloat

    Floating-point numbers

    Which data type is best for storing the value \(3.75\) (a number with a decimal point)?

    1. Character

    2. Float

    3. Integer

    4. Boolean


    Numbers that can have digits after the decimal point need a specific type.
  6. רב־ברירהמדעי המחשבc#while looploop conditions

    While loop behavior

    In a while loop, when is the loop body executed?

    1. Repeatedly, as long as the condition is True

    2. Only if the condition is False at the start

    3. Exactly once, regardless of the condition

    4. Only after all variables are deleted


    The loop checks a condition before each repetition.
  7. רב־ברירהמדעי המחשבc#for looprange function

    For loop counting

    How many times will the following loop run? for i in range(5): print(i)

    1. 1

    2. 6

    3. 5

    4. 4


    range(5) produces the values 0, 1, 2, 3 and 4.
  8. רב־ברירהמדעי המחשבc#variable assignmentarithmetic expressions

    Reassigning a variable

    What is the value of x after this code runs? x = 4; x = x + 3

    1. 43

    2. 4

    3. 3

    4. 7


    The second line uses the old value of x and then stores a new value back into x.
  9. רב־ברירהמדעי המחשבc#infinite loopwhile looploop variables

    Infinite loop risk

    Which problem is most likely to cause an infinite loop in a while loop?

    1. The condition uses the less-than operator

    2. The loop variable is never updated inside the loop

    3. The loop body contains a print statement

    4. The loop is written with indentation


    If the condition never becomes False, the loop never stops.
  10. רב־ברירהמדעי המחשבc#type conversiondata typescasting

    Type conversion

    What does the expression int("12") do in most beginner programming languages?

    1. Deletes the variable named int

    2. Creates a Boolean value True

    3. Converts the integer 12 into the text "12"

    4. Converts the text "12" into the integer 12


    Look at what the function name suggests: it changes one type into another, specifically into an integer.

פרטים

Questions on what variables store, data types, and how for and while loops repeat instructions in simple programs.
קהל יעד
חטיבת ביניים · כיתות ז׳–ט׳
רמת קושי
5 מתוך 10
שפה
אנגלית
מי יכול לראות
כולם
הושלם על ידי AI
מה שמסומן בניצוץ נוסף על ידי AI.
נוצר באמצעות AI
Claude Haiku 5.5
נוצר

תגובות

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