(see the video at: https://youtu.be/isLtkpgHM8Y)

One of the things that makes a computer more powerful than a calculator is the ability to do different things based on circumstances. This ability to make decisions is called conditional processing. For example:

`What is 1 + 1? 2`

`Your answer is correct.`

Here is how you do it:

`inp = int(input("What is 1 + 1? "))`

`if inp == 2:`

`print("Your answer is correct.")`

You can think of this as a stimulus/response, such as if you are hungry, you should eat. The first part, the stimulus, is called the condition, and in the above example is the line that says `if inp == 2:` – note a few details: (1) It starts with the word `if`; (2) it’s followed by a relational statement (explained below); and (3) the entire line is ended with a colon.

The relational statement is a statement where two values are compared; in the above example, the value of inp is compared to the number 2. In this case, the relational operator is `==` (which stands for equal to). It is very important to note that if you want to compare something for equality, you have to use the double equals symbol `==`. Why? Because a single equals sign `=` is what you use for an assignment statement (which you’ve been doing for a number of problems now).

Other relational operators are: `>` (greater than), `< `(less than), `!=` (not equal to), `<=` (less than or equal to), and`>=` (greater than or equal to).

After the condition line, you must include one or more lines of code which are the response to the stimulus. In the above case, this is printing the message `Your answer is correct.` This line needs to be indented under the conditional statement or it will not work properly. (In my experience, this is one of the aspects of Python that gives students the most constant trouble.) If there was more than one line of code to execute as the response to the stimulus, you would need to indent each of the lines under the conditional statement. The line or lines of code under the condition statement are called a code block. This means “block” like “block of wood” not like “block your path.”

Practice Problems

Problem # 17-1

Write a program that prompts the user for an even number from 2 to 100. If the value is equal to 82, display “indigo”.

For example:

Please enter an even number from 2 to 100: 82

indigo

OR

Please enter an even number from 2 to 100: 78

Problem # 17-2

Write a program that prompts the user for a Fibonacci number. If the value is less than 2584, display “waiter”.

Problem # 17-3

Write a program that prompts the user for a number from 1 to 20. If the value is less than 12, display “understand”.

Problem # 17-4

Write a program that prompts the user for an even number from 2 to 100. If the value is not equal to 94, display “frost”.