Module 3 Conditional Statements and Loops
Module 3 Conditional Statements and Loops
Conditional Statements
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 sr.citizen, 70% of fare is applicable
b. If female and sr.citizen, 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 sr.citizens if their age >=60]
Conditional Statements
4. Write a simple user defined function that greets a person in such a way that :
i) It should accept both the name of the person and message you want to deliver.
ii) If no message is provided, it should greet a default message ‘How are you’