Donello - 1 year ago 84

Python Question

I am trying to solve a homework: I am required to write a program which will calculate the length of a ladder based on two inputs, that is the desired height to be reached and the angle created by leaning the ladder toward the wall.

I used the following formula to convert degrees to radians :

`radians = (math.pi / 180) * x # x is the given angle by the user.`

I imported the math library as well to use its functions.

`def main():`

import math

print("this program calculates the length of a ladder after you give the height and the angle")

h = eval(input("enter the height you want to reach using the ladder"))

x = eval(input("enter the angle which will be created be leaning the ladder to the wall"))

radians = ( math.pi / 180 ) * x

length = h / math.sin(x)

print("the length is:", length)

main()

What exactly am I doing wrong?

I know the code is missing something and would appreciate it if someone could help me fill the gap.

Answer Source

You never used `radians`

after you calculate it.

i.e. `length = h / math.sin(radians)`