← Courses

Python for AI — Beginner Foundations

Data Science

Basics · Lesson 25 of 76

Code formatting

Code is read far more often than it's written, so making it readable is a real skill. Python programmers follow a shared style (called PEP 8). The basics:

  • Spaces around operators: total = price + tax, not total=price+tax.
  • Clear names: student_count, not sc or x.
  • 4 spaces for each level of indentation.
  • A blank line between separate ideas.
Python

You don't have to memorise every rule — later you'll meet tools (like Ruff) that tidy formatting for you automatically.

Your turn: rewrite x=2*3+1 with spaces around the operators, then print x.

You’re reading for free. Sign in to keep your progress and earn a certificate when you finish.Sign in to keep my progress →