Write a program in Python to check if the user is eligible to marry.
★ Hints :
(i) The minimum age for males for marriage is 21 years.
(ii) The minimum age for females for marriage is 18 years.
★ Points to note :-
(i) Program should ask the user to enter his/her important details.
(ii) It's mandatory for the program to ask the gender and age of the user.
Answers
Answer:
Have a great time ahead
Explanation:
First of all, we are reading the input from the user using the input() method. This method returns a string, so we are using_ int(input())_ to convert the input to an integer.
Then we are checking if the value is greater than 18 or not. This is known as a ternary conditional operator in python. If you are familiar with C language, then you may have seen the “condition ? statement : statement ” operator. This is similar to the one we have used in this program. So, it will check if the user is eligible or not for voting and print out the result accordingly. You can also use the_ ‘if-else’_ block to achieve the same result. But ternary if-else will fit more for this scenario. Ternary if-else is an important python condition checker. If you want to check any condition with only one line, you can use ternary if-else.