How do you use the output of one function, as an inputted value in another?

I am doing a coding project for school, where I have the following prompt:

In a target practice exercise, a student holds a rifle 5 meters away from a target. The target is tossed up at 5 meters/second. Write a function that takes in the angle (in degrees) at which the student is holding their rifle and provides the time in seconds after the target is released that the student should shoot. Specify units in your input(). (Assume the speed of the target is constant – ignore gravity). Make sure to include a caller after and a docstring in all of your functions. Use the math module.

I have the following code:

#Imports the math function
import math

#Prompts the user to input the angle of which the rifle is pointed in the air
angle = float(input("Enter the angle of which the rifle is pointed in the air (In degrees): "))

#Function to determine length of shot
def length_of_shot():
    #Multiplies the inputted angle (Converted to radians) with the adjancent side (5) to figure out opposite side (Height in the air)
    return math.tan(math.radians(angle)) * 5

#Function to determine time to shoot
def time_to_shoot(): 
    #Divide by 5 since the target is tossed in the air at 5 meters / second
    return lenth_of_shot / 5

#Calls the time_to_shoot function
time_to_shoot()

I am trying to figure out how to take the output value from the function “length_of_shot”

def length_of_shot():
    return math.tan(math.radians(angle)) * 5

And use it in this equation in the function “time_to_shoot”

def time_to_shoot(): 
    return length_of_shot / 5

Answer

You need to provide parameters to your functions, and use their return values. Also, you need to call length_of_shot to get its return value, as otherwise you’ll be dividing the function object, which will result in an error.

#Imports the math function
import math

#Prompts the user to input the angle of which the rifle is pointed in the air
angle = float(input("Enter the angle of which the rifle is pointed in the air (In degrees): "))

#Function to determine length of shot
def length_of_shot(angle):
    #Multiplies the inputted angle (Converted to radians) with the adjancent side (5) to figure out opposite side (Height in the air)
    return math.tan(math.radians(angle)) * 5

#Function to determine time to shoot
def time_to_shoot(angle): 
    #Divide by 5 since the target is tossed in the air at 5 meters / second
    return length_of_shot(angle) / 5

#Calls the length_of_shot function
time_to_shoot(angle)

When the instructions say “Write a function that takes in the angle“, they mean that the angle should be passed in as a parameter.