← 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.
-
The elements of a program: identifiers, variables and input/output
40 min · 1 practice tasks · quizThe parts every program is made of, the rules for naming things, data types, declaring variables and constants, and reading input and displaying output.
-
Operators
40 min · 1 practice tasks · quizThe four families of operator - arithmetic, relational, logical and assignment - how they work, precedence, and the store-versus-compare trap.
-
How a program is structured
40 min · 1 practice tasks · quizA program is ordered parts: comment, import, names, input, processing, output. Structure is why a language is usable.
-
Syntax and the three kinds of error
40 min · 1 practice tasks · quizSyntax is grammar. Syntax errors refuse to run; runtime errors crash; logic errors finish with the wrong change.
-
Reserved words you cannot use as names
40 min · 1 practice tasks · quizKeywords such as if, while, for and import belong to Python. They cannot be identifiers.
-
Identifiers and naming rules
40 min · 1 practice tasks · quizAn identifier is a name you choose. Four rules, plus the unenforced rule: make it meaningful.
-
Data types: integer, float, string and Boolean
40 min · 1 practice tasks · quizA type is the kind of value. Whole shillings, decimal prices, names in quotes, and True or False.
-
Type conversion before arithmetic
40 min · 1 practice tasks · quizinput() is text. int() and float() turn it into a number. str() turns a number into text. Forgetting this joins "50" and "20" into 5020.
-
Declaring variables in Python (and how C differs)
40 min · 1 practice tasks · quizA variable is a named box. Python creates it by assignment. C and Java state the type first. That is the inquiry question.
-
Constants: VAT, PI and a fee rate
40 min · 1 practice tasks · quizA constant is a named value that must not change. Python uses CAPITALS as a promise. Put VAT in one place.
-
Input statements: reading the user
40 min · 1 practice tasks · quizinput() pauses, shows a prompt, and always returns a string. Convert, then store in a well-named variable.
-
Output statements: showing the result
40 min · 1 practice tasks · quizprint() displays values. Several items can go in one print, separated by commas. Labels make the number mean something.
-
Arithmetic operators in Kenyan calculations
40 min · 1 practice tasks · quizPlus, minus, times, divide and modulus on real amounts: kiosk change, VAT, even and odd admission numbers.
-
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.
-
Logical operators: and, or, not
40 min · 1 practice tasks · quizand needs both, or needs either, not reverses. That is how a real school or kiosk rule is written.
-
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.
-
Operator precedence: when in doubt, brackets
40 min · 1 practice tasks · quizTimes and divide before add and minus, as in mathematics. Brackets override and make the order readable.
-
Standard libraries: math and random
40 min · 1 practice tasks · quizimport brings ready-made tools. math.sqrt and math.pi, random.randint. Reuse is professional, not cheating.