Write script readpatwts that will first attempt to open file

Assignment Help Basic Computer Science
Reference no: EM13854497

For a biomedical experiment, the names and weights of some patients have been stored in a file patwts.dat. For example, the file might look like this:

Darby George   166.2

Helen Dee  143.5

Giovanni Lupa   192.4

Cat Donovan   215.1

Create this data file first. Then, write a script readpatwts that will first attempt to open the file. If the file open is not successful, an error message should be printed. If it is successful, the script will read the data into strings, one line at a time. Print for each person the name in the form ilast,firsti followed by the weight. Also, calculate and print the average weight. Finally, print whether or not the file close was successful. For example, the result of running the script would look like this:

>> readpatwts

George,Darby 166.2

Dee,Helen 143.5

Lupa,Giovanni 192.4

Donovan,Cat 215.1

The ave weight is 179.30

File close successful

Reference no: EM13854497

Find the power input required for a mass flow rate

Helium is to be compressed from 105 kPa and 295 K to 700 kPa and 460 K. A heat loss of 15 kJ/kg occurs during the compression process. Neglecting kinetic energy changes, det

Percent of the total cost was spent on extra expenses

A sold his car to B at 20% profit of the cost price but incurred a net loss of 10% because of extra expenses. What percent of the total cost was spent on extra expenses?

Mesa community college can increase it''s green footprint

Please title the page appropriately. Please use Microsoft Word. Please double-space the Word Document. Be creative! Are we using Word to create all writing assignments?

Finds the first match for a simple regular expression

Other characters match themselves. For example, find(s,"name:") returns a pointer to the first occurrence of name: in s; find(s,"[nN]ame:") returns a pointer to the first oc

Alter computation of prefix function-correctly match string

if ‘_' is wild-card, then pattern ‘foo*bar*nad' can be found in ‘foofoowangbarnad'. Alter computation of prefix function to correctly match strings using KMP.

What is the worst-case asymptotic running time for sortk

Imagine that there exists an algorithm SPLITk that can split a list L of n elements into k sub lists, each containing one or more elements, such that sub list i contains onl

Keyboard combinations that can increase

Microsoft® Word provides keyboard combinations that can increase a user's efficiency. How can these shortcuts simplify the support process for Microsoft® Word

Implementation of it and it goals of organization

You will conduct an evaluation of the business goals of DynCorp International. Prepare a mapping of IT goals for DynCorp International that will support the business goals.


Write a Review

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd