Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4.3.9 solution: def find_net_force_from_file(forces): total_horizontal = 0 total_vertical = 0 for force in forces: magnitude=force angle = force angle = radians(float(angle)) horizontal = magnitude *

image text in transcribed

4.3.9 solution:

def find_net_force_from_file(forces):

total_horizontal = 0

total_vertical = 0

for force in forces:

magnitude=force

angle = force

angle = radians(float(angle))

horizontal = magnitude * cos(angle)

vertical = magnitude * sin(angle)

total_horizontal += horizontal

total_vertical += vertical

net_magnitude = sqrt(total_horizontal**2 + total_vertical**2)

net_magnitude = round(net_magnitude, 1)

net_angle = atan2(total_vertical, total_horizontal)

net_angle = degrees(net_angle)

net_angle = round(net_angle, 1)

return (net_magnitude, net_angle)

Coding Problem 4.4.4 A Bookmark this page Coding Problem 4.4.4 (External resource) s0 paints possible) FreeBodyiles.py SubmitRun Grades Reset I #Recall Coding Problem 4.3.9 (Advanced), the free body Console output will be displayed here 2 #dia If you were unable to solve that, eve 3#inc 4 #-- feel free to us that to write your answer to this the sample answer in the dropdawn in the top left 5 #problem- 7 #Revise your code fron that prob lan to use a file instead of g #tind nat force fra file. The function should tako are 10 #Pariteter, the name of a file-Te function hould return 11 #the net magnitude and direction, just as it did in the other 12. #Problem 13 14 HEach line of the file will have two numbers, both integers: 15 Wthe first number will be the negaitude, and the second 6 number will be the angle (in de 17 #Ihere will be space between t 181# 9 HENT: You may have multiple functions in your code if you 29 #Ment ! 22 #H?NT 2: Tryto irite this such that you can reuse-as.nuch 2.3#of your earlier code as possible. Renenber, when loading 24 #fra file, any text you load is initially string. You'll #almost certainly need to use the split() method 27 fron nath inport sin, cos, tan. asin, acos, atan2, radians, degrees, sqrt 29#Add your function here! function 31 #Below are samo lines of code that uill test 32#You can change the value at the variable(s) to test your 33 #function with different inputs 5 Tf your function orks correctly, Lhis will originally 36 print: (87-8,54.4 37 print(find net force from file" few sngles.txt")) 38 39

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

Beginning Apache Cassandra Development

Authors: Vivek Mishra

1st Edition

1484201426, 9781484201428

More Books

Students also viewed these Databases questions