Could you explain to me how the calculations are done using this code!? Sample output is hyp=5, oppo=4, and adj=3
Could you explain to me how the calculations are done using this code!? Sample output is hyp=5, oppo=4, and adj=3
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Could you explain to me how the calculations are done using this code!?
Sample output is hyp=5, oppo=4, and adj=3

Transcribed Image Text:Answer 1 of 1
Done
...
import math
E Calculate the length of the adjacent side of a right triangle
using the length of the hypotenuse and the adjacent angle.
def adjacent_length(hypotenuse, adjacent_angle):
Using hypotenuse and adjacent angle, we will use cosine to find the adjacent length
return hypotenuse • math.cos(nath.radians(adjacent_angle))
Calculate the length of the opposite side of a right triangle
using the length of the hypotenuse and the adjacent angle.
def opposite_length(hypotenuse, adjacent_angle):
EUsing hypotenuse and adjacent angle, we will use sine to find the opposite length
return hypotenuse nath.sin(nath.radians(adjacent_angle))
* calculate adjacent angle from hypotenuse and opposite
def adjacent_angle_from_opposite(hypotenuse, opposite):
Using the opposite and hypotenuse, we will use sine inverse to find the adiacent angle
sine inverse opposite / hypotenuse
sine in python is asin(opposite/ hypotenuse)
return math.degrees(nath.asin(opposite / hypotenuse))
* Calculate the adjacent angle from adjacent and opposite
def adjacent_angle_from_adjacent_opposite(adjacent, opposite):
Using the opposite and hypotenuse, we will use tan inverse to find the adjacent angle
tan inverse opposite / adjacent
tan in python is atan(opposite /adjacent)
return math.degrees(nath.atan(opposite / adjacent))
nain progran
def main():
hypotenuse- float(input("Enter the length of the hypotenuse: ")) = Ask Hypotenuse from user
opposite - float(input("Enter the length of the opposite: "))# Ask Opposite from user
ad jacent - float(input("Enter the length of the adjacent: "))E Ask Adjacent from user
angle - float(input("Enter the adjacent angle of the triangle: *)) = Ask angle from user
print("The length of the adjacent is: ", adjacent_length(hypotenuse, angle)) Print the length
of the adjacent
print("The length of the opposite is: ", opposite_length(hypotenuse, angle)) Print the length
of the opposite
print("The adjacent angle is: ", adjacent_angle_from_opposite(hypotenuse, opposite)) = Print the
ad jacent angle
print("The adjacent angle is: ",
adjacent_angle_from_adjacent_opposite(adjacent, opposite)) Print the adjacent angle
call main
-- ain_ *:
if _name
main()
Enter the length of the hypotenuse: 5
Enter the length of the opposite: 4
Enter the length of the adjacent: 3
Enter the adjacent angle of the triangle: 60
The length of the adjacent is: 2.50ø0000000000004
The length of the opposite is: 4.330127018922193
The adjacent angle is: 53.13010235415599
The adjacent angle is: 53.13010235415598
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education