MODULE-4 Conditional Statements
Please write Python Programs for all the problems .
1. Take a variable ‘age’ which is of positive value and check the following:
a. If age is less than 10, print “Children”.
b. If age is more than 60 , print ‘senior citizens’
c. If it is in between 10 and 60, print ‘normal citizen’
2. Find the final train ticket price with the following conditions.
a. If male and [Link], 70% of fare is applicable
b. If female and [Link], 50% of fare is applicable.
c. If female and normal citizen, 70% of fare is applicable
d. If male and normal citizen, 100% of fare is applicable
[Hint: First check for the gender, then calculate the fare based on age factor.. For both
Male and Female ,consider them as [Link] if their age >=60]
3. Check whether the given number is positive and divisible by 5 or not.
################ Assingments MODULE 4 Conditional Statements ################
# Take a variable ‘age’ which is of positive value and check the following:
# If age is less than 10, print “Children”.
# If age is more than 60 , print ‘senior citizens’
# If it is in between 10 and 60, print ‘normal citizen’
age = 28
if age <=10:
print("children")
elif age >=60:
print('senior citizens')
else:
print('normal citizen')
elif age >=10 and age <=60:
print('normal citizen')
# Find the final train ticket price with the following conditions.
# If male and [Link], 70% of fare is applicable
# If female and [Link], 50% of fare is applicable.
# If female and normal citizen, 70% of fare is applicable
# If male and normal citizen, 100% of fare is applicable
Ticket_price = 200
passanger = 'male'
age = 56
if passanger == 'male' and age >=60:
print('70% of fare is applicable:',70/100*Ticket_price)
elif passanger == 'female' and age >=60:
print('50% of fare is applicable: ', 50/100*Ticket_price)
elif passanger == 'female' and age <=60:
print('70% of fare is applicable: ', 70/100*Ticket_price)
else:
print('100% of fare is applicable: ',100/100*Ticket_price)
# [Link] whether the given number is positive and divisible by 5 or not.
n=int(input("Enter your number: "))
if n%5==0:
print(f"{n} divisible by 5")
else:
print(f"{n} not divisible by 5")