Python Programming – John Zelle: Chapter 3 ex. 10

Write a program to determine the length of a ladder required to reach a given height when leaned against a house. The height and angle of the ladder are given as inputs.

Chapter 3 Exercise 10

Python

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #Chapter 3 Exercise 10 # Write a program to determine the length of a ladder # required to reach a given height when leaned against a house. # The height and angle of the ladder are given as inputs. from math import * def main(): print("This program to calculates the length of a ladder.") height = eval(input("How high do you need the ladder to reach? ")) angle = eval(input("At what angle will the ladder be leaning against the house? ")) angler = ((pi / 180) * angle) length = (height / sin(angler)) print("The length of ladder required is ", length) main() |

Run =

This program to calculates the length of a ladder.

How high do you need the ladder to reach? 15

At what angle will the ladder be leaning against the house? 70

The length of ladder required is 15.962666587138683