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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!