Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
26 views

Module 3 Conditional Statements and Loops

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

Uploaded by

Prashantdasi
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Module 3 Conditional Statements and Loops

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

Uploaded by

Prashantdasi
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

# -*- coding: utf-8 -*-

"""
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’

age = int (input('Enter Age in integer:'))


if age < 10:
print (f'Your are is {age} so your a children')
elif age > 60:
print (f'Your are is {age} so your a Senior Citizen')
elif age >9 and age <61:
print (f'Your are is {age} so your a 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.

Value1 = int(input('Please Provide the any integer Number:'))


if Value1 > 0 and Value1 % 5 ==0:
print (f'The integer value of {Value1} is postive and is divisible by 5')
else:
print ('The integer value of is Negative or is not divisible by 5')

# Conditional Statements
# Please implement Python coding for all the problems.

# 1. A) list1=[1,5.5,(10+20j),’data science’].. Print default functions and


parameters exist in list1.
list4= [1,5.5,(10+20j),"data science"]
print (dir(list4))

# B) How do we create a sequence of numbers in Python?


new_seq = range (30)
print(list(new_seq))
# C) Read the input from keyboard and print a sequence of numbers up to that
number

Input1 = int(input("Kindly Provide the Postive Integer number:"))


new_seq = range(Input1+1)
print(list(new_seq))

#2. Create 2 lists.. one list contains 10 numbers (list1=[0,1,2,3....9]) and


other
#list contains words of those 10 numbers (list2=['zero','one','two',.... ,'nine']).
#Create a dictionary such that list2 are keys and list 1 are values..

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

name = eval(input('Provide the name if any:'))

def greet_person (name,message='How are you?'):


""
print (f'Hi {name} , Hope you enjoyed the fligh!!')

You might also like