Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

=+What is the EVPI?

Answered: 1 week ago

Question

How else might employees be motivated to improve their performance?

Answered: 1 week ago