Create a module called chemistry that contains the following three functions: elementName(symbol) This function accepts one string parameter. The symbol represents the name of a specific element on the periodic table. The function returns the name of the element (as string) of the specific element. For example, elementName(Na) returns Sodium. elementName(Li) return Lithium. Note: You are NOT allowed to use lists or any data types not yet covered in class. ionicCompound(e1, c1, e2, c2) This function accepts the chemical symbol and charge for two elements. The function should return the ionic compound created with these two elements. The subscripts should be reduced. ionicName(e1, e2) This function accepts the chemical symbols for two elements. Based on these two symbols the function should return an appropriate chemical name. ionicName(Mg, O) returns Magnesium Oxide. Create a Python program that uses the functions defined in your chemistry module to allow a user to create chemical formulas and chemical names. Your program should include a menu with 2 options. If the user selects an invalid option, the user should be told so, and the menu should be displayed again. The user can enter ANY chemical symbol and chemical charge (+ or -). The program should only work with one metal (+) and non-metal (-). It should only work for the first 20 elements. iv) If the user chooses option 'Q’ (or 'q') the program should end. If the user chooses options 1 or 2, they should be asked to enter the chemical symbols and charges. The menu should then be displayed again, allowing the user to choose again. Your program should use effective mainline logic. In addition to a main() function, think about creating other functions to make your code as easy to read as possible. Your program should demonstrate mastery of the style rules including docstrings, and code comments, and correct use of modules.
Create a module called chemistry that contains the following three functions: elementName(symbol) This function accepts one string parameter. The symbol represents the name of a specific element on the periodic table. The function returns the name of the element (as string) of the specific element. For example, elementName(Na) returns Sodium. elementName(Li) return Lithium. Note: You are NOT allowed to use lists or any data types not yet covered in class. ionicCompound(e1, c1, e2, c2) This function accepts the chemical symbol and charge for two elements. The function should return the ionic compound created with these two elements. The subscripts should be reduced. ionicName(e1, e2) This function accepts the chemical symbols for two elements. Based on these two symbols the function should return an appropriate chemical name. ionicName(Mg, O) returns Magnesium Oxide. Create a Python program that uses the functions defined in your chemistry module to allow a user to create chemical formulas and chemical names. Your program should include a menu with 2 options. If the user selects an invalid option, the user should be told so, and the menu should be displayed again. The user can enter ANY chemical symbol and chemical charge (+ or -). The program should only work with one metal (+) and non-metal (-). It should only work for the first 20 elements. iv) If the user chooses option 'Q’ (or 'q') the program should end. If the user chooses options 1 or 2, they should be asked to enter the chemical symbols and charges. The menu should then be displayed again, allowing the user to choose again. Your program should use effective mainline logic. In addition to a main() function, think about creating other functions to make your code as easy to read as possible. Your program should demonstrate mastery of the style rules including docstrings, and code comments, and correct use of modules.
Step by step
Solved in 5 steps with 6 images