Рубрики
Без рубрики

Калькулятор молекулярной массы углеводов

# carb_molecular_weight_calc.py # Эта программа вычисляет молекулярную массу углеводов # … Теги с Python.

# 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.00794
CARBON_ATOMIC_WEIGHT = 12.0107
OXYGEN_ATOMIC_WEIGHT = 15.9994

print("***** 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_atoms
carbon_combined_weight = CARBON_ATOMIC_WEIGHT * carbon_atoms
oxygen_combined_weight = OXYGEN_ATOMIC_WEIGHT * oxygen_atoms
total_combined_weight = hydrogen_combined_weight + \
    carbon_combined_weight + oxygen_combined_weight

print("The total combined molecular weight of all the atoms is",
      total_combined_weight, "grams per mole.")

Оригинал: “https://dev.to/sagordondev/carbohydrate-molecular-weight-calculator-c7k”