Photo by chuttersnap on Unsplash

an object moves along the x-axis. The function x(t) gives the object’s position at any time:

x(t) = t^3 - 4t^2 + 3t -2

Time(t) \geq 0

Define a function to calculate velocity and acceleration.

Velocity

v(t) = x'(t) = 3t^2 - 8t + 3

Accelation

a(t) = x''(t) = 6t - 8

def vafunc(time, ctype):
    """ 
	Velocity or Accelation calculate function
        Usage vafunc(time, type)
        time non-negative, 
        type one of v or a
        v = Velocity
        a = Accelation 
    """
    if time < 0:
        print("time should not be negative")
        return
    if ctype == 1:
        o = 3*time**2 - 8*time +3
        ct = 'Velocity v('
    elif ctype == 2:
        o = 6*time - 8
        ct = 'Accelation a('
    return ct + str(time) + ')' + ' = ' + str(o)
v = 1; a = 2