The elif condition is used to multiple conditional expressions after the if condition or between the if and else conditions. The elif block is executed if the specified condition evaluates to True.
Syntax :
if ( condition 1 ) :
// body of the statements will execute if the condition1 is true
elif ( condition 2 ) :
// body of the statements will execute if the condition2 is true
.
.
else :
// body of the statements will execute if the condition1 is false condition2 is False
This program is a Python script that prompts the user to enter a number of days and then calculates a fine based on that number.
So the program is checking the number of days and based on the number of days it is calculating the fine.
# elif Statement in Python """ 0 No Fine 1-5 0.5 5-10 1 10-30 5 >30 Membership Cancel """ days = int(input("Enter The Days : ")) if days == 0: print("Good No Fine") elif days >= 1 and days <= 5: print("Fine Amount : ", days * 0.5) elif days > 5 and days <= 10: print("Fine Amount : ", days * 1) elif days > 10 and days <= 30: print("Fine Amount : ", days * 5) else: print("Membership Cancel")To download raw file Click Here
Enter The Days : 5 Fine Amount : 2.5
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions