Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions