Home » Blog » Implement The Energy Equation Based On Velocity

Implement The Energy Equation Based On Velocity

Solution For Below Problem

A car driver, driving at velocity v0, suddenly puts on the brake. What
is braking distance d needed to stop the car? One can derive, using
Newton’s second law of motion or a corresponding energy equation,
that

d=(1/2) * (v0^2/ug)

Make a program for computing d above equation, when the initial car
velocity v0 and the friction coefficient μ are given on the command
line. Run the program for two cases: v0 = 120 and v0 = 50 km/h, both
with μ = 0.3 (μ is dimensionless).
(Note: convert the velocity in m/s)

import sys
values=sys.argv
if (len(values)<=1):
    print("You Don't Have Any Argument")
elif len(values)!=4 :
    print("Insufficient Argument")
else:
    v01=float(values[1])
    v02=float(values[2])
    u=float(values[3])

    d1=(1/2)*(pow(v01,2)/(u*9.8))
    d2=(1/2)*(pow(v02,2)/(u*9.8))

    print("d1 = ",d1)
    print("d2 = ",d2)

 

Leave a Reply

Your email address will not be published.