| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- # f_chemistry.py
- '''
- title: Chemistry Elements Infomation 2
- author: Michael Tang
- date-created: 2021-05-12
- '''
- from e_chemistry import getElem
- import sys
- # --- SUBROUTINES --- #
- ### - INPUTS
- ### - PROCESSING
- def getElemInfo(SYMBOL, ARRAY):
- '''
- search for element in the 2D array
- :param SYMBOL: (str) Element symbol
- :param ARRAY: (list) Elements information
- :return: (tuple)
- '''
- for i in range (len(ARRAY)):
- if SYMBOL == ARRAY[i][0]:
- return ARRAY[i]
- print("The element is not in the list.")
- sys.exit()
- ### - OUTPUTS
- def displInfo(ARRAY):
- '''
- Displays the element information
- :param ARRAY: (tuple) of the element info
- :return: (none)
- '''
- print(f"{ARRAY[1]}: {ARRAY[2]} g/mol")
- # --- VARIABLES --- #
- ELEMENTS = (
- ("H", "Hydrogen", 1.01),
- ("He", "Helium", 4.00),
- ("Li", "Lithium", 6.94),
- ("Be", "Beryllium", 9.01)
- )
- if __name__ == "__main__":
- # --- MAIN PROGRAM CODE --- #
- ELEMENT = getElem()
- ELEM_INFO = getElemInfo(ELEMENT, ELEMENTS)
- displInfo(ELEM_INFO)
-
-
|