Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Consider the formula y(t)vot 0.5gt2 that describes the variation in displacement with time. The goal of this exercise is to evaluate y for a

image text in transcribed
1. Consider the formula y(t)vot 0.5gt2 that describes the variation in displacement with time. The goal of this exercise is to evaluate y for a range oft values found in file ball.dat. The beginning of the file has the following format vo: 3.00 t: 0.15592 0.28075 0.36807889 0.35 0.57681501876 0.21342619 0.0519085 0.042 0.27 0.50620017 0.528 where the first two lines are always present, while the next lines contain an arbitrary number of t values on each line, separated by one or more spaces. For the data in this file, perform the following a) Write a function that reads the input file and returns vo and a list with the t values. (b) Write a function that creates a file with two formatted columns containing the t value to the left and the corresponding y value to the right. Let the t values appear in increasing order An example code of inputting and outputting data is below and may be helpful in developing the functions in (a) and (b) # Example of writing data to two columns: for i in range (10): x.aPpend (i); y,append (s**2); fout open ('test.txt','w) fout.write('x y In' for i in range (len (x)) fout.write (str x[1)'4str (y[i])+'In) fout.close () # Example of loading data with two columns: fin = open ( ' test.txt', 'r') linesfin.readlines () header lines [o 1ines lines [1: for line in lines x n.append (eval (ine. splito [o1)) y n.append (eval (ine. splito [1])) fin.close

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 Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

How could assessment be used in an employee development program?

Answered: 1 week ago