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.
Given below is the code for the question. PLEASE MAKE SURE
INDENTATION IS EXACTLY AS SHOWN IN IMAGE.
Please do rate the answer if it helped. Thank you.
import re
def process(formulas):
result = []
for f in formulas:
elems = re.split('\d', f) #get the
alphabetic names separated by digits
values = re.findall('\d', f) #get
all the digits list
values = [int(x) for x in values]
#convert all values to int
total = sum(values)
d = {}
for i in range(2):
name =
elems[i]
frac =
round(values[i]/total, 2) #round to 2 decimal places
d[name] =
frac
result.append(d)
return result
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',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{'Ho':
0.33, 'Te': 0.67}, {'Rh': 0.83, 'Tb': 0.17}, {'As': 0.5, 'Pu':
0.5}]
You have been given a list of binary compounds. Build a function that # parses their...
[References Select an element on the periodic table to see its electron configuration. Symbol: Group: Atom Number: Sf ЗА 4, 5, 6, 7А 58 68 7B - IB 28 Order of Filling ISIS Spectroscopic (spdf) Noble Gas Notation: 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 Cs Ba La HET W Re Os Ir...
17 18 12 13 15 16 5 14 2 3 4 6 7 10 11 1 He 1 H 2 N O F Ne Li Be Na Mg $3 Si CI Ar Al Cr Mn Fe Co Ca Sc Ni Cu Zn 4 K Ti V Ga Ge As Se Br Kr Sr Y Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te 5 Rb Xe 6 Cs Ba La WRe Os Ir Au Hg TI...
Не 1 H C N O F Ne В 2 Li Вe Si P S Ar Al Na Mg 3 Se Br Kr Cu Zn Ga Ge As Cr Mn Fe Co Ni 4 K Ca Sc Ti V Sn Sb Te I Ru Rh Pd Ag Cd In Zr Nb Mo Tc Rb Sr Y $5 Po At Pb Bi Hf Ta W Rn Re Os Ir Hg T Pt Au 6 Cs Ba La Ra Ac Fr Tm...
1A 8A H 2A 3A 4A 5A 6A 7A He Li Be B CN O F Ne Na Mg 3B 4B 5B 6B 7B 8B 1B 2B Al Si P SCI Ar K Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr Rb Sr YZr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te Xe Cs Ba La Hf Ta WRe Os Ir Pt Au Hg T Pb Bi...
E CGQNO hemical Reactions: Acid-Base mical Reactions: Acid-Base ed 20 K Ca Phesphar 34 As 24 27 29 30 12 Ge Ga 3 Sc Mni Fe Co Ni Cu Zni Se Br Kr s Ceppe T2431 cacm a 38 Rb Sr Zr Nb Mo Tc Ru Rh Pd Ag Cd 50 Sn In Sb Te Хe une Art Ca Te 57-71 Ва 82 84 Cs Hf W Re Os Ir Pt Au Hg TI Pb Bi Po At Rn Cem...
I need help asap please!!
8A ЗА 4А 5А 6А 74 Не B C N O са Sc Cr Mn u znGa Ge As Na Mg 3B 48 58 68 7B 8G B 2B Al Si P K Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Ki Y Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn La Hf Ta W Re Os Ir Pt Au Hg |ті Pb Bi...
-6 days 0/50 The Periodic Table of Elements H He tanton Metas Ane Earth Haa AMes Post on Met Mettods Nonmetals No Ganes Halogens Be Li N C C Ne 15 Lanhanides Mg Al P Na Ar is mi mm Ti Mn Fe Sc Cr Co Ni Cur Zn Ga Ge As Se Br K Ks Ce Str Nb Mo Tc Sh Zr Ru Rh Cd In Sn Te Rb Pd atsa Buts A Hf Re Po Au Hq Ph...
its a two part question. plz look at second pic
BA 3A 4A 5A 6A 7A He 27 Na Mg 3B 4B 5B 6B7B 8B1B2B K ca sa Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr Y Zr Nb Mo Tc Ru Rh Pd Ag Cd Hf Ta W Re Os Ir Pt Au Hg At Rn TI Ra AC Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu FE...
USCRICICULES ULLE HUU W u n . A. An element with the valence electron configuration 4s' would form a monatomic ion with a charge of In order to form this ion, the element will electron(s) from/into the subshell(s). B. An element with the valence electron configuration 5s-5p would form a monatomic ion with a charge of In order to form this ion, the element will Y e lectron(s) from/into the subshell(s). Submit Answer Retry Entire Group 9 more group attempts...
gress Use the References to access important values if needed for this question ZA 4A SA 6A7A He (Nor Na Mg 3B 4B 5B 68 78 8 1 B 2B Al Si P Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge As Sr Y Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Ir Pt Au Hg Tl Pb Bi Bf Ha Ho Er Th Pa U Np Pu Am Cm Bk...