Hướng dẫn dùng hypotenuse triangle python
Write a Python program to calculate the hypotenuse of a right angled triangle. From Wikipedia, Pictorial Presentation: Sample Solution-1: Python Code : from math import sqrt print("Input lengths of shorter triangle sides:") a = float(input("a: ")) b = float(input("b: ")) c = sqrt(a**2 + b**2) print("The length of the hypotenuse is:", c )Sample Output: Input lengths of shorter triangle sides: a: 3 b: 4 The length of the hypotenuse is: 5.0Visualize Python code execution:The following tool visualize what the computer is doing step-by-step as it executes the said program: Sample Solution-2: Python Code: Sample Output: 5.0 5.622277118748239Flowchart: Visualize Python code execution:The following tool visualize what the computer is doing step-by-step as it executes the said program: Python Code Editor: Have another way to solve this solution? Contribute your code (and comments) through Disqus. Previous: Write a Python program to convert height (in feet and inches) to centimeters. Python: Tips of the DayIterating over a dictionary: m = {'a': 1, 'b': 2, 'c': 3, 'd': 4} for key, value in m.items(): print('{0}: {1}'.format(key, value)) |