Run your first Python

Python runs your code line by line and stops at the first mistake, naming it in the last line of the traceback. This set covers what a single = does, why a name that differs only in case is a different name, why the body of a loop is indented, and what the slice that reverses a string actually does. The task runs a few short lines and asks you to read what they print.

4 questions 1 task Read the lesson

Questions

Each one is marked as you go, and the explanation arrives straight after, which is the part worth reading.

4 questions, marked as you go.

1 What does a single = do in Python?
2 The line print("Hello, " + Name) raises a NameError. Why?
3 Why must the body of a for loop be indented?
4 What does word[::-1] give you?

Tasks

These need your own device. Run the command in Termux, then paste what it printed. The marking looks at what the output means, so spacing, version numbers and ordering do not matter. If you have not installed anything yet, the lesson covers the setup.

Run a few lines and read the output

This runs four short pieces of Python in one go: a print statement, the arithmetic that works out the minutes in a week, a loop that adds every number from one to one hundred, and a slice that reverses a word. Paste all four lines it prints.

Run this in Termux On your own device. Nothing on this page executes it. The command runs in your terminal, and this box only reads what you paste back.

python3 -c "print('Hello from Python'); print(60 * 24 * 7); print(sum(range(1, 101))); print('Termux'[::-1])"
Marking your own work Both halves of this are checked in your browser, with no server involved, so nothing stops you from pasting output you did not run. The tasks are written so that the easiest way to pass one is to actually do it and read the result, which is the whole intention.

All sets Read the lesson