If Statements

What is an if statement?

An if statement allows you to set a condition on whether particular cod runs. For example, using a variable called game_activate, you can use an if statement to ensure the code that begins a game only runs if this variable is set to True.

What are if statements used for?

An if statement allows programmers to respond to user input, and it changes conditions during a program's execution.

What is an elif statement?

An elif statement is used to make your program respond to multiple conditions. This code structure means "if one condition applies, do this; else if a different condition applies, do something different." You can chain together as many of these certain conditions as you need.

What is an else statement?

An else block runs a particular block of code when all other conditions don't apply. An else block must always be the final block in an if-else chain.