Chapter 3 (branches, conditions and while loops)

Random

What is a module?

A module is a file that contains code that can be run in the program

import random

random.randint(1, 6)

random.randrange(6)

if statement

if condition:

code

Define condition

A condition is a evaluation that equates to be true or false

Comparison operators

==

!=

≥=

>

≤=

What does a indentation represent

A block of code

'apples' > 'oranges' true or false

this is FALSE

0 or void elements true or false

FALSE

-5 true or false

TRUE

While loop

while condition:

code

What operator exits the loop

break

What is a sentry variable

It is the variable that is in the condition statement of the loop

What is a simple condition

This is where you compare two values

What is a compound condition

This is where you use logical operators in the condition

What is a logical operator

This is things like: and, not, or