wiz-icon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

Presume that a ladder is put upright against a wall. Let variables length and angle store the length of the ladder and the angle that it forms with the ground as it leans against the wall. Write a Python program to compute the height reached by the ladder on the wall for the following values of length and angle:
a) 16 feet and 75 degrees
b) 20 feet and 0 degrees
c) 24 feet and 45 degrees
d) 24 feet and 80 degrees

Open in App
Solution

The diagram can be drawn as follows:



ladder aligned with wall
Here:
sin(θ) = height / length
⇒ height = length × sin(θ)


To calculate the sin() value in Python, math module sin() function is needed. The values need to be passed in radians to the sin() function. Therefore, the degree will be converted to radians and then the sin() function will be applied.

Program:

#import the math module, to use sin & radians function
import math
length = int(input("Enter the length of the ladder: "))
degrees = int(input("Enter the alignment degree: "))
#Converting degrees to radian
radian = math.radians(degrees)
#Computing sin value
sin = math.sin(radian)
# Calculating height and rounding it off to 2 decimal places
height = round(length * sin,2)
#displaying the output
print("The height reached by ladder with length",length,"feet and aligned at",degrees,"degrees is",height, "feet.")


OUTPUT:
a) Enter the length of the ladder: 16
Enter the alignment degree: 75
The height reached by the ladder with length 16 feet aligned at 75 degrees is 15.45 feet.


b) Enter the length of the ladder: 20
Enter the alignment degree: 0
The height reached by the ladder with length 20 feet and aligned at 0 degrees is 0.0 feet.


c) Enter the length of the ladder: 24
Enter the alignment degree: 45
The height reached by the ladder with length 24 feet and aligned at 45 degrees is 16.97 feet.


d) Enter the length of the ladder: 24
Enter the alignment degree: 80
The height reached by the ladder with length 24 feet and aligned at 80 degrees is 23.64 feet.

flag
Suggest Corrections
thumbs-up
3
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Trigonometric Functions in a Right Angled Triangle
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon