Sonzaschool
Back

O-Level · Form 4 · Vocational · Electronics and Computer

Computer Programming

Performing exploration of basic programming constructs

about 5 minutes to read

Discussions
Topics in this sectionCreating basic programs3 topics

Basic Programming Constructs

Programming is the process of giving a computer a set of instructions to perform a task. To write effective programs, programmers use programming constructs — the basic building blocks that control how a program runs. In this topic, we will explore four fundamental constructs: variables, data types, conditionals, and loops.


A variable is a named storage location in computer memory that holds a value which can change during program execution. Think of a variable as a labeled box where you store information.

Key Points

  • Variables have a name that you choose (e.g., price, quantity, total)
  • Variables store data that can be used and modified in your program
  • In Python, you create a variable by assigning a value using the = operator

Worked Example

# Creating variables in Python
price = 5000          # Price of an item in Tanzanian shillings (TSH)
quantity = 3          # Number of items
discount = 0.1        # 10% discount rate

In this example:

  • price is a variable storing 5000
  • quantity is a variable storing 3
  • discount is a variable storing 0.1

How you'll be assessedProcess assessment · Outcome assessment · Knowledge assessment

Process assessment

  • The student should be able to:
  • Use of correct syntax for variables, loops, and conditionals.
  • Identify andcorrect logical errors in code.

Outcome assessment

A functional Python script showcasing proper use of variables, conditionals, and loops.

Knowledge assessment

Detailed knowledge of:

Method used: The student should explain:

  • Step-by-step explanation of Python basics (syntax, semantics).

Principles: The student should explain the principles of:

  • clean and efficient coding practices.

Theories: The student should explain:

  • basic concepts and applications of Python programming language
  • data types and variables in Python
  • flow control (sequential, conditional, iterative).

Circumstantial knowledge:

Detailed knowledge about:

  • debugging computer programs.

Question

Which statement correctly describes what a variable is in programming?

Sign in to submit your answer and have it count toward your mastery.

Sign in to practice

Tutor

Stuck? Ask me anything about this topic.

Sign in to ask the Sonza AI Tutor about this question.

Sign in to ask

Discussions

No questions yet

Sign in to ask
Loading discussions…