Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is wrong with my code? Here is the assignment if it helps A common situation dealt with in engineering and physics is that of

image text in transcribedimage text in transcribedimage text in transcribed

image text in transcribed

image text in transcribedimage text in transcribedWhat is wrong with my code?

Here is the assignment if it helps

A common situation dealt with in engineering and physics is that of projectile motion. The equation for the height of a projectile, y (m), is: y=-6) gt2 + Vo sin(O)t+y g= Acceleration due to gravity: 9.81 m/s2 t = Time (seconds) Vo = Initial Velocity of Projectile (m/s) 0 = Launch Angle (degrees) yo= Initial height of the projectile (m) The equation for the horizontal distance traveled by the projectile, x (m), is: x = V, cos(O)t Assuming yo is zero, the time at which the projectile impacts the ground is given by: 2 V, sin(0) - assuming y. = 0 Timpact = Assuming y. is zero, the time at which the projectile reaches the maximum height is given by: _Vsin(0) TMax assuming y. = 0 Download the text file, Projectile.txt, from the Community Site. The first column in the text file is initial velocity (m/s) and the second column is launch angle (degrees). Write a Python script that will: c. Read the data from the Projectile.txt file For each initial velocity and launch angle, compute Timpact, Maximum Height, and the Horizontal Distance and save the values in lists. Assume yo = 0 and compute horizontal distance at the impact time. Remember: trig functions are in the math library and use radians Write the results along with the initial velocity and launch angles in a new text file called Projectile Results.txt. The first column should be initial velocity, the second column should be launch angle, the third column should be impact time, the fourth column should be maximum height, and the last column should be distance. The first few lines of your Projectile Results.txt file should look like this: O X Projectile_Results.txt -... - File Edit Format View Help 10 15 0.5 0.3 5.1 10 30 1.0 1.3 8.8 10 45 1.4 2.5 10.2 100% Windows (CRLF) UTF-8 angle = ((line.split(' ')[1])) IndexError: list index out of range import math # path of the file pathofFile = './Projectile.txt' # function to calculate the different values def calculateValues(velocity, angle): g = 9.81 one_Degree_to_radian = 0.0174533 # impact time value impact Time - 2 * velocity * math.sin(angle * one_Degree_to_radian) / g # max height value maxHeight = velocity ** 2 * (math.sin(angle * one_Degree_to_radian) **2 /(2*g) # distace value distance - velocity * math.cos(angle * one_Degree_to_radian) * impactTime # returning the values return round(impactTime, 1), round(maxHeight,1), round(distance, 1) # openging file to read the content with open(pathofFile, 'r') as fileobj: # reading each lines for line in fileobj.readlines: # storing velocity velocity = (line.split(' ')[0]) # storing angle angle = (Cline.split(' ')[1])|| if angle[-1] == ' ': angle = angle[:-1] impactTime, maxHeight, distance = calculateValues(float(velocity), float(angle)) # writing the values to file fileobj = open("./Projectile_Results.txt", "a+") fileobji.write(str(velocity) + ' ' + str(angle) + ' ' + str(impactTime) + ' ' + str(maxHeight) + ' ' + str(distance) + ' ') fileobji.close() fileobj.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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

Combine like terms. 7x + 3y - 4x + 8y

Answered: 1 week ago

Question

Describe a persuasive message.

Answered: 1 week ago

Question

Identify and use the five steps for conducting research.

Answered: 1 week ago

Question

List the goals of a persuasive message.

Answered: 1 week ago