<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 IST256 Lesson 03
Conditionals
Zybook Ch3
P4E Ch3
Links
Participation
Step1:  Python’s Relational Operators
<table style="font-size
Step2:  A. 4
B. 5
C. 6
D. 7  
Vote Now
Step3:  A. 4
B. 5
C. 6
D. 7  
Vote Now
Step4:  elif versus a series of if statements
Step5:  Check Yourself
Step6:  A. One
B. Two
C. Three
D. Four  
Vote Now
Step7:  Watch Me Code 2
The need for an exception handling
<ASSISTANT_TASK:>
Python Code:
if boolean-expression:
    statements-when-true
else:
    statemrnts-when-false
Explanation: IST256 Lesson 03
Conditionals
Zybook Ch3
P4E Ch3
Links
Participation: https://poll.ist256.com
Zoom Chat!!!
Agenda
Homework 02 Solution
Non-Linear Code Execution
Relational and Logical Operators
Different types of non-linear execution.
Run-Time error handling
Connect Activity
A Boolean value is a/an ______?
A. True or False value
 B. Zero-based value
 C. Non-Negative value
 D. Alphanumeric value
Vote Now: https://poll.ist256.com
What is a Boolean Expression?
A Boolean expression evaluates to a Boolean value of <font color='red'> True </font> or <font color='green'> False </font>. 
Boolean expressions ask questions.  
GPA >3.2  <span>&#8594;</span>  Is GPA greater than 3.2?  
The result of which is <font color='red'> True </font> or <font color='green'> False </font> based on the evaluation of the expression:  
GPA = 4.0 <span>&#8594;</span>  GPA > 3.2  <span>&#8594;</span>  <font color='red'> True </font>  
GPA = 2.0 <span>&#8594;</span>  GPA > 3.2  <span>&#8594;</span>  <font color='green'> False </font>
Program Flow Control with IF
The IF statement is used to branch your code based on a Boolean expression.
End of explanation
x = 15
y = 20
z = 2
x > y
z*x <= y
y >= x-z
z*10 == x
Explanation: Python’s Relational Operators
<table style="font-size:1.2em;">
    <thead><tr>
        <th>Operator</th>
        <th>What it does</th>
        <th>Examples</th>
    </tr></thead>
    <tbody>
    <tr>
        <td><code> > </code></td>
        <td> Greater than </td>
        <td> 4>2 (True)</td>
    </tr>
    <tr>
        <td><code> < </code></td>
        <td> Less than </td>
        <td> 4<2 (False)</td>
    </tr>
    <tr>
        <td><code> == </code></td>
        <td> Equal To </td>
        <td> 4==2 (False)</td>
    </tr>
    <tr>
        <td><code> != </code></td>
        <td> Not Equal To </td>
        <td> 4!=2 (True)</td>
    </tr>
    <tr>
        <td><code> >= </code></td>
        <td> Greater Than or Equal To </td>
        <td> 4>=2 (True)</td>
    <tr>
        <td><code> <= </code></td>
        <td> Less Than or Equal To </td>
        <td> 4<=2 (True)</td>
    </tr>
  </tbody>
</table>
Expressions consisting of relational operators evaluate to a Boolean value
Watch Me Code 1!
```
  Do you need more milk?  
When the Fudge family has less than 1 gallon of milk, 
  we need more!
```
Check Yourself: Relational Operators
On Which line number is the Boolean expression True?
End of explanation
raining = False
snowing = True
age = 45
age < 18 and raining
age >= 18 and not snowing
not snowing or not raining
age == 45 and not snowing
Explanation: A. 4
B. 5
C. 6
D. 7  
Vote Now: https://poll.ist256.com
Python’s Logical Operators
<table style="font-size:1.2em;">
    <thead><tr>
        <th>Operator</th>
        <th>What it does</th>
        <th>Examples</th>
    </tr></thead>
    <tbody>
    <tr>
        <td><code> and </code></td>
        <td> True only when both are True </td>
        <td> 4>2 and 4<5 (True)</td>
    </tr>
    <tr>
        <td><code> or </code></td>
        <td> False only when both are False </td>
        <td> 4<2 or 4==4 (True)</td>
    </tr>
    <tr>
        <td><code> not </code></td>
        <td> Negation(Opposite) </td>
        <td> not 4==2 (True)</td>
    </tr>
    <tr>
        <td><code> in </code></td>
        <td> Set operator </td>
        <td> 4 in [2,4,7] (True)</td>
    </tr>
  </tbody>
</table>
Check Yourself: Logical Operators
On Which line number is the Boolean expression True?
End of explanation
if boolean-expression1:
    statements-when-exp1-true
elif boolean-expression2:
    statements-when-exp2-true
elif boolean-expression3:
    statements-when-exp3-true
else:  
    statements-none-are-true
Explanation: A. 4
B. 5
C. 6
D. 7  
Vote Now: https://poll.ist256.com
Multiple Decisions: IF ladder
Use elif to make more than one decision in your if statement. Only one code block within the ladder is executed.
End of explanation
x = int(input("enter an integer"))
# one single statement. only one block executes
if x>10:
    print("A:bigger than 10")
elif x>20:
    print("A:bigger than 20")    
# Independent if's, each True Boolean executes a block
if x>10:
    print("B:bigger than 10")
    
if x>20:
    print("B:bigger than 20")
Explanation: elif versus a series of if statements
End of explanation
if x > 20:
    if y == 4:
        print("One")
    elif y > 4:
        print("Two")
    else:
        print("Three")
else:
    print("Four")
Explanation: Check Yourself: IF Statement
Assuming values x = 77 and y = 2 what value is printed?
End of explanation
try:
    statements-which
    might-throw-an-error
except errorType1:
    code-when-Type1-happens
except errorType2:
    code-when-Type2-happens
finally:
    code-happens-regardless
Explanation: A. One
B. Two
C. Three
D. Four  
Vote Now: https://poll.ist256.com
End-To-End Example, Part 1:
Tax Calculations!
The country of “Fudgebonia” determines your tax rate from the number of dependents:  
0 <span>&#8594;</span> 30%  
1 <span>&#8594;</span> 25%  
2 <span>&#8594;</span> 18%   
3 or more <span>&#8594;</span> 10%  
Write a program to prompt for number of dependents (0-3) and annual income.  
It should then calculate your tax rate and tax bill. Format numbers properly!  
Handle Bad Input with Exceptions
Exceptions represent a class of errors which occur at run-time. 
We’ve seen these before when run a program and it crashes due to bad input. And we get a TypeError or ValueError.
Python provides a mechanism try .. except to catch these errors at run-time and prevent your program from crashing.
Exceptions are <i>exceptional</i>. They should ONLY be used to handle unforeseen errors in program input. 
Try…Except…Finally
The Try... Except statement is used to handle exceptions. Remember that exceptions catch run-time errors!
End of explanation
try:
    x = float(input("Enter a number: "))
    if x > 0:
        y =  "a"
    else:
        y = "b"
except ValueError:
    y = "c"
print(y)
Explanation: Watch Me Code 2
The need for an exception handling:
- Bad input
- try except finally
- Good practice of catching the specific error
Check Yourself: Conditionals Try/Except
What prints on line 9 when you input the value '-45s'?
End of explanation
<END_TASK>