← Reference

Keep asking: cheat sheet

Console bridge: text in, text out · In any playground, open Reference to copy these.

while loop

Repeat the indented lines for as long as the condition is true.

while True:
    pass
Example
r = 10
while r < 60:
    circle(r)
    r = r + 15
What it draws
A circle each time, while r < 60

add to (+=)

Add to a variable: total += 5 is short for total = total + 5.

total += 1

running total

Start the total at 0 once, then add to it on every pass.

total = 0
while total < 10:
    total += int(input("Add: "))

random number

Pick a random whole number between two values.

import random

n = random.randint(1, 10)