Python in plain terms
Write and run your first Python script, understand its values and names, and diagnose the first common errors.
Work here, beside the explanation
Python gives the computer the same kinds of instructions you have already connected as blocks. A say block becomes print(...); a set-variable block becomes an assignment; an if block becomes an indented if statement. You now type the connections and punctuation into a text editor. That adds syntax to learn, but it does not erase what you know about order, values, repetition, or decisions. Build this small greeting before introducing a model.
Each numbered stage below shows a complete program. Try this stage copies it into the editor beside the article, including every line it needs from earlier stages, so it works even after you reload the page. Read the program first, predict what it will print, then press Run. Loading a stage replaces what is in the editor; Undo brings your own version back.
Build with me · 1
1. Turn one say block into one line
In blocks, you placed text in a say block and ran it. Here print names Python's display function. The opening parenthesis begins its arguments, and the closing parenthesis ends them. The quotes mark the text to display; Python does not print those outer quotes. The editor is where instructions belong. Output is where their result appears. Typing or editing a line alone does not execute it: pressing Run does. A function is a named procedure; for now you are calling an existing one.
print("Hello, Ada")Type the line yourself, or load it, and predict the exact message before running. Watch the loading status if this is the first Python run.
What to look for
Output contains Hello, Ada. It does not contain print, parentheses, or the quotation marks.
Make it yours
Choose a fictional name or greeting. Keep the opening and closing quote the same kind.
Build with me · 2
2. Translate a named-value block
name = "Ada" is the typed equivalent of setting a variable named name to the text Ada. Read = as 'store the value on the right under the name on the left'. On the next line, name has no quotes because Python should look up that stored value. In print("Hello", name), the comma separates two arguments; print puts a space between their displayed forms. Running starts at the first line again, so the assignment occurs before the lookup.
name = "Ada"print("Hello", name)Run once, then change only the value assigned to name and run again. Both lines together are a complete program.
What to look for
The new name appears after Hello. Printing "name" with quotes would instead display the literal word name.
Make it yours
Use your own fictional name. Then deliberately print the quoted word name to hear the difference in meaning in your own words.
Build with me · 3
3. Store a number instead of text
age = 14 stores an integer: a whole number. The greeting is a string: text. Quotes distinguish the string "14" from the number 14 even though their printed forms look alike. Names are case-sensitive, so age and Age are different names. A good name describes a value, such as image_count or accuracy. It may contain letters, digits, and underscores, but cannot start with a digit or contain spaces. Avoid replacing useful built-in names such as print or list.
name = "Ada"print("Hello", name)age = 14print("Age:", age)Find the two assignments and the two display calls. Run and compare the displayed number with its code.
What to look for
The program displays the greeting and Age: 14, on separate lines.
Make it yours
Choose any fictional age from 1 to 100. There is no need to provide personal information.
Build with me · 4
4. Calculate before assigning
The right-hand side of next_age = age + 1 is evaluated first. With age equal to 14, the addition produces 15; next_age then refers to that result. This is the same as putting an addition block into a variable's value slot. The original age is still 14 because this line assigns to a different name. age = age + 1 would instead replace age's value. Arithmetic uses +, -, *, /, and ** for powers. Parentheses can group calculations, just as nested number blocks group operations.
name = "Ada"print("Hello", name)age = 14print("Age:", age)next_age = age + 1print("Next birthday:", next_age)Before Run, calculate next_age for your chosen age. Then change the added amount from 1 to 2 and rerun.
What to look for
Next birthday: 15 appears with the original example. Your chosen age changes the result predictably.
Make it yours
Add print("In five years:", age + 5) as another display line without introducing a new variable.
Build with me · 5
5. Translate an if block
if next_age >= 15: asks a question. The >= comparison returns a boolean, True or False. The colon introduces the branch, and the four spaces before its print line say that instruction belongs inside the branch. else: is aligned with if, and its indented line handles the false case. In blocks, the C-shaped if block enclosed its contents. In Python, indentation shows that same enclosure. This threshold is a made-up example, not an age rule for using this website.
name = "Ada"print("Hello", name)age = 14print("Age:", age)next_age = age + 1print("Next birthday:", next_age)if next_age >= 15: print("Next birthday reaches our example target.")else: print("Our example target is later.")Run once with age 14 and once with age 10. Keep four spaces before each branch's print instruction.
What to look for
Exactly one branch message prints on each run. The greeting and next-age lines still execute before the decision.
Make it yours
Choose a different example target and explain both possible messages before testing them.
Build with me · 6
6. Distinguish assignment from a question
A single equals sign assigns a value. Two equals signs, ==, ask whether two values are equal. != asks whether they differ. Comparisons return True or False, without quotation marks: those are boolean values, not words. and requires both questions to be true; or requires at least one; not reverses a boolean. These are the typed versions of the question-shaped logic blocks you used earlier. A successful comparison does not store a new age.
name = "Ada"print("Hello", name)age = 14print("Age:", age)next_age = age + 1print("Next birthday:", next_age)print("Age equals 14:", age == 14)print("Age differs from 14:", age != 14)print("At least 10 and below 20:", age >= 10 and age < 20)Predict each of the three booleans for your age before running. Change age and test the predictions.
What to look for
With age 14, the three displayed booleans are True, False, and True.
Make it yours
Store one comparison in a name such as meets_target, then print that name. A variable can refer to a boolean as well as text or a number.
Build with me · 7
7. Read choices in Terminal
A program can receive values instead of fixing them in its source. input("Name: ") pauses the running program and displays a clear prompt in Terminal; type a fictional name, then press Enter or Send. It returns that text. int(input("Age: ")) pauses at the next prompt, then converts the entered numeric text to an integer. The nested calls play the same role as a number-conversion block around an answer block. Answer with Ada and 14, not assignments or quote marks.
# Fictional details are fine. Answer each Terminal prompt with data, not Python code.name = input("Name: ")age = int(input("Age: "))next_age = age + 1print("Hello", name)print("Next birthday:", next_age)if next_age >= 15: print("Next birthday reaches our example target.")else: print("Our example target is later.")Load the stage and press Run. Answer the Name: prompt, then answer the Age: prompt in Terminal. Run again with two different fictional answers.
What to look for
After answers Ada and 14, the greeting and branch use those values. The source code stays unchanged when the Terminal answers change.
Make it yours
Use a fictional name and a new numeric age. Entering fourteen at Age: produces ValueError; run again and enter a numeral to repair it.
Build with me · 8
8. Compare text and numerical operations
Adding two numbers performs arithmetic. Adding two strings joins them. Thus 8 + 1 is 9, while "8" + "1" is the text 81. int converts valid whole-number text; it does not infer the meaning of every word. Division with / produces a decimal-valued float, so 17 / 20 is 0.85. type tells you the kind of value you supplied. This inspection is useful when a program reads a CSV or user input and receives strings where a numerical model needs numbers.
print(8 + 1)print("8" + "1")print(int("8") + 1)print(17 / 20)print(type("8"))print(type(8))print(type(0.85))print(type(True))Predict the first four outputs, then run. Read the four type names as evidence about values, not something to memorise for a quiz.
What to look for
The first four outputs are 9, 81, 9, and 0.85. The type lines identify str, int, float, and bool.
Make it yours
Change one numeric string to a different numeral. Next try an invalid conversion and read the final error line; return to valid input afterward.
Build with me · 9
9. Name and display a measurement
These counts are a fictional evaluation for learning Python. Accuracy is the number correct divided by the number evaluated. round(accuracy, 3) returns a value rounded for display; it does not change accuracy because we did not assign the result back. Multiplying a proportion by 100 expresses a percentage. A target of 0.8 is a teaching choice, not a universal definition of a useful model. An error such as misspelling correct is different from a logic mistake such as dividing by the wrong total: both deserve checking.
total = 20correct = 17accuracy = correct / totalmeets_target = accuracy >= 0.8print("Correct:", correct, "of", total)print("Accuracy:", round(accuracy, 3))print("Percent:", round(100 * accuracy, 1))print("Meets target:", meets_target)Run, then trace the path from correct and total to the displayed percentage. Keep total positive and correct between zero and total.
What to look for
The example displays accuracy 0.85, percent 85.0, and True for the chosen target.
Make it yours
Choose your own fictional counts. Calculate the answer before running so you can catch a plausible but wrong formula.
Build with me · 10
10. Assemble and check your greeting
You have now typed the same categories of instructions as blocks: display, named values, arithmetic, terminal input, and decisions. The comment begins with # and explains a choice without becoming an instruction. Blank lines group related work. If an error occurs, read the final error message and the indicated source line. NameError often means a misspelled or not-yet-created name; SyntaxError may point to a missing quote, bracket, or colon; an indentation error points to the structure that blocks previously drew for you. Repair one cause, then run the whole program again.
# Fictional details are fine. Answer each Terminal prompt with data, not Python code.name = input("Name: ")age = int(input("Age: "))next_age = age + 1print("Hello", name)print("Next birthday:", next_age)if next_age >= 15: print("Next birthday reaches our example target.")else: print("Our example target is later.") # Comments explain our choices; Python ignores them.completed = 2completed = completed + 1print("Lessons completed:", completed)Build your own final version in the lesson editor. Run it twice: answer the prompts once for each branch, then compare with the folded reference only after trying.
What to look for
After entering Ada and 14 in Terminal, the greeting addresses Ada, the next age is 15, and completed lessons is 3. Your personal choices may differ.
Make it yours
Add one more clearly labelled calculation of your choice. Explain which block you would use for each Python instruction.
The bridge you have built
Blocks made valid connections visible. Python asks you to express those same connections with names, parentheses, colons, and indentation. Neither representation gives a program understanding of your intention: the computer follows exactly the instructions provided. You already know how to break a task into small operations. Keep doing that, run often, and inspect the result after each deliberate change.
Later lessons introduce lists, loops, functions, and libraries one at a time. You do not need to memorise unfamiliar training code before those foundations exist.
The complete reference is folded away below. Compare it with your work after trying the steps; changing a personal choice such as a name, a colour, or a display threshold can produce a different valid program.
Full reference solution
This is the final complete program built in the walkthrough. All its setup is included. Personal choices may differ in your own version; model scores are measured when you run, not promises about a future dataset.
# Fictional details are fine. Answer each Terminal prompt with data, not Python code.name = input("Name: ")age = int(input("Age: "))next_age = age + 1print("Hello", name)print("Next birthday:", next_age)if next_age >= 15: print("Next birthday reaches our example target.")else: print("Our example target is later.") # Comments explain our choices; Python ignores them.completed = 2completed = completed + 1print("Lessons completed:", completed)Compare this with your version. Different names and personal choices are fine when the program follows the same logic.
Keep your progress
Sign in and every reading, quiz, and exercise you finish is saved.