Programming

Python from Zero: variables, types, if / elif / else and loops for beginners

For adults who have never programmed: read short Python programs, work out what they print and choose fixes for common mistakes with variables, if / elif / else and loops. You type or pick each answer; the app does not run code.

3 lessons, 18 steps

Get it on Google Play

Learn to read code before you write it

Python from Zero is a first step into programming for adults who have never written a line of code. Every step shows a short program, about coins in a game, a café bill or a cinema ticket, and asks what it does. Reading and tracing code line by line is the skill the course practices.

Lesson one covers values, variables and types: what the = sign really does, why b keeps its value when a changes later, the difference between int, float and str, and why adding a number to text in quotes stops the program with a TypeError. Lesson two is about comparisons and decisions: True and False, == against =, and which branch of an if / elif / else chain runs. Lesson three covers for and while loops: which numbers range() gives, counting and adding up inside a loop, a range that stops one number too early and a loop that never ends.

Each lesson opens with a short explanation and then gives you six steps. You type what a program prints or the value a variable ends with, pick the change that fixes a bug, put lines in the right order or explain a fix in a sentence or two. The app does not run code: you trace each program in your head or on paper. When your answer is wrong, the AI tutor asks a question that points at the mistake, then gives a hint, then a partial step. Show solution is always available, and a short quiz before and after each lesson shows what changed.

This is one of the editorial courses in Ai Teacher. The problems and worked solutions were written in advance, and facts and definitions were checked against the public sources listed below. Functions, input and files are not part of these three lessons.

What the lessons cover

  • Follow a variable as its value changes and say what a short program prints
  • Tell int, float and str values apart and fix a program that adds text to a number
  • Say whether a comparison is True or False and which branch of an if / elif / else chain runs
  • Trace for and while loops that count or add up, including where range() stops
  • Spot common slips: = in place of ==, a name with the wrong capital letter, a range that stops too early and a loop that never ends

Lessons

  1. Values, variables and types

    6 steps, 4 min intro

  2. Making decisions: comparisons and if / elif / else

    6 steps, 4 min intro

  3. Repeating work: for and while loops

    6 steps, 4 min intro

A variables step from lesson 1

Tutor: Read the program: a = 6, then b = a + 1, then a = 10. What value does b hold after the last line?

You: 11

Tutor: The last line says a = 10. Does it say anything about b?

You: No. b got 6 + 1 when the second line ran, so b is still 7.

Tutor: Right, 7. An assignment stores the result at that moment; giving a a new value later does not change b.

Based on a real step from lesson 1. The tutor's wording varies, and AI can be wrong: the tutor answers from the course material and labels a reply it could not check.

Who this Python course is for

  • You have never programmed and want to see what code is like before you start a longer course.
  • You work with developers or analysts and want to read a simple script without guessing.
  • You started a Python tutorial and got stuck on why a value changed or a loop ran one time too few.
  • You want to practice on your phone, without installing Python.

Questions about Python from Zero

Do I need to install Python?

No. The lessons run in the Ai Teacher app, and the app does not run code. You read each program on screen and type or pick your answer, so all you need is the app.

How is this different from the Non-Programmer's Tutorial course?

Both are for beginners. Non-Programmer's Tutorial for Python 3 was built automatically from chapters of a Wikibooks textbook and was not reviewed by a person; it includes input() and work with text. Python from Zero is an editorial course with problems written in advance, and it spends its three lessons on variables and types, decisions, and for and while loops.

Is the course free?

One lesson in Ai Teacher is free. After that, a subscription opens all lessons. You can pay monthly or yearly in Google Play, and usage limits apply.

Sources

Facts and definitions were checked against these public sources. Lesson text and examples were written independently; no text was adapted.

Start Python from Zero in Ai Teacher

One lesson in the app is free. Ai Teacher is available for Android on Google Play.

Get it on Google Play