# MY JOURNEY AT BLOCKFUSE LABS WEEK 9.
This week we review the last week class again that is our data types class. the dictionary, tuple and others you can check my last update to see that. So the following day we look at the conditionals statement that are the if-else statements. the if-else statement are used for stating conditions like if the condition match it should do something otherwise it should do the it should do the other way round. and this conditionals has another one called elif that means if else and this is how it used. if condition match do something elif condition match do this else do this. this is how the conditional statement work don't worry you may not understand now but am gonna do the practical example bellow:
```python
# python conditionals.
num1 = 10
num2 = 2
# so now we will used the conditional statement.
# starting by the if block
if num1 > num2:
print('Greater')
# The elif block
elif num1 >= num2:
print('is Greater or Equal')
# The else block
else:
print('Not greater')
```
This is the basic way conditionals works. if you check the snipet you will see me putting coloum at the end if the conditions that is for the end of line without it your code will throw an error. and in coditionals you can put and if block only without all other ones. you can also used the if and elif statement without the else block. you can used only the if and else but you can't used just the else without the the if or the elif without the if block practical example:
```python
# example of if and elif block without else
num1 = 20
num2 = 14
if num1 == num2:
print('num1 equal num2')
elif num1 > num2:
print('num1 greater')
elif num1 < num2:
print('num1 lesser')
```
example of if and else without elif. this is usually done when you have two conditions to state.
```python
num1 = 2
num2 = 10
if num1 >= num2:
print('num1 greater or equal')
else:
print('num1 lesser!')
```
###### We did some exercise with conditional with will be put down here:
###### exercise 1
```python
score = float(input('Enter a number to have a grade: \n >>>'))
if score >= 70 and score <= 100:
print('Grade is A')
elif score >= 50 and score <= 69.9:
print('Grade is B')
elif score >= 40 and score <= 49.9:
print('Grade is C')
elif score >= 30 and score <= 39.9:
print('Grade is D')
elif score >= 0 and score < 30:
print('Grade is F')
else:
print('INVALID SCORE')
```
###### exercise 2
```python
customer = {
'name': 'Godiya',
'order_amount': 25000,
'loyalty_card': True,
'is_student': False
}
discount_percentage = 0
if customer["loyalty_card"]:
discount_percentage += customer["order_amount"] // 100 * 10
if customer["order_amount"] > 20000:
if customer["loyalty_card"]:
discount_percentage += customer["order_amount"] // 100 * 5
else:
print('Free drink for you')
elif customer['is_student']:
discount_percentage += customer["order_amount"] // 100 * 5
final = customer['order_amount'] - discount_percentage
order_summary = {
"order_amount": customer['order_amount'],
'Discount_percentage': discount_percentage,
'amount_to_pay': final
}
print(order_summary)
```
###### exercise 3
```python
Input = int(input('enter your age: '))
if Input >= 18:
print('CAN BUY TICKET')
if Input >= 60:
print('SENIOR DISCOUNT')
else:
if Input < 18 and Input >= 12:
print('TEEN TICKET')
else:
print('KID TICKET')
```
###### exercise 4
```python
budget = float(input('Enter your budget: '))
if budget >= 500:
if budget >= 1000:
print("You can get an Google Pixel 9pro.")
else:
if budget >= 200:
print('You can get a Redmi.')
else:
print('Save more.')
```
There are many exercise we did and i can't put them all here but you can make research for more.
We also look at match:
The match work same as the conditionals it's used for stating conditions instead of writing mant if-else block you can used the match instead. let look at how it works:
```python
# the match statement syntax
match expression:
case a:
code block
case b:
code block
case c:
code block
```
As you can see from the snipet above that is the syntax for expressing match. let make a reasonable example:
```python
number = 10
match number:
case 3:
print('number is three')
case 10:
print('number is 10')
case 5:
print('number is 5')
case_:
print('no expression match!')
```
This is how the match expression works. The match expression is evaluated once. The value of the expression is compared with the values of each case. If there is a match, the associated block of code is executed. if there is no match it will execute the last line of code by defualt that is the (case _). look out for my next update.
# NEVER SETTLE:100: