Small Basic Arithmetic and Variables
9 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What arithmetic operator is not utilized in Small Basic?

  • $*$
  • $+$
  • $igodot$
  • $igdiv$ (correct)
  • What is the result of the arithmetic expression $6 + 5 * 2$?

  • 18 (correct)
  • 16
  • 20
  • 22
  • What is the output of the function Math.Remainder(30, 8)?

  • 5 (correct)
  • 3
  • 8
  • 6
  • Which symbol is used for inserting comments in a Small Basic program?

    <p><code>'</code></p> Signup and view all the answers

    Which method is used to read a numeric value during program execution in Small Basic?

    <p><code>ReadNumber()</code></p> Signup and view all the answers

    What is the effect of using WriteLine() instead of Write() in Small Basic?

    <p><code>WriteLine()</code> moves the cursor to a new line afterward.</p> Signup and view all the answers

    What should be considered when naming variables in Small Basic?

    <p>Variable names should not begin with a number.</p> Signup and view all the answers

    When multiple arithmetic operators are present, what is the order of execution?

    <p>Multiplication and division are executed before addition and subtraction.</p> Signup and view all the answers

    Which conditional statement is most suitable when there are multiple conditions to evaluate?

    <p>If-Then-ElseIf</p> Signup and view all the answers

    Study Notes

    Arithmetic Operators

    • Small Basic uses the following arithmetic operators:
      • + (addition)
      • - (subtraction)
      • * (multiplication)
      • / (division)
      • \ (integer divison)
      • ^ (power)
      • Math.Remainder() (modulo)

    Variable Naming

    • The rules for naming variables in Small Basic are:
      • Must start with a letter
      • Can contain letters, numbers, and the underscore character (_)
      • Cannot be a reserved word

    Variables

    • Small Basic has two types of variables:
      • Local: Variables declared inside a function. Their scope is limited to that function.
      • Global: Variables declared outside a function. Their scope is global, meaning they can be accessed by any function in the program.

    Comments in Small Basic

    • Comments are used to provide explanations and documentation within a program.
    • They are ignored by the interpreter.
    • Use single quotes ' at the start of a comment.

    Write() vs WriteLine() Methods

    • WriteLine() prints the text and then moves the cursor to the next line.
    • Write() prints the text on the same line.

    Conditional Statements - If-Then, If-Then-Else, If-Then-ElseIf

    • If- Then: Executes a block of code only if a condition is true.
    • If-Then-Else: Executes one block of code if a condition is true and another block if the condition is false.
    • If-Then-ElseIf: Allows us to evaluate multiple conditions in sequence.

    Example Coding

    • Operator Usage:
      • >= (greater than or equal to)
      • * (multiplication)
      • + (addition)
      • > (greater than)
      • AND (logical AND)
      • = (assignment operator)

    Coding for Lunchbox Data

    • To collect data on students bringing lunchboxes, you can use a For loop with an If statement to count students under 14 who bring lunchboxes.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    This quiz covers the fundamental arithmetic operators and variable naming conventions in Small Basic. You'll also learn about the types of variables, their scopes, and the importance of comments in programming. Test your knowledge on these essential concepts!

    Use Quizgecko on...
    Browser
    Browser