Activities 1.10 – 1.17. Use this to review, or to fill in a definition you missed.
A comparison produces a boolean, and an if statement uses that boolean to decide whether to run a block. In Python, indentation is what marks the block.
True or False.== or >= that compares two values and produces a boolean.True.if statement checks.and, or, and not — combine or invert booleans.An if can be extended into a chain. Only the first branch whose condition is true will run, and this is also where you first imported the random module.
False.if — only the first true branch runs.A conditional can live inside another conditional, which lets you ask a follow-up question only when the first answer was yes.
if) inside another.A while loop repeats as long as its condition holds. Something inside the loop has to change that condition, or it never ends.
True.False, so it never stops.round() — avoid naming variables the same thing.When you know how many times to repeat, a for loop is the better fit. range() supplies the numbers to count through.
for loop to count through.A loop inside a loop runs the inner block once for every combination — the inner loop finishes completely on each pass of the outer one.