Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. A simple spring test rig measures weights hung from a spring and the static displacement at each weight. The springs are supposed to be

image text in transcribed
image text in transcribed
2. A 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=k8, where Fis the force applied to the spring, kis the spring constant, and is the displacement in the spring. We can see, when given values of force and displacement, we can find k=F/6. Femg The data collected from one run of this rig is given in the file WO5_02 Springbata.txt, which is available on Look over that file to see how the headers are set up and note the numerical formats. The last line is blank. Note that the file 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 for data file. 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 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. For output, create a file called HW05_02_out.txt. It should have The same comment as the input file. 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 stiffness and header units "IN/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 suggested 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 file with 5 data lines is shown below (and available as HWO5_ExampleSpringData.txt one . Spring Test Data, February, 2020 weight displacement (N) ) 0.968 2.022 2.997 0.6520 1.3066 2.0459 It is very strongly suggested 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 file with 5 data lines is shown below (and available as HWO5_ExampleSpringData.txt on CatCourses). Spring Test Data, February, 2020 weight displacement (N) (mm) 0.968 2.022 2.997 3.965 4.984 0.6520 1.3066 2.0459 2.5755 3.4614 And the resulting output file (available as HW05_ExampleSpringData_out.txt): Spring Test Data, February, 2020 weight displacement (N) (mm) stiffness (N/m) 2.968 2.022 2.997 3.965 4.984 0.652 1.307 2.046 2.575 3.461 1484.663 1547.528 1464.881 1539.507 1439.880

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

Database Systems For Advanced Applications 15th International Conference Dasfaa 2010 Tsukuba Japan April 2010 Proceedings Part 1 Lncs 5981

Authors: Hiroyuki Kitagawa ,Yoshiharu Ishikawa ,Wenjie Li ,Chiemi Watanabe

2010th Edition

3642120253, 978-3642120251

More Books

Students also viewed these Databases questions