# carb_molecular_weight_calc.py
# This program computes the molecular weight of a carbohydrate
# (in grams per mole) based on the number of hydrogen, carbon and
# oxygen atoms in the molecule.
# by: Scott Gordon
HYDROGEN_ATOMIC_WEIGHT=1.00794CARBON_ATOMIC_WEIGHT=12.0107OXYGEN_ATOMIC_WEIGHT=15.9994print("***** Carbohydrate Molecular Weight Calculator *****")hydrogen_atoms=int(input("How many Hydrogen atoms are there? "))carbon_atoms=int(input("How many Carbon atoms are there? "))oxygen_atoms=int(input("How many Oxygen atoms are there? "))hydrogen_combined_weight=HYDROGEN_ATOMIC_WEIGHT*hydrogen_atomscarbon_combined_weight=CARBON_ATOMIC_WEIGHT*carbon_atomsoxygen_combined_weight=OXYGEN_ATOMIC_WEIGHT*oxygen_atomstotal_combined_weight=hydrogen_combined_weight+ \
carbon_combined_weight+oxygen_combined_weightprint("The total combined molecular weight of all the atoms is",total_combined_weight,"grams per mole.")
Top comments (0)
Subscribe
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)