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

Module 3 Conditional Statements and Loops

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

Module 3 Conditional Statements and Loops

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

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

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

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.
B) How do we create a sequence of numbers in Python?
C) Read the input from keyboard and print a sequence of numbers up to that number

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

© 360DigiTMG. All Rights Reserved.


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

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

© 360DigiTMG. All Rights Reserved.

You might also like