Code Stepper – Variables, Data Types and Expressions

Computer ScienceAlgorithms & Problem SolvingAges 15–16

Loading…

Use with my class ✨ Customize with AI Report a problem

Step through a short Python or exam-style pseudocode program one line at a time. A variables table shows how each value and its data type (int, float, string, Boolean) change with every assignment, and an expression tree shows operator precedence and how 17 // 5, 17 % 5 or int(3.7) are evaluated. Examples cover input and output, selection, loops, random numbers with a frequency chart, virtual text files, casting errors and exceptions, and 32-bit integer overflow, all recorded in a trace table.

Lesson: Variables, assignment, data types and expressions; input and output, selection, iteration, files and exceptions

What it shows

A variable is a named storage location: an assignment evaluates the expression on the right and stores the result in the variable on the left. This stepper runs a teaching subset of Python, or exam-style pseudocode with ←, DIV, MOD and IF … ENDIF, one line at a time. A variables table shows every value with its data type, an expression tree shows operator precedence and how integer division, modulo and casting are worked out, and a trace table records each step. Examples cover input and output, selection, loops, random numbers, text files, casting errors, exceptions and 32-bit overflow.

How to use

Choose an Example program and a Language, then press Step 1 line to run one line at a time, Run to run at the chosen Speed, or Run to end. Values read by input() or INPUT go in the Input box, one per line. After each step, check the Variables in memory table, the expression tree and the Trace table. Press Edit code to write your own program, and set Integers to 32-bit to see overflow.

Parameters you can change

  • Example program Variables and data types, Operators and precedence, Input and output, Selection (if / else), Loops, Random numbers (dice), Reading and writing files, Casting errors and exceptions, 32-bit integer overflow
  • Language Python, Pseudocode (exam style)
  • Integers Unbounded (like Python), 32-bit (like Java, C)
  • Run speed 0.5–20 lines/s

Questions to explore

  1. Why does age + 1 fail after age = input(), while int(age) + 1 works?
  2. What values and types do 17 // 5, 17 % 5 and 17 / 5 give, and how do // and DIV differ for -7?
  3. In 32-bit mode, why does 2147483647 + 1 become a negative number?