lab2-extra¶
These voluntary tasks exercise the known Python concepts in the context of
engineering problems. fall_time()
and impact_velocity
relate to
the mechanics of object’s in Earth’s gravitational field.
interval_point()
relates to linear interpolation as be found in data
analysis, data-based model descriptions, or finite element calculations.
fall_time(h)
¶
Write a function fall_time(h)
that returns the time \(t\) (in
seconds) needed for an object falling from a tower of height \(h\)
(in meters) to hit the ground (ignoring air friction).
The relevant equation is
being the gravitational constant on the Earth’s surface. As we need to compute \(t(h)\), we solve the equation for \(t\):
Examples:
In [ ]: fall_time(10)
Out[ ]: 1.4278431229270645
In [ ]: fall_time(1)
Out[ ]: 0.4515236409857309
impact_velocity(h)
¶
Implement a function impact_velocity(h)
that returns the velocity
\(v\) (in metre per second) with which an object falling from a
height of \(h\) meters will hit the ground. Use \(v(t)=gt\),
with \(v(t)\) the velocity at time \(t\), and
\(g=9.81 \frac{\mathrm{m}}{\mathrm{s}^2}\).
You need to compute the fall time \(t\) from a given height
\(h\). You can re-use the fall_time
function you wrote earlier
to compute \(t(h)\).
Examples:
In [ ]: impact_velocity(0.1)
Out[ ]: 1.4007141035914503
In [ ]: impact_velocity(0.5)
Out[ ]: 3.132091952673165
In [ ]: impact_velocity(1)
Out[ ]: 4.4294469180700204
interval_point(a, b, x)
¶
Write a function interval_point(a, b, x)
that takes three numbers
and interprets a
and b
as the start and end point of an
interval, and interprets x
as a fraction between 0 and 1 that
determines how far to go towards b, starting at a. The function should
return the position described by a, b and x.
Examples:
In [ ]: interval_point(100, 200, 0.5)
Out[ ]: 150.0
In [ ]: interval_point(100, 200, 0.2)
Out[ ]: 120.0
Please include the extra tasks in your file lab2.py
and submit as Computing lab2 assignment.
Back to lab2.
End of lab2-extra.