← Computer Studies / 3 Software development

3.3 Identifiers and Operators

Computer Studies · Grade 10 · 18 lessons in the design

What this covers

  • The structural elements of a program: structure, syntax, errors
  • Reserved words, identifiers and naming rules
  • Data types
  • Declaring variables and constants
  • Input and output statements
  • Operators: arithmetic, relational, logical and assignment
  • Standard libraries

What you will be able to do

  • describe the elementary elements of a computer program
  • declare variables and constants in a programming language
  • use input and output statements in a programming language
  • use operators in a programming language
  • appreciate the role of identifiers and operators in programming

Key questions

“What is the importance of a structured programming language?”

“How are variables declared in programming languages?”

Lessons

The titles are open to everyone. Reading a lesson needs an account — sign in or create one.

  1. The elements of a program: identifiers, variables and input/output
    40 min · 1 practice tasks · quiz
    The parts every program is made of, the rules for naming things, data types, declaring variables and constants, and reading input and displaying output.
  2. Operators
    40 min · 1 practice tasks · quiz
    The four families of operator - arithmetic, relational, logical and assignment - how they work, precedence, and the store-versus-compare trap.
  3. How a program is structured
    40 min · 1 practice tasks · quiz
    A program is ordered parts: comment, import, names, input, processing, output. Structure is why a language is usable.
  4. Syntax and the three kinds of error
    40 min · 1 practice tasks · quiz
    Syntax is grammar. Syntax errors refuse to run; runtime errors crash; logic errors finish with the wrong change.
  5. Reserved words you cannot use as names
    40 min · 1 practice tasks · quiz
    Keywords such as if, while, for and import belong to Python. They cannot be identifiers.
  6. Identifiers and naming rules
    40 min · 1 practice tasks · quiz
    An identifier is a name you choose. Four rules, plus the unenforced rule: make it meaningful.
  7. Data types: integer, float, string and Boolean
    40 min · 1 practice tasks · quiz
    A type is the kind of value. Whole shillings, decimal prices, names in quotes, and True or False.
  8. Type conversion before arithmetic
    40 min · 1 practice tasks · quiz
    input() is text. int() and float() turn it into a number. str() turns a number into text. Forgetting this joins "50" and "20" into 5020.
  9. Declaring variables in Python (and how C differs)
    40 min · 1 practice tasks · quiz
    A variable is a named box. Python creates it by assignment. C and Java state the type first. That is the inquiry question.
  10. Constants: VAT, PI and a fee rate
    40 min · 1 practice tasks · quiz
    A constant is a named value that must not change. Python uses CAPITALS as a promise. Put VAT in one place.
  11. Input statements: reading the user
    40 min · 1 practice tasks · quiz
    input() pauses, shows a prompt, and always returns a string. Convert, then store in a well-named variable.
  12. Output statements: showing the result
    40 min · 1 practice tasks · quiz
    print() displays values. Several items can go in one print, separated by commas. Labels make the number mean something.
  13. Arithmetic operators in Kenyan calculations
    40 min · 1 practice tasks · quiz
    Plus, minus, times, divide and modulus on real amounts: kiosk change, VAT, even and odd admission numbers.
  14. Relational operators: questions that answer True or False
    40 min · 1 practice tasks · quiz
    == != < > <= >= ask questions. They produce Booleans, which every if will need in the next sub-strand.
  15. Logical operators: and, or, not
    40 min · 1 practice tasks · quiz
    and needs both, or needs either, not reverses. That is how a real school or kiosk rule is written.
  16. Assignment and compound assignment
    40 min · 1 practice tasks · quiz
    = stores right into left. += -= *= /= update a box in place. count += 1 is the standard step of a counter.
  17. Operator precedence: when in doubt, brackets
    40 min · 1 practice tasks · quiz
    Times and divide before add and minus, as in mathematics. Brackets override and make the order readable.
  18. Standard libraries: math and random
    40 min · 1 practice tasks · quiz
    import brings ready-made tools. math.sqrt and math.pi, random.randint. Reuse is professional, not cheating.