0% found this document useful (0 votes)
40 views

Experiment No-6 TITLE: Functions in Python Objective: Understanding Functions in Python. List of Lab Works

The document outlines 4 experiments involving functions in Python, including writing functions to calculate employee salary based on basic salary and allowances, check eligibility for a traveler to fly based on baggage weight, immigration status, and security clearance, develop a menu driven program for a professor to check student attendance status and generate grades, and find the maximum and minimum values in a list of tuples using a lambda function. The experiments are designed to practice writing and using different types of functions in Python programs to solve various problems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Experiment No-6 TITLE: Functions in Python Objective: Understanding Functions in Python. List of Lab Works

The document outlines 4 experiments involving functions in Python, including writing functions to calculate employee salary based on basic salary and allowances, check eligibility for a traveler to fly based on baggage weight, immigration status, and security clearance, develop a menu driven program for a professor to check student attendance status and generate grades, and find the maximum and minimum values in a list of tuples using a lambda function. The experiments are designed to practice writing and using different types of functions in Python programs to solve various problems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Experiment No- 6

TITLE: Functions in Python


Objective: Understanding Functions in python.

List of lab works:


Write the python program to implement the below given design problems.
Using functions, re-write and execute Python program to:
1. Write a function that computes the gross salary of an employee according to the following
rules:
a. Input basic salary of an employee
b. Calculate and output Gross Salary = Basic + HRA + DA
c. If basic salary is >25000 then HRA =Rs.6000 and DA=12% of the basic.
d. If basic salary is <=25000 then HRA =Rs.4000 and DA=12% of the basic
2. At an airport, a traveller is allowed entry into the flight only if he clears the following
checks:
1. Baggage Check
2. Immigration Check
3. Security Check
 The logic for the check methods are given below:
check_baggage (baggage_weight)
returns True if baggage_weight is greater than or equal to 0 and less
than or equal to 40. Otherwise returns False.

check_immigration (expiry_year)
returns True if expiry_year is greater than or equal to 2030 and less
than or equal to 2050. Otherwise returns False.

check_security(noc_status)
returns True if noc_status is 'valid' or 'VALID', for all other values
return False.

traveler()
Initialize the traveller Id and traveller name and invoke the functions
check_baggage(), check_immigration() and check_security() by
passing required arguments.

 Refer the below data for value of arguments


traveler_id - "Your SAP Id"
traveler_name - "Your Name"
baggage_weight - 35
expiry_year - 2022
noc_status - VALID
 If all values of check_baggage(), check_immigration() and check_security() are true,
- display traveler_id and traveler_name
- display "Allow Traveler to fly!"
Otherwise,
- display traveler_id and traveler_name
- display "Detain Traveler for Re-checking!
 Invoke the traveler() function. Modify the values of different variables in traveler()
function and observe the output.

3. Develop a menu driven software in python with the below mentioned choices
[1- CheckAttendanceStatus 2-GenerateGrade 3-Exit

That helps a professor, to get a choice and invoke a suitable functions that provides the
below given functionality.
a) checkAttendanceStatus(classAttended,classHeld) which returns the status
allowed/debarred, with the condition “A student will not be allowed to sit in exam if
his/her attendance is less than 75%”
b) generateGrade(IAMarks,midSemMarks,endSemMarks) which returns the grade of the
student, as per the conditions mentioned below.
Rules for grading system:

 TotalMarks=20% MidSemMarks+30% IA+50% EndSemMArks


 On the basis of TotalMarks the grade is generated.
Below 25 - F
25 to 45 - E
45 to 50 - D
50 to 60 - C
60 to 80 - B
Above 80 – A

4. Write a Python program to find the maximum and minimum values in a given list of
tuples using lambda function.
Original list with tuples:
[('V', 62), ('VI', 68), ('VII', 72), ('VIII', 70), ('IX', 74), ('X', 65)]
Output-
Maximum and minimum values of the said list of tuples:(74, 62)

You might also like