Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help with this Python 3.7.2 Problem! I use PythonWin 3.7.2 or another Python app that runs 3.7.2 on my MacBook with OS X. Please

please help with this Python 3.7.2 Problem! I use PythonWin 3.7.2 or another Python app that runs 3.7.2 on my MacBook with OS X. Please use simple code as this is an intro level programming class and Id like to understand what youre doing! Please use # as much as possible to explain what you are doing and why!
The code/program does not need to be super complicated! The most simple way to write this program/code while still outputting the correct format is best!
THANKS!
image text in transcribed
2A simple spring test rig measures weights hung from a spring and the static displacement at each weight. The springs are supposed to be linear, following the relation F-k6, where F is the force applied to the spring, k is the spring constant, and is the displacement in the spring, we can see, when given values of force and displacement, we can find kF6 The data collected from one run of this rig is given in the file HWOS 02 Springbata.txt,which is available on CatCourses. Look over that file to see how the headers are set up and note the numerical formats. The last line is blank. Note thot the ile could have any number of data rows in it, not just the 10 shown. Your program should accommodate different sizes of data files without changing the code. You may assume that there will be 4 header lines before the first data line: A comment, the column titles, the column units, and a blank line. You should read the header lines to know what to write to the output file's headers F mg Write a Python program that reads in the headers and data from that file. The program should be able to accommodate any size of file. For each data point in the file, calculate a spring constant k for the given weight and displacement. This should be in N/m (not N/mm). Keep track of these values Bulk of the westion output, create a file called HWOS 02 out.txt. It should have . The same comment as the input file. MEO21 Engineering Computing Spring 2019 Three columns, the first two are the weight and displacement from the input file. The third column - is the spring constant calculated for each row, with the column header title "stiffiness" and header units (N/m) * A header line following the units should consist of dashes for each header, as wide as the header title for that column. . Make each column of the output file 20 characters wide. The format specification for all floats should use a 20 character wide field and show 3 digits to the right of the decimal place See the example output below to be sure how this should look It is very strongly supgested that reading the data and calculating stiffness correctly is done first. Getting the format output correct will take some time and some fine-tuning. Remember that the code should work for an input data file with any number of data rows without adjustment to the code. As an example, a data fle with 5 data lines is shown below (and available as HNOS ExamplespringData.txt on Catcourses). Spring Test Data, Tebruary, 2019 veight displacenent N) Crm 0.968 2.022 2.997 3.965 .984 1.3066 2.0459 2.5755 .4614 And the resulting output file (available as HWO5 ExampleSpringData out.txt) Spring Test Data, February, 2819 weight stiffness Should 1484.663 1547.528 look like .461

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_2

Step: 3

blur-text-image_3

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

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions