Sum of two numbers

Reads two numbers and prints their sum. Teaches variables and expressions.

Open in Tokbit Level: Beginner. Free in the browser, nothing to install, no account needed.

Run the example in Tokbit and step through it: before each step say what will happen and check it in the Variables panel. Then change it your way.

Flowchart

Flowchart of the Sum of two numbers example

Python program

The same program as Python code. In Tokbit you see it when you switch from Diagram to Python above the flowchart.

"""Adds two numbers you type in. Teaches variables and an expression in Output."""
a: int
b: int
a = int(input("First number:"))
b = int(input("Second number:"))
# The sum is computed right in the Output, no extra variable needed.
print("The sum is", a + b)

Follow-up tasks

Tasks in which you change the example (with a model solution):

All examples