-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslide.py
More file actions
35 lines (29 loc) · 1.18 KB
/
slide.py
File metadata and controls
35 lines (29 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# TRYIT: Import the required math functions
from math import degrees, hypot, sqrt, tan
# TRYIT: Create variables to store the triangle sides input by the user
a = input("Enter the rise of the slide's ladder: ")
b = input("Enter the run of the base of the slide: ")
# TRYIT: Use the int() function to convert the input string values to integers
rise = int(a)
run = int(b)
# TRYIT: Calculate the values
sidea = rise * rise
sideb = run * run
slide = int(sqrt(sidea + sideb))
# You could also use:
# slide = int(hypot(rise, run))
pitch = int(degrees(tan(rise/run)))
# TRYIT: Create a Boolean variable to store true or false if the slide length meets safety standards
slidesafe = False
# TRYIT: Create an if...elif...else statement to test the measurements of the slide
if pitch > 40:
slidesafe = False
elif rise > 7:
slidesafe = False
else:
slidesafe = True
# TRYIT Use an if...else statement to test whether the Boolean variable is True or False, and print the results
if slidesafe == True:
print("Safe! The pitch is: " + str(pitch) + " degrees and your slide length is: " + str(slide))
else:
print("Unsafe! The pitch is: " + str(pitch) + " degrees and your slide length is: " + str(slide))