Question: TypeError: unsupported operand type(s) for *: 'function' and 'float' for python for the line of: gramOxygenAA = (moleOxygen * (2/1)) * ((12.011*2) + (1.008*4) +
TypeError: unsupported operand type(s) for *: 'function' and 'float' for python for the line of: gramOxygenAA = (moleOxygen * (2/1)) * ((12.011*2) + (1.008*4) + (15.9994 * 2))
Hi! i am having trouble with my python coding that determines the limiting reagent. I keep getting the error above and can't seem to fix it.
This is my python code:
# Function that determines moles of oxygen input def moleOxygen (gramOxygen): moleOxygen = gramOxygen / (15.9994 * 2) print ("Moles of oxygen available:", format(moleOxygen,'.2f')) return (moleOxygen) # Function that determines moles of acetaldehyde input def moleAcetaldehyde (gramAcetaldehyde): moleAcetaldehyde = gramAcetaldehyde / ((12.011*2) + (1.008*4) + 15.999) print ("Moles of acetaldehyde available:", format(moleAcetaldehyde,'.2f')) return moleAcetaldehyde
# Function that determines grams of Acetic Acid produced from available oxygen def gramOxygenAA (moleOxygen): gramOxygenAA = (moleOxygen * (2/1)) * ((12.011*2) + (1.008*4) + (15.9994 * 2)) print ("Grams of Acetic Acid that can be produced from available oxygen is", format(gramOxygenAA,'.2f')) return gramOxygenAA
# Function that determines grams of Acetic Acid produced from available acetaldehyde def gramAcetaldehydeAA (): gramAcetaldehydeAA = (moleAcetaldehyde / (2/2)) *((12.011*2) + (1.008*4) + (15.9994 * 2)) print ("Grams of Acetic Acid that can be produced from available acetaldehyde is", format(gramAcetaldehydeAA, '.2f')) return gramAcetaldehydeAA
# Function that determines the Limiting Reagent def limitingReagent(): if gramOxygenAA < gramAcetaldehydeAA: smaller = gramOxygenAA print ("Oxygen is the limiting reagent") else: smaller = gramAcetaldehydeAA print ("Acetaldehyde is the limiting reagent") return smaller
def main (): gramOxygen = float (input("Enter grams of oxygen entered into the reaction: ")) gramAcetaldehyde = float (input("Enter grams of acetaldehyde entered into the reaction: ")) print ("*" * 80) moleOxygen (gramOxygen) moleAcetaldehyde (gramAcetaldehyde) gramOxygenAA (moleOxygen) gramAcetaldehydeAA () limitingReagent() print ("The number of grams of acetic acid produced due to limiting reagent is", format (smaller,'.2f'))
### Call to main program ### main ()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
