You are here: The Path · Stage 3

Stage 3

The terminal is a filing cabinet.

You are always standing in one folder. Commands move you, show you names, or open a page so you can write. Then a program is only a text file with instructions.

Tap a command

Each button is a word you can type. The meaning appears under them. Type them in Termux. Watching here is not the same as typing there.

Pick one

Start with pwd. It answers a simple question: where am I?

Your first program

The ~ means “my home folder inside Termux.” .py on the end is how the computer guesses the language.

mkdir ~/learn
cd ~/learn
nano hello.py

Type these three lines exactly, including quotes:

hello.py
print("Hello from my phone")
name = input("Your name: ")
print("Hi", name)

What the lines mean

print(...) shows text on the screen.

name = input("Your name: ") asks a question, then remembers the answer in a box labeled name. That box is a variable. A variable is a labeled sticky note that holds a value.

print("Hi", name) shows the word Hi, then whatever is on that sticky note.

Save in nano

Ctrl+O (the letter O, for out / write). Enter to confirm the name. Ctrl+X to leave.

Then run it:

python hello.py

The phone should say hello and ask your name.

If it breaks

Read the message text. It is trying to tell you which line broke. Copy the exact message into the phone tutor and ask: “Explain this like I have never coded.”

Nano will not close? Ctrl+O, Enter, Ctrl+X. Termux often shows an extra CTRL row.