Style

PEP 8 names, snake_case, constants, and a short function.

PEP 8 is the usual Python style. You do not need a linter in this tab. You do need names, spacing, and short functions a teammate can read.

Goal

Rewrite a messy kiosk snippet into snake_case helpers and a CONSTANT.

Before

def Tot(u,p):
    return round(u*p*1.16,2)
print(Tot(2,10))

That works. It does not read.

After

TAX = 0.16

def line_total(units, price):
    return round(units * price * (1 + TAX), 2)

print(line_total(2, 10))
  • TAX is a constant (all caps).
  • line_total is snake_case.
  • Spaces around *.
  • A blank line before the top-level print in a real file (here the script is short).

Names

cities = ["Nairobi", "Mombasa", "Kisumu"]
n_cities = len(cities)
is_coast = "Mombasa" in cities
print(n_cities, is_coast)

n_cities counts. is_coast is a boolean. Avoid data, temp, x unless the scope is three lines.

Pitfall

This editor does not run black or ruff. Paste tidy code anyway — reviews start with names, not pixels.