import os
import math
# A program to calculate Molecular Weight of a Hydrocarbon
# These are the atomic weights(grams/mole) of Hydrogen,Carbon and Oxygen
atomicwtH = 1.0079
atomicwtC = 12.011
atomicwtO = 15.994
Hatoms = input("Enter the number of Hydrogen atoms ")
Catoms = input("Enter the number of Carbon atoms ")
Oatoms = input("Enter the number of Oxygen atoms ")
#Before calculating, we change the type of the input to int to avoid incompatibility issues.
atomicwtHmol = int(Hatoms)* atomicwtH
atomicwtCmol = int(Catoms)* atomicwtC
atomicwtOmol = int(Oatoms)* atomicwtO
totalmolwt = atomicwtHmol+atomicwtCmol+atomicwtOmol
print("Molecular Weight = "+str(totalmolwt)+" gms/Mole")
OUTPUT.
Enter the number of Hydrogen atoms 15
Enter the number of Carbon atoms 5
Enter the number of Oxygen atoms 8
Molecular Weight = 203.1255 gms/Mole