Created
March 7, 2020 06:09
-
-
Save zamiur/0f9057a30dd23ba86782744984aa5f96 to your computer and use it in GitHub Desktop.
Molecular mass calculator. Not Perfect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import getpass # This module is imported only for the purpose of printing out your user | |
import re | |
from molmass import * | |
name = getpass.getuser() | |
print(f"Hello,{name}") # Prints current username | |
input = str(input("Please enter in chemical formula: ")) #assign string the chemical formula | |
if input == "": #If statement to see if user has left input blank | |
print("You forgot to type in formula") | |
else: | |
f = Formula(input) #converts input to "formula" | |
mf = f.mass #variable assigned to mass of "f" | |
print(f"your formula is {input}") #prints what user has assigned variable input | |
print(f"Your total mass is {mf}.") #prints mass of formula | |
print(f"Below is the composition fo {input}") | |
print(f.composition()) | |
#TODO: Put some sort of way to restart the program without reopening it |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment