Question
(PYTHON) The program first reads the atomic masses of the elements from a file provided by the user. It stores atomic masses in a suitable
The program calculates the molecular weight of the molecule entered by the user and prints it. The program then asks the user if he wants to continue. The program continues to ask for a new molecular formula if the user's response is "y" or "Y". Otherwise, the program will stop working. See the example times for more information on what the program should print at different stages. Finally, the program prints "The program ends."
The program uses a file containing the atomic masses of the elements. See an example of atomic_masses1.txt and a slightly invalid atomic_masses2.txt file. In the file, the atomic mass of one element is given in one line so that there is first the chemical sign of the element, then the colon, and then the atomic mass of the element in atomic mass units (amu).
atomic_masses1.txt: atomic_masses2.txt
H:1.008 H:1.008
He:4.0026 He:4.0026
C:12.011 C:12.011
N:14.0067 U:vaara
O:16.00 N:14.0067
S:32.065 S:32.065:ylimaaraista
Cl:35.45 CL:35.45
Cr:52.00 Cr:52.00
Au:196.67 Al
Cu:63.55 Au:196.67
Pb:207.2 Cu:63.55
Ni:58.70 Kr:?
Si:28.09 Pb:207.2
Ni:58.70
Si:28.09
There is an answer for this assignment on this page, but can you solve this without using ' sys ' .
Examples of program execution:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started