A company insures its drivers in the following cases:
This program is a simple example of using the if-elif-else statement in Python. The program takes input from the user for the age, sex, and marital status of a driver. It then uses this input to check if the driver should be insured or not. If the marital status is 'M' or 'm' (married), the program will print "Driver should be Insured".
If the marital status is 'U' or 'u' (unmarried) and the sex is 'M' or 'm' (male) and the age is greater than 30, the program will print "Driver should be Insured". If the marital status is 'U' or 'u' (unmarried) and the sex is 'F' or 'f' (female) and the age is greater than 25, the program will print "Driver should be Insured". If none of these conditions are met, the program will print "Driver should not be Insured".
age = int(input("Enter the Age :")) sex = input("Enter the Gender M/F :") status = input("Enter the Marital Status U/M :") if( status == 'M' or status == 'm'): print( "Driver should be Insured" ) elif( status == 'U' and sex == 'M' and age > 30 or status == 'u' and sex == 'm' and age > 30 ): print( "Driver should be Insured" ) elif( status == 'U' and sex == 'F' and age > 25 or status == 'u' and sex == 'f' and age > 25 ): print( "Driver should be Insured" ) else: print( "Driver should not be Insured" ) """ age = int(input("Enter the Age :")) sex = input("Enter the Gender M/F :") status = input("Enter the Marital Status U/M :") if ( ( status == 'M') or ( status == 'U' and sex == 'M' and age > 30 ) or( status == 'U' and sex == 'F' and age > 25 ) ): print( "Driver should be Insured" ) else: print( "Driver should not be Insured" ) """
Enter the Age :21 Enter the Gender M/F :F Enter the Marital Status U/M :U Driver should not be Insured
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions