Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
October 18, 2021 01:04 am GMT

Periodic Table

Console Output

# periodic_table.py#   This program display a periodic chart and allows you to pick an element#   for a full description of the element chosen.# by: Scott Gordonimport csv, sys, re# Read data from periodictable.csvelements_file = open("periodictable.csv", encoding="utf-8")elements_csv_reader = csv.reader(elements_file)elements = list(elements_csv_reader)elements_file.close()COLUMNS = [    "Atomic Number",    "Symbol",    "Element",    "Origin of name",    "Group",    "Period",    "Atomic weight",    "Density",    "Melting point",    "Boiling point",    "Specific heat capacity",    "Electronegativity",    "Abundance in earth's crust",]# Find longest string in each column in order to justify textLONGEST_COLUMN = 0for key in COLUMNS:    if len(key) > LONGEST_COLUMN:        LONGEST_COLUMN = len(key)# Add elements into dictionaryELEMENTS = {}for line in elements:    element = {        "Atomic Number": line[0],        "Symbol": line[1],        "Element": line[2],        "Origin of name": line[3],        "Group": line[4],        "Period": line[5],        "Atomic weight": line[6] + " u",        "Density": line[7] + " g/cm^3",        "Melting point": line[8] + " K",        "Boiling point": line[9] + " K",        "Specific heat capacity": line[10] + " J/(g*K)",        "Electronegativity": line[11],        "Abundance in earth's crust": line[12] + " mg/kg",    }    # Remove bracketed text from csv that was imported from Wikipedia    for key, value in element.items():        # Remove [roman numeral] text        element[key] = re.sub(r"\[(I|V|X)+\]", "", value)    ELEMENTS[line[0]] = element  # Map atomic number to element    ELEMENTS[line[1]] = element  # Map symbol to elementprint("Periodic Table of Elements")print()while True:    print(        """ Periodic Table of Elements      1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 16 17 18    1 H                                                  He    2 Li Be                               B  C  N  O  F  Ne    3 Na Mg                               Al Si P  S  Cl Ar    4 K  Ca Sc Ti V  Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr    5 Rb Sr Y  Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I  Xe    6 Cs Ba La Hf Ta W  Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn    7 Fr Ra Ac Rf Db Sg Bh Hs Mt Ds Rg Cn Nh Fl Mc Lv Ts Og            Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu            Th Pa U Np Pu Am Cm Bk Cf Es Fm Md No Lr"""    )    response = input("> ").title()    if response == "Quit":        sys.exit()    # Display element's data    if response in ELEMENTS:        for key in COLUMNS:            key_justified = key.rjust(LONGEST_COLUMN)            print(f"{key_justified}: {ELEMENTS[response][key]}")        input("Press Enter to continue...")

This is a copy of the .csv file used in this program.

1,H,Hydrogen,"Greek elements hydro- and -gen, meaning 'water-forming'",1,1,1.008[III][IV][V][VI],0.00008988,14.01,20.28,14.304,2.2,14002,He,Helium,"Greek hlios, 'sun'",18,1,4.002602(2)[III][V],0.0001785,[VII],4.22,5.193,,0.0083,Li,Lithium,"Greek lthos, 'stone'",1,2,6.94[III][IV][V][VIII][VI],0.534,453.69,1560,3.582,0.98,204,Be,Beryllium,"beryl, a mineral (ultimately from the name of Belur in southern India)",2,2,9.0121831(5),1.85,1560,2742,1.825,1.57,2.85,B,Boron,"borax, a mineral (from Arabic bawraq)",13,2,10.81[III][IV][V][VI],2.34,2349,4200,1.026,2.04,106,C,Carbon,"Latin carbo, 'coal'",14,2,12.011[III][V][VI],2.267,3800,4300,0.709,2.55,2007,N,Nitrogen,"Greek ntron and -gen, meaning 'niter-forming'",15,2,14.007[III][V][VI],0.0012506,63.15,77.36,1.04,3.04,198,O,Oxygen,"Greek oxy- and -gen, meaning 'acid-forming'",16,2,15.999[III][V][VI],0.001429,54.36,90.2,0.918,3.44,4610009,F,Fluorine,"Latin fluere, 'to flow'",17,2,18.998403163(6),0.001696,53.53,85.03,0.824,3.98,58510,Ne,Neon,"Greek non, 'new'",18,2,20.1797(6)[III][IV],0.0008999,24.56,27.07,1.03,,0.00511,Na,Sodium,"English soda (the symbol Na is derived from New Latin natrium, coined from German Natron, 'natron')",1,3,22.98976928(2),0.971,370.87,1156,1.228,0.93,2360012,Mg,Magnesium,"Magnesia, a district of Eastern Thessaly in Greece",2,3,24.305[VI],1.738,923,1363,1.023,1.31,2330013,Al,Aluminium,"alumina, from Latin alumen (gen. aluminis), 'bitter salt, alum'",13,3,26.9815384(3),2.698,933.47,2792,0.897,1.61,8230014,Si,Silicon,"Latin silex, 'flint' (originally silicium)",14,3,28.085[V][VI],2.3296,1687,3538,0.705,1.9,28200015,P,Phosphorus,"Greek phsphros, 'light-bearing'",15,3,30.973761998(5),1.82,317.3,550,0.769,2.19,105016,S,Sulfur,"Latin sulphur, 'brimstone'",16,3,32.06[III][V][VI],2.067,388.36,717.87,0.71,2.58,35017,Cl,Chlorine,"Greek chlrs, 'greenish yellow'",17,3,35.45[III][IV][V][VI],0.003214,171.6,239.11,0.479,3.16,14518,Ar,Argon,"Greek args, 'idle' (because of its inertness)",18,3,39.948[III][V][VI],0.0017837,83.8,87.3,0.52,,3.519,K,Potassium,"New Latin potassa, 'potash' (the symbol K is derived from Latin kalium)",1,4,39.0983(1),0.862,336.53,1032,0.757,0.82,2090020,Ca,Calcium,"Latin calx, 'lime'",2,4,40.078(4)[III],1.54,1115,1757,0.647,1,4150021,Sc,Scandium,"Latin Scandia, 'Scandinavia'",3,4,44.955908(5),2.989,1814,3109,0.568,1.36,2222,Ti,Titanium,"Titans, the sons of the Earth goddess of Greek mythology",4,4,47.867(1),4.54,1941,3560,0.523,1.54,565023,V,Vanadium,"Vanadis, an Old Norse name for the Scandinavian goddess Freyja",5,4,50.9415(1),6.11,2183,3680,0.489,1.63,12024,Cr,Chromium,"Greek chrma, 'colour'",6,4,51.9961(6),7.15,2180,2944,0.449,1.66,10225,Mn,Manganese,corrupted from magnesia negra; see Magnesium,7,4,54.938043(2),7.44,1519,2334,0.479,1.55,95026,Fe,Iron,English word (the symbol Fe is derived from Latin ferrum),8,4,55.845(2),7.874,1811,3134,0.449,1.83,5630027,Co,Cobalt,"German Kobold, 'goblin'",9,4,58.933194(3),8.86,1768,3200,0.421,1.88,2528,Ni,Nickel,"Nickel, a mischievous sprite of German miner mythology",10,4,58.6934(4),8.912,1728,3186,0.444,1.91,8429,Cu,Copper,"English word, from Latin cuprum, from Ancient Greek Kpros 'Cyprus'",11,4,63.546(3)[V],8.96,1357.77,2835,0.385,1.9,6030,Zn,Zinc,"Most likely from German Zinke, 'prong' or 'tooth', though some suggest Persian sang, 'stone'",12,4,65.38(2),7.134,692.88,1180,0.388,1.65,7031,Ga,Gallium,"Latin Gallia, 'France'",13,4,69.723(1),5.907,302.9146,2673,0.371,1.81,1932,Ge,Germanium,"Latin Germania, 'Germany'",14,4,72.630(8),5.323,1211.4,3106,0.32,2.01,1.533,As,Arsenic,"French arsenic, from Greek arsenikn 'yellow arsenic' (influenced by arseniks, 'masculine' or 'virile'), from a West Asian wanderword ultimately from Old Iranian *zarniya-ka, 'golden'",15,4,74.921595(6),5.776,1090 [IX],887,0.329,2.18,1.834,Se,Selenium,"Greek seln, 'moon'",16,4,78.971(8)[V],4.809,453,958,0.321,2.55,0.0535,Br,Bromine,"Greek brmos, 'stench'",17,4,79.904[VI],3.122,265.8,332,0.474,2.96,2.436,Kr,Krypton,"Greek krypts, 'hidden'",18,4,83.798(2)[III][IV],0.003733,115.79,119.93,0.248,3,110437,Rb,Rubidium,"Latin rubidus, 'deep red'",1,5,85.4678(3)[III],1.532,312.46,961,0.363,0.82,9038,Sr,Strontium,"Strontian, a village in Scotland",2,5,87.62(1)[III][V],2.64,1050,1655,0.301,0.95,37039,Y,Yttrium,"Ytterby, a village in Sweden",3,5,88.90584(1),4.469,1799,3609,0.298,1.22,3340,Zr,Zirconium,"zircon, a mineral",4,5,91.224(2)[III],6.506,2128,4682,0.278,1.33,16541,Nb,Niobium,"Niobe, daughter of king Tantalus from Greek mythology",5,5,92.90637(1),8.57,2750,5017,0.265,1.6,2042,Mo,Molybdenum,"Greek molbdaina, 'piece of lead', from mlybdos, 'lead'",6,5,95.95(1)[III],10.22,2896,4912,0.251,2.16,1.243,Tc,Technetium,"Greek tekhnts, 'artificial'",7,5,[98][X],11.5,2430,4538,,1.9,~ 3109[XI]44,Ru,Ruthenium,"New Latin Ruthenia, 'Russia'",8,5,101.07(2)[III],12.37,2607,4423,0.238,2.2,0.00145,Rh,Rhodium,"Greek rhodeis, 'rose-coloured', from rhdon, 'rose'",9,5,102.90549(2),12.41,2237,3968,0.243,2.28,0.00146,Pd,Palladium,"the asteroid Pallas, considered a planet at the time",10,5,106.42(1)[III],12.02,1828.05,3236,0.244,2.2,0.01547,Ag,Silver,English word (The symbol derives from Latin argentum),11,5,107.8682(2)[III],10.501,1234.93,2435,0.235,1.93,0.07548,Cd,Cadmium,"New Latin cadmia, from King Kadmos",12,5,112.414(4)[III],8.69,594.22,1040,0.232,1.69,0.15949,In,Indium,"Latin indicum, 'indigo' (colour found in its spectrum)",13,5,114.818(1),7.31,429.75,2345,0.233,1.78,0.2550,Sn,Tin,English word (The symbol derives from Latin stannum),14,5,118.710(7)[III],7.287,505.08,2875,0.228,1.96,2.351,Sb,Antimony,"Latin antimonium, the origin of which is uncertain: folk etymologies suggest it is derived from Greek ant ('against') + mnos ('alone'), or Old French anti-moine, 'Monk's bane', but it could plausibly be from or related to Arabic imid, 'antimony', reformatted as a Latin word. (The symbol derives from Latin stibium 'stibnite'.)",15,5,121.760(1)[III],6.685,903.78,1860,0.207,2.05,0.252,Te,Tellurium,"Latin tellus, 'the ground, earth'",16,5,127.60(3)[III],6.232,722.66,1261,0.202,2.1,0.00153,I,Iodine,"French iode, from Greek ioeids, 'violet')",17,5,126.90447(3),4.93,386.85,457.4,0.214,2.66,0.4554,Xe,Xenon,"Greek xnon, neuter form of xnos 'strange'",18,5,131.293(6)[III][IV],0.005887,161.4,165.03,0.158,2.6,310555,Cs,Caesium,"Latin caesius, 'sky-blue'",1,6,132.90545196(6),1.873,301.59,944,0.242,0.79,356,Ba,Barium,"Greek bars, 'heavy'",2,6,137.327(7),3.594,1000,2170,0.204,0.89,42557,La,Lanthanum,"Greek lanthnein, 'to lie hidden'",3,6,138.90547(7)[III],6.145,1193,3737,0.195,1.1,3958,Ce,Cerium,"the dwarf planet Ceres, considered a planet at the time",,6,140.116(1)[III],6.77,1068,3716,0.192,1.12,66.559,Pr,Praseodymium,"Greek prsios ddymos, 'green twin'",,6,140.90766(1),6.773,1208,3793,0.193,1.13,9.260,Nd,Neodymium,"Greek nos ddymos, 'new twin'",,6,144.242(3)[III],7.007,1297,3347,0.19,1.14,41.561,Pm,Promethium,Prometheus of Greek mythology,,6,[145][X],7.26,1315,3273,,1.13,21019[XI]62,Sm,Samarium,"samarskite, a mineral named after Colonel Vasili Samarsky-Bykhovets, Russian mine official",,6,150.36(2)[III],7.52,1345,2067,0.197,1.17,7.0563,Eu,Europium,Europe,,6,151.964(1)[III],5.243,1099,1802,0.182,1.2,264,Gd,Gadolinium,"gadolinite, a mineral named after Johan Gadolin, Finnish chemist, physicist and mineralogist",,6,157.25(3)[III],7.895,1585,3546,0.236,1.2,6.265,Tb,Terbium,"Ytterby, a village in Sweden",,6,158.925354(8),8.229,1629,3503,0.182,1.2,1.266,Dy,Dysprosium,"Greek dysprsitos, 'hard to get'",,6,162.500(1)[III],8.55,1680,2840,0.17,1.22,5.267,Ho,Holmium,"New Latin Holmia, 'Stockholm'",,6,164.930328(7),8.795,1734,2993,0.165,1.23,1.368,Er,Erbium,"Ytterby, a village in Sweden",,6,167.259(3)[III],9.066,1802,3141,0.168,1.24,3.569,Tm,Thulium,"Thule, the ancient name for an unclear northern location",,6,168.934218(6),9.321,1818,2223,0.16,1.25,0.5270,Yb,Ytterbium,"Ytterby, a village in Sweden",,6,173.045(10)[III],6.965,1097,1469,0.155,1.1,3.271,Lu,Lutetium,"Latin Lutetia, 'Paris'",,6,174.9668(1)[III],9.84,1925,3675,0.154,1.27,0.872,Hf,Hafnium,"New Latin Hafnia, 'Copenhagen' (from Danish havn)",4,6,178.49(2),13.31,2506,4876,0.144,1.3,373,Ta,Tantalum,"King Tantalus, father of Niobe from Greek mythology",5,6,180.94788(2),16.654,3290,5731,0.14,1.5,274,W,Tungsten,"Swedish tung sten, 'heavy stone' (The symbol is from wolfram, the old name of the tungsten mineral wolframite)",6,6,183.84(1),19.25,3695,5828,0.132,2.36,1.375,Re,Rhenium,"Latin Rhenus, 'the Rhine'",7,6,186.207(1),21.02,3459,5869,0.137,1.9,710476,Os,Osmium,"Greek osm, 'smell'",8,6,190.23(3)[III],22.61,3306,5285,0.13,2.2,0.00277,Ir,Iridium,"Iris, the Greek goddess of the rainbow",9,6,192.217(2),22.56,2719,4701,0.131,2.2,0.00178,Pt,Platinum,"Spanish platina, 'little silver', from plata 'silver'",10,6,195.084(9),21.46,2041.4,4098,0.133,2.28,0.00579,Au,Gold,English word (The symbol derives from Latin aurum),11,6,196.966570(4),19.282,1337.33,3129,0.129,2.54,0.00480,Hg,Mercury,"Mercury, Roman god of commerce, communication, and luck, known for his speed and mobility (The symbol is from the element's Latin name hydrargyrum, derived from Greek hydrrgyros, 'water-silver')",12,6,200.592(3),13.5336,234.43,629.88,0.14,2,0.08581,Tl,Thallium,"Greek thalls, 'green shoot or twig'",13,6,204.38[VI],11.85,577,1746,0.129,1.62,0.8582,Pb,Lead,English word (The symbol derives from Latin plumbum),14,6,207.2(1)[III][V],11.342,600.61,2022,0.129,1.87,1483,Bi,Bismuth,"German Wismut, from wei Masse 'white mass', unless from Arabic",15,6,208.98040(1)[X],9.807,544.7,1837,0.122,2.02,0.00984,Po,Polonium,"Latin Polonia, 'Poland' (the home country of Marie Curie)",16,6,[209][X],9.32,527,1235,,2,21010[XI]85,At,Astatine,"Greek statos, 'unstable'",17,6,[210][X],7,575,610,,2.2,31020[XI]86,Rn,Radon,radium,18,6,[222][X],0.00973,202,211.3,0.094,2.2,41013[XI]87,Fr,Francium,France,1,7,[223][X],1.87,300,950,,0.7,~ 11018[XI]88,Ra,Radium,"French radium, from Latin radius, 'ray'",2,7,[226][X],5.5,973,2010,0.094,0.9,9107[XI]89,Ac,Actinium,"Greek akts, 'ray'",3,7,[227][X],10.07,1323,3471,0.12,1.1,5.51010[XI]90,Th,Thorium,"Thor, the Scandinavian god of thunder",,7,232.0377(4)[X][III],11.72,2115,5061,0.113,1.3,9.691,Pa,Protactinium,"proto- (from Greek prtos, 'first, before') + actinium, which is produced through the radioactive decay of protactinium",,7,231.03588(1)[X],15.37,1841,4300,,1.5,1.4106[XI]92,U,Uranium,"Uranus, the seventh planet in the Solar System",,7,238.02891(3)[X],18.95,1405.3,4404,0.116,1.38,2.793,Np,Neptunium,"Neptune, the eighth planet in the Solar System",,7,[237][X],20.45,917,4273,,1.36, 31012[XI]94,Pu,Plutonium,"the dwarf planet Pluto, considered the ninth planet in the Solar System at the time",,7,[244][X],19.84,912.5,3501,,1.28, 31011[XI]95,Am,Americium,"The Americas, as the element was first synthesised on the continent, by analogy with europium",,7,[243][X],13.69,1449,2880,,1.13,0[XII]96,Cm,Curium,"Pierre Curie and Marie Curie, French physicists and chemists",,7,[247][X],13.51,1613,3383,,1.28,0[XII]97,Bk,Berkelium,"Berkeley, California, where the element was first synthesised, by analogy with terbium",,7,[247][X],14.79,1259,2900,,1.3,0[XII]98,Cf,Californium,"California, where the element was first synthesised",,7,[251][X],15.1,1173,(1743)[XIII],,1.3,0[XII]99,Es,Einsteinium,"Albert Einstein, German physicist",,7,[252][X],8.84,1133,(1269)[XIII],,1.3,0[XII]100,Fm,Fermium,"Enrico Fermi, Italian physicist",,7,[257][X],(9.7)[XIII],(1125)[XIII],,,1.3,0[XII]101,Md,Mendelevium,"Dmitri Mendeleev, Russian chemist and inventor who proposed the periodic table",,7,[258][X],(10.3)[XIII],(1100)[XIII],,,1.3,0[XII]102,No,Nobelium,"Alfred Nobel, Swedish chemist and engineer",,7,[259][X],(9.9)[XIII],(1100)[XIII],,,1.3,0[XII]103,Lr,Lawrencium,"Ernest O. Lawrence, American physicist",,7,[266][X],(15.6)[XIII],(1900)[XIII],,,1.3,0[XII]104,Rf,Rutherfordium,"Ernest Rutherford, chemist and physicist from New Zealand",4,7,[267][X],(23.2)[XIII],(2400)[XIII],(5800)[XIII],,,0[XII]105,Db,Dubnium,"Dubna, Russia, where the Joint Institute for Nuclear Research is located",5,7,[268][X],(29.3)[XIII],,,,,0[XII]106,Sg,Seaborgium,"Glenn T. Seaborg, American chemist",6,7,[269][X],(35.0)[XIII],,,,,0[XII]107,Bh,Bohrium,"Niels Bohr, Danish physicist",7,7,[270][X],(37.1)[XIII],,,,,0[XII]108,Hs,Hassium,"New Latin Hassia, 'Hesse' (a state in Germany)",8,7,[270][X],(40.7)[XIII],,,,,0[XII]109,Mt,Meitnerium,"Lise Meitner, Austrian physicist",9,7,[278][X],(37.4)[XIII],,,,,0[XII]110,Ds,Darmstadtium,"Darmstadt, Germany, where the element was first synthesised",10,7,[281][X],(34.8)[XIII],,,,,0[XII]111,Rg,Roentgenium,"Wilhelm Conrad Rntgen, German physicist",11,7,[282][X],(28.7)[XIII],,,,,0[XII]112,Cn,Copernicium,"Nicolaus Copernicus, Polish astronomer",12,7,[285][X],(23.7)[XIII],,~357[XIV],,,0[XII]113,Nh,Nihonium,"Japanese Nihon, 'Japan' (where the element was first synthesised)",13,7,[286][X],(16)[XIII],(700)[XIII],(1400)[XIII],,,0[XII]114,Fl,Flerovium,"Flerov Laboratory of Nuclear Reactions, part of JINR, where the element was synthesised; itself named after Georgy Flyorov, Russian physicist",14,7,[289][X],(14)[XIII],,~210,,,0[XII]115,Mc,Moscovium,"Moscow Oblast, Russia, where the element was first synthesised",15,7,[290][X],(13.5)[XIII],(700)[XIII],(1400)[XIII],,,0[XII]116,Lv,Livermorium,"Lawrence Livermore National Laboratory in Livermore, California, which collaborated with JINR on its synthesis",16,7,[293][X],(12.9)[XIII],(709)[XIII],(1085)[XIII],,,0[XII]117,Ts,Tennessine,"Tennessee, United States",17,7,[294][X],(7.2)[XIII],(723)[XIII],(883)[XIII],,,0[XII]118,Og,Oganesson,"Yuri Oganessian, Russian physicist",18,7,[294][X],(5.0)[XIII][XV],,(350)[XIII],,,0[XII]

Photo by Vedrana Filipovi on Unsplash


Original Link: https://dev.to/sagordondev/periodic-table-4776

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To