Scripts, print, and Indentation
Scenario: Your useful experiment must run again tomorrow.
New words, in plain English
- Script - a saved text file of instructions
.pyfile - the usual filename ending for Python source- Indentation - spaces at the start of a line that group code
Save code as hello.py, then run python3 hello.py. print() displays values. Python uses consistent indentation as grammar, usually four spaces inside a block.
Analogy: A Python program is like a clear set of instructions for a careful helper: names label things, indentation groups steps, and errors explain where the helper became confused.
A small, real example
name = "Maya"
if name:
print(f"Hello, {name}!")
Tip: Do not mix tabs and spaces. A formatter can keep indentation consistent.
Goal: Practice this idea in the py-variables-types challenge at/labs/python. Fix the broken program, run it yourself, then usecheckto prove the real end state.