# The script stores and displays information about elements' electron configurations and Lewis structures
# based on the provided table.
# --- Data Structure ---
# Using a list of dictionaries to store the data, where each dictionary represents an element.
elements_data=[{"symbole":"H","configuration":"K(1)","representation_lewis":"H (1 valence electron)","valence_electrons":1},{"symbole":"C","configuration":"K(2) L(4)","representation_lewis":"•Ċ• (4 valence electrons)","valence_electrons":4},{"symbole":"N","configuration":"K(2) L(5)","representation_lewis":":Ṅ• (5 valence electrons, 1 lone pair)","valence_electrons":5},{"symbole":"O","configuration":"K(2) L(6)","representation_lewis":":Ö: (6 valence electrons, 2 lone pairs)","valence_electrons":6},{"symbole":"P","configuration":"K(2) L(8) M(5)","representation_lewis":":Ṗ• (5 valence electrons, 1 lone pair)","valence_electrons":5},{"symbole":"Cl","configuration":"K(2) L(8) M(7)","representation_lewis":":Cl̈: (7 valence electrons, 3 lone pairs)","valence_electrons":7},{"symbole":"Na","configuration":"K(2) L(8) M(1)","representation_lewis":"Na• (1 valence electron)","valence_electrons":1},{"symbole":"Ne","configuration":"K(2) L(8)","representation_lewis":":Ne: (8 valence electrons, 4 lone pairs - stable octet)","valence_electrons":8},]# --- Display Function ---
defafficher_tableau_elements(data):"""
Displays the elements' data in a formatted table.
"""print("\n--- Tableau des Configurations Électroniques et Représentations de Lewis ---")# Define the column widths for proper alignment
w_symbole=8w_config=18w_lewis=60# Print the header
header=(f"| {'SYMBOLE':<{w_symbole}}"f"| {'CONFIGURATION':<{w_config}}"f"| {'REPRÉSENTATION DE LEWIS (Notes)':<{w_lewis}} |")separator="-"*len(header)print(separator)print(header)print(separator)# Print the data rows
forelementindata:row=(f"| {element['symbole']:<{w_symbole}}"f"| {element['configuration']:<{w_config}}"f"| {element['representation_lewis']:<{w_lewis}} |")print(row)print(separator)# --- Execution ---
# 1. Display the full table
afficher_tableau_elements(elements_data)# 2. Example of how to access specific data
print("\n--- Exemple d'accès aux données ---")try:# Find the data for Oxygen (O)
oxygen=next(itemforiteminelements_dataifitem["symbole"]=="O")print(f"L'oxygène ({oxygen['symbole']}) a la configuration : {oxygen['configuration']}")print(f"Il possède {oxygen['valence_electrons']} électrons de valence.")exceptStopIteration:print("Élément non trouvé.")# 3. Example of filtering data (e.g., elements with 5 valence electrons)
print("\n--- Éléments avec 5 Électrons de Valence ---")elements_cinq_valence=[e['symbole']foreinelements_dataife['valence_electrons']==5]print(f"Les éléments avec 5 électrons de valence sont : {', '.join(elements_cinq_valence)}")
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.