5.1: 🗻 If Statements

Topic

5.1: 🗻 If Statements

Topic Progress:

If statements are one of the main ways that we control the flow of our code. We can surround a number of lines in an ‘if block’, which means the code inside only runs if the ‘boolean conditional’ (remember, True/False) inside the if statement comes out as ‘True’.

Basically, this means we can have our program choose whether it wants to run a certain block of code. In this example if statement, the program prints “Code Successful” to the console if the value of x is 1:

if(x == 1):
print("Code Successful")

Once the machine is sure that x == 1 is True, the program runs all the code indented under the if statement!

For this exercise, your task is to make one change to the first line of the following code, so that the if statement runs successfully, and x is set to 100.

Reminder: The < operator comes back True if the number/variable on the left is smaller than the one on the right.

@

Not recently active