Question
Complete the following function in python based on the cutomers request. Function : def hydrocarbon(hydrogen,carbon,oxygen): #Add your code here Customer Request: take in three parameters
Complete the following function in python based on the cutomers request.
Function:
def hydrocarbon(hydrogen,carbon,oxygen):
#Add your code here
Customer Request:
take in three parameters assumed to be hydrogen, carbon, and oxygen IN THAT ORDER.
validate that all three values are non-negative integers:
if not than you should return None
if all three parameters are valid then you should calculate the mass of the hydrocarbon and return the mass where:
Each hydrogen has a molecular weight of 1.0079
Each carbon has a molecular weight of 12.011
Each oxygen has a molecular weight of 15.9994
For example:
hydrocarbon(4,3,0) will return 40.0646
hydrocarbon(1,2,3) will return 73.0281
hydrocarbon(-1,-1,-1) will return None
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started