Question
You have been given a list of binary compounds. Build a function that # parses their chemical formula. They will be of the form AxBy.
You have been given a list of binary compounds. Build a function that # parses their chemical formula. They will be of the form AxBy. # Make a list with dictionaries for all formula in the "parse_me" list. # A & B are element symbols. # x & y are integers from 0 to 9. # # Your function should return a dictionary with the elements as keys, # and their fractional amount as values. A list of element symbols is # provided if needed. # Al2O3 => {"Al": 0.4, "O": 0.6} # # NOTE: I am not looking for a "clean" solution. Be as hacky as you need # to create a function that parses Binaries of the form AxBy. Go wild! # ============================================================================= all_symbols = ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar', 'K', 'Ca', 'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr', 'Rb', 'Sr', 'Y', 'Zr', 'Nb', 'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te', 'I', 'Xe', 'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn', 'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr', 'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds', 'Rg', 'Cn', 'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og'] parse_me = ['Dy1Rh2', 'Ba1Pt1', 'Al1Pt1', 'Ca1Si2', 'Ru3Zr1', 'Dy2Se3', 'Ir2Lu1', 'Be2C1', 'Al2Ho3', 'Al2Y1', 'I1Rb1', 'C1Zr1', 'B4Fe1', 'Ba1Pt2', 'Ca1In2', 'Cu1Ti3', 'C1Nb1', 'Br1Cu1', 'S1Zn1', 'Ni1Zn1', 'As1Ti3', 'O3Tb2', 'Al3Zr4', 'O1Sr1', 'Ca1Ir2', 'Mg1Sc1', 'Sn2Tb1', 'Au1Ti1', 'B1N1', 'Ho1Te2', 'Rh5Tb1', 'As1Pu1']
This is in python.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started