Conditional
Conditional
1. Conditional statements in Python are used to control the flow of a program based
on certain conditions.
3. The primary conditional statements in Python are if, elif (short for "else if"),
and else.
# Types:
1. if Statement:
The if statement is used to execute a block of code only if a specified
condition is true.
2. if-else Statement:
The if-else statement extends the if statement by providing an alternative block
of code to n execute when the condition is fals
3. if-elif-else Statement:
The if-elif-else statement allows you to check multiple conditions in sequence.
If the first condition is false, it moves on to the next elif (else if)
condition, and so on. The else block is executed if none of the conditions
is true.
a=10
b=20
a,b=b,a
print(a)
print(b)
# wap to calculate no of leave of an employ if the leaves <=5 in year then give a
bonus of 15% and if the leaves are more the 10 then deduct his salary by 20%
leaves=int(input("enter your total annual leaves "))
salary=int(input("enter your salary"))
if(leaves<=5):
print("you got a bonus of 15%")
bonus=salary*0.15
print("the total bonus amount",bonus)
new_salary=salary+bonus
print("salry after bonus",new_salary)
elif(leaves>=10):
print("you will be charge a tax of 10%")
deduct=salary*0.10
print("the total deducted amount",deduct)
new_salary=salary-deduct
print("salry after deduction",new_salary)
else:
print("you got nothing! please try again later")