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

(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 data structure (you can choose it yourself, but choose wisely). The program then asks the user for the chemical formula of the molecule whose molecular weight is being calculated.

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!