Skip to content
Exercises · Q21

Q.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
Yanam CbseNCERTSubjective· 3mImportance★★★★★est
98% · 48/49 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

height = length × sin(angle), converting degrees to radians first — giving ≈ 15.45 ft, 0.0 ft, ≈ 16.97 ft and ≈ 23.64 ft for the four cases.

The geometry: the ladder, the wall and the ground form a right triangle in which the ladder is the hypotenuse and the angle is at the ground. The height reached on the wall is the side opposite the angle, so height = length × sin(angle). The programming concept is that math.sin() expects radians, so the degree inputs must go through math.radians() first.

# Height reached on the wall by a leaning ladder
import math

for length, angle in [(16, 75), (20, 0), (24, 45), (24, 80)]:
    height = length * math.sin(math.radians(angle))
    print(length, "feet at", angle, "degrees -> height", round(height, 2), "feet")

Key lines:

  • math.radians(angle) converts degrees to radians (75° → 1.3089…). Feeding degrees straight into math.sin is the classic bug — sin(75 radians) ≈ −0.39, a nonsense height.
  • The loop evaluates all four required cases in one run.

Working for each case:

Caselengthanglesin(angle)height = length × sin
a16 ft75°0.965915.45 ft
b20 ft0°0.00.0 ft
c24 ft45°0.707116.97 ft
d24 ft80°0.984823.64 ft

Expected output:

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.