Home > other >  For bosses to see a Python
For bosses to see a Python

Time:10-08

Enter 1 to calculate accord with the rules of chemical formula string, such as C3O26N4, letters case-insensitive,
Output the relative molecular weight of the formula is, keep one decimal,
Relative atomic mass expressed in dictionary elements, such as: {' C ': 12.0,' O ': 16.0,' N ': 14.0},
Consider only the periodic table top 30 can,
Thank you

CodePudding user response:

Don't understand the question, is the element with the digital divide?

CodePudding user response:

reference 1st floor chuifengde response:
don't understand the question, is the element with the digital divide?
before the number represents the number of an element

CodePudding user response:

refer to the second floor wants to become a better person reply:
Quote: refer to 1st floor chuifengde response:
don't understand the question, is the element with the digital divide?
before the number represents the number of an element
I think separates element and digital cross the border but in the end do not know why the list

CodePudding user response:

With expression is measured first separate elements of the logo
Re. The.findall (" \ \ w d *?" , s)

CodePudding user response:

Re. The split (' \ d ', 'STR')

CodePudding user response:

 import re 

X="C3O26N4
"
G=re. The.findall (" ([a zA - Z] +) ([0-9] +) ", x)

If g:
D={I [0] of float: (I) [1] for I in g}
Print (d)

# {' C ': 3.0,' O ': 26.0,' N ': 4.0}
  • Related