Explainer
Explain Python code in plain English
Paste Python and read what it does: what it takes in, each check it makes, each answer it gives, and the line each one comes from. Thunder reads the code itself, with no AI, so the same code always gets the same explanation.
Type or paste your own. It explains as you type, in your browser: nothing is sent anywhere.
In plain English
Shipping cost
Author's note: Five dollars plus two per kilo; express costs half as much again.
You give it: weight, express
- Ask: Is weight at most 0? (line 3)
Yes:
- Stop: ValueError: "weight must be positive" (line 4)
No: continue
- `cost = 5 + weight * 2` (code, not explained) (line 5)
- Ask: Is express set? (line 6)
Yes:
- Sets cost to cost times 1.5 (line 7)
No: continue
- Gives back cost (line 8)
Grade: a rule
You give it: score
- Ask: Score is at least 90? (line 12)
Yes:
- Answer: A (line 12)
No:
- Ask: Score is at least 80? (line 14)
Yes:
- Answer: B (line 14)
No:
- Ask: Score is at least 70? (line 16)
Yes:
- Answer: C (line 16)
No:
- Answer: F (line 18)
Total
You give it: prices
- Sets result to 0 (line 22)
- For each price in prices (line 23)
For each:
- `result = result + price` (code, not explained) (line 24)
- Gives back result (line 25)How to read it
- You give it: the inputs. Ask: a check, with what happens on Yes and No. Answer or Gives back: what comes out.
- Every step names its line, so you can check it against the code.
- A line Thunder can't say in words yet is shown as code and marked code, not explained. It is never guessed.
More than an explanation
- Read a file or a whole repository this way in Thunder Code, and at five levels of detail, from the big picture to the original code, in Semantic Zoom.
- Python can also be converted: Python to Thunder, and from there to Java, C#, TypeScript, Go, or Rust.
The example
Written by the Thunder compiler 2.0.0 while this page was built, not by hand.
Python
def shipping_cost(weight, express):
"""Five dollars plus two per kilo; express costs half as much again."""
if weight <= 0:
raise ValueError("weight must be positive")
cost = 5 + weight * 2
if express:
cost = cost * 1.5
return cost
def grade(score):
if score >= 90:
return "A"
elif score >= 80:
return "B"
elif score >= 70:
return "C"
return "F"
def total(prices):
result = 0
for price in prices:
result = result + price
return resultIn plain English
Shipping cost
Author's note: Five dollars plus two per kilo; express costs half as much again.
You give it: weight, express
- Ask: Is weight at most 0? (line 3)
Yes:
- Stop: ValueError: "weight must be positive" (line 4)
No: continue
- `cost = 5 + weight * 2` (code, not explained) (line 5)
- Ask: Is express set? (line 6)
Yes:
- Sets cost to cost times 1.5 (line 7)
No: continue
- Gives back cost (line 8)
Grade: a rule
You give it: score
- Ask: Score is at least 90? (line 12)
Yes:
- Answer: A (line 12)
No:
- Ask: Score is at least 80? (line 14)
Yes:
- Answer: B (line 14)
No:
- Ask: Score is at least 70? (line 16)
Yes:
- Answer: C (line 16)
No:
- Answer: F (line 18)
Total
You give it: prices
- Sets result to 0 (line 22)
- For each price in prices (line 23)
For each:
- `result = result + price` (code, not explained) (line 24)
- Gives back result (line 25)