Module 3 Conditional Statements and Loops
Module 3 Conditional Statements and Loops
"""
Created on Tue Sep 17 12:52:31 2024
@author: Admin
"""
#MODULE – 3 ASSIGNMENT
#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
Base_Fare = 2500
Final_price=''
age = int (input('Enter Age in integer:'))
Gender = input ('Please enter gender Male or Female:')
if [age >= 60 and Gender =='Male'] or [age < 60 and Gender =='Female'] :
Final_price = Base_Fare * 30 / 100
print (f'Your are a {Gender} and your age is {age} so your a Citizen after
discount your ticket price is amounted to rs {Final_price}')
elif age >= 60 and Gender =='Female':
Final_price = Base_Fare * 50 / 100
print (f'Your are a {Gender} and your age is {age} so your a Senior Citizen
after discount your ticket price is amounted to rs {Final_price}')
else:
print (f'Your are a {Gender} and your age is {age} so your a Normal Citizen
after discount your ticket price is amounted to rs {Base_Fare}')
#3. Check whether the given number is positive and divisible by 5 or not.
# Conditional Statements
# Please implement Python coding for all the problems.
Lis1=[0,1,2,3,4,5,6,7,8,9]
Lis2=['Zero','one','Two','Three','Four','Five','Six','Seven','Eight','Nine']
Dictonary1 = dict(zip(Lis2,Lis1))
print (Dictonary1)
# 3. Consider a list1 [3,4,5,6,7,8]. Create a new list2 such that Add 10 to the
even number and multiply with 5 if it is an odd number in the list1..
New_list1 = [3,4,5,6,7,8]
New_list_even=[]
New_list_odd=[]
for num in New_list1:
if num % 2 ==0:
New_list_even.append(num + 10)
else:
New_list_odd.append(num + 5)
print ('The Odd List is : ',New_list_odd)
print (' The Even list is : ',New_list_even)
#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’
# Ex: Hello ---xxxx---, How are you -🡪 default message.
# Ex: Hello ---xxxx---, --xx your message xx---