Flowchart examples
Every example is a finished program in Tokbit: its page shows the flowchart, the same program in Python and a button that opens it in the app. There you run it, step through it and change it.
Beginner
- Hello – Asks for your name and says hello. Teaches Input and Output.
- Sum of two numbers – Reads two numbers and prints their sum. Teaches variables and expressions.
- Temperature converter – Converts Celsius to Fahrenheit. Teaches decimal numbers and rounding.
- Circle – Asks for the radius and prints the circumference and area of a circle. Teaches pi, powers and rounding to 2 places.
- Pythagorean theorem – Works out the hypotenuse of a right triangle from its two legs. Teaches the square root sqrt and the power **.
- Even or odd – Finds out whether a number is even. Teaches conditions and the remainder %.
- Countdown – Counts down from 10 to 1 and lifts off. Teaches the for loop with step -1.
- Sum of numbers – Reads a number and adds up all numbers from 1 to it. Teaches input, variables and the for loop.
- Rainbow – Prints lines in all screen colours. Teaches the for loop and how to change the text colour, the background and where you write.
Intermediate
- Largest number – Finds the largest number in a list. Teaches lists, indexes and a condition inside a loop.
- FizzBuzz – Numbers 1 to 100, words instead of multiples of 3 and 5. Teaches the remainder and the order of conditions.
- Times table – Prints the multiplication table 1 to 10. Teaches nested loops and aligning text.
- Guess the number – The computer thinks of a number and says higher or lower. Teaches random numbers, the while loop and counting guesses.
- Hangman – Guess the word letter by letter before the hangman is drawn. Teaches strings, in, looping over characters and checking input.
- Mastermind – Crack a four-colour code with black and white pegs as hints. Teaches lists, a function with a return value and counting matches.
- Average of grades – Reads grades into a list and computes the average. Teaches lists, do-while and looping over a list.
- Melody – Plays Ode to Joy from a list of notes and lengths. Teaches playing notes, lists and looping over indexes.
- Rectangle – Draws two frames of # at chosen places and in colours. Teaches writing at screen coordinates, colours, loops and your own function with parameters.
- Ball – A ball sprite bounces off the screen edges. Teaches sprites, point coordinates and a loop.
- My Sprite – A rocket drawn from a shape in the program flies across the screen. Open the shape block and draw your own in the grid. Teaches how a sprite's shape is written as a list of strings.
- Aquarium – Six fish swim, bounce off the edges and turn around. Teaches many sprites at once, position lists and looping over indexes.
- Arrows – A star moves around the screen with the arrow keys and stays inside the edges; space quits. Teaches arrow-key controls, writing at coordinates, pace and a game loop.
- Calculator – A menu in a loop: plus, minus, times, divide. Teaches menus, conditions and checking division by zero.
- Geometry – A menu of shapes: perimeter and area of a rectangle, square, circle and right triangle. Teaches functions that return a value.
- Cash machine – A PIN with three tries, then balance, withdraw and deposit. Teaches text input, isdigit, len and menus.
- Factorial – Computes factorials with a function that calls itself. Teaches functions and recursion.
- How old are you – Enter your day, month and year of birth and the program works out your age; on your birthday it wishes you well and plays a tune. Teaches working with today's date and conditions with and and or.
- Clock – Shows today's date, greets you by the time of day and then runs a live clock with hands until you press Space. Teaches working with the time, your own functions, sin and cos, drawing lines and a loop that waits for a key.
- Shopping list – A menu in a loop: add, remove, list and count items. Teaches a list of text, append, remove, in and len.
- Search in a list – Finds a number in a list: the first position and how many times it is there. Teaches linear search and the index.
- Bubble sort – Sorts eight random numbers by swapping neighbours; step through and watch the list in Variables. Teaches nested loops and sorting.
- Simon – A memory game: the computer plays a growing sequence of coloured fields with tones and you repeat it with keys 1–4. Teaches a list as memory, a loop over a list and sound.
- Moon landing – The module falls towards the Moon, you brake with the engine and save fuel, and you must land slowly on the yellow pad. The ground is drawn with lines and the touch is told by the colour of a point. Teaches physics in variables, decimals, conditions and a sprite over a drawing.
Expert
- Catch the Heart – A ship steered with the arrows catches falling hearts. Teaches telling when two sprites touch, arrow-key controls, a function with a return value and lives.
- Pong – Tennis for two: paddles W/S and arrows, the ball bounces by where it hits. Teaches telling when the paddle hits the ball, functions and scoring.
- Breakout – Bounce the ball with the paddle, smash the coloured bricks (top rows score more) and do not let the ball drop. Teaches how a sprite finds a character on the screen, a grid of bricks, points and lives.
- Gomoku – Two players, X and O, five in a row on a 15 × 15 grid; arrows and space. Teaches a list as a grid, functions with return values and searching along a line.
- Three Dice – Stop three spinning dice with Space, matches multiply your points. Teaches random numbers, reading a key, conditions and a function.
- Bomber – A plane over a city: drop bombs with the space bar and flatten the city before you hit it. In an emergency, F fires a shot ahead of the plane that destroys the buildings at its height one by one (costs 100 points). A hit plays a tone, landing and crashing each play their own tune. Teaches a real-time game and sound.
- Snake – An arrow-key game: the snake eats food and avoids walls, itself and poison. It beeps when it eats and plays falling tones at the end. Teaches key controls, game pace, checking what is on the screen, lists, functions and sound.
- Sokoban – The warehouse classic: push the boxes onto the goals; a box can only be pushed and two in a row will not move. Three levels as lists of texts, R restarts. Teaches a grid in a list, movement rules and levels as data.
- Sorting as bars – Bubble sort as coloured bars: the pair being compared lights up and you see each swap. Teaches sorting, your own function and drawing rectangles.
- Function graph – Draws the axes and a graph of the sine function. Teaches screen coordinates, turning values into points and drawing lines.
- Snowflake – The Koch snowflake grows level by level: every line turns into four shorter ones with a spike. Teaches recursion you can see.
- Night flight – A demo in the style of old home computers: scrolling text, stars in three layers, a drawn moon and mountains, a rocket and UFOs on a wave and fireworks, all to the beat of the music. Teaches functions, lists, sin, sprites and drawing.