Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
382 views

Assignment Module 4

The document contains 3 programming problems involving conditional statements in Python. The first problem checks the age of a person and prints the category they fall into. The second problem calculates train ticket prices based on gender and age. The third problem checks if a number is positive and divisible by 5. Sample code is provided to solve each problem using if-else statements.

Uploaded by

Kamlesh Nikam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
382 views

Assignment Module 4

The document contains 3 programming problems involving conditional statements in Python. The first problem checks the age of a person and prints the category they fall into. The second problem calculates train ticket prices based on gender and age. The third problem checks if a number is positive and divisible by 5. Sample code is provided to solve each problem using if-else statements.

Uploaded by

Kamlesh Nikam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

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 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]

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 sr.citizen, 70% of fare is applicable

# If female and sr.citizen, 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)

# 3.Check 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")

You might also like