Complete the function blood_donor, which determines whether a person is able to donate blood. A per age is 18 or over and his/her mass ("weight") is greater than 48 kilograms. The function takes four arguments: age, which gives the prospective donor's age mass, which gives the prospective donor's mass in kilograms requested_blood_type, which gives the requested blood type donor_blood_type, which gives the prospective donor's blood type The function returns one of several strings, depending on the inputs. If the donor's eligibility is satisfied a

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Complete the function blood_donor, which determines whether a person is able to donate blood. A person is eligible to donate blood if his/her
age is 18 or over and his/her mass ("weight") is greater than 48 kilograms.
The function takes four arguments:
• age, which gives the prospective donor's age
mass, which gives the prospective donor's mass in kilograms
requested_blood_type, which gives the requested blood type
• donor_blood_type, which gives the prospective donor's blood type
The function returns one of several strings, depending on the inputs. If the donor's eligibility is satisfied and his/her blood type matches the
requested blood type, return 'match' . Otherwise, check for ineligibility in the following order and return the first reason for ineligibility, if any:
'too young, too light' (both the age and the mass are too low)
'too young' (age is too low)
'too light' (mass is too low)
'mismatch' (requested_blood_type and donor_blood_type don't match)
Examples:
Function Call
Return Value
blood_donor (21, 50, 'A', 'A')]
blood_donor (16, 50, 'A', 'B')
blood_donor (20, 48, '0', 'A')
blood donor (17, 47, 'B', 'B')
blood_donor (21, 70, 'A', 'B') mismatch
match
too young
too light
too young, too light
1 def blood_donor (age, mass, requested_blood_type, donor_blood_type):
2
return 'Error' # DELETE THIS LINE and start coding here.
3
# Remember: end all of your functions with a return statement, not a print statement!
4
5
6 # Test cases
7 print (blood_donor (21, 50, 'A', 'A'))
8 print (blood_donor (16, 50, 'A',
9 print (blood_donor (20, 48, '0', 'A'))
10 print (blood_donor (17, 47, 'B', 'B'))
11 print (blood_donor (21, 70, 'A', 'B'))
Transcribed Image Text:Complete the function blood_donor, which determines whether a person is able to donate blood. A person is eligible to donate blood if his/her age is 18 or over and his/her mass ("weight") is greater than 48 kilograms. The function takes four arguments: • age, which gives the prospective donor's age mass, which gives the prospective donor's mass in kilograms requested_blood_type, which gives the requested blood type • donor_blood_type, which gives the prospective donor's blood type The function returns one of several strings, depending on the inputs. If the donor's eligibility is satisfied and his/her blood type matches the requested blood type, return 'match' . Otherwise, check for ineligibility in the following order and return the first reason for ineligibility, if any: 'too young, too light' (both the age and the mass are too low) 'too young' (age is too low) 'too light' (mass is too low) 'mismatch' (requested_blood_type and donor_blood_type don't match) Examples: Function Call Return Value blood_donor (21, 50, 'A', 'A')] blood_donor (16, 50, 'A', 'B') blood_donor (20, 48, '0', 'A') blood donor (17, 47, 'B', 'B') blood_donor (21, 70, 'A', 'B') mismatch match too young too light too young, too light 1 def blood_donor (age, mass, requested_blood_type, donor_blood_type): 2 return 'Error' # DELETE THIS LINE and start coding here. 3 # Remember: end all of your functions with a return statement, not a print statement! 4 5 6 # Test cases 7 print (blood_donor (21, 50, 'A', 'A')) 8 print (blood_donor (16, 50, 'A', 9 print (blood_donor (20, 48, '0', 'A')) 10 print (blood_donor (17, 47, 'B', 'B')) 11 print (blood_donor (21, 70, 'A', 'B'))
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Types of Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education