<jupyter_start><jupyter_text>Hypotenuses  $$hypotenuse = \sqrt{leg1^2 + leg2^2}$$ $$hypotenuse = \sqrt{2 * leg^2}$$  Import modules<jupyter_code>import math
import numpy as np<jupyter_output><empty_output><jupyter_text>Calculate Hypotenuses without NumPy<jupyter_code>legs = range(1, 101)
hypotenuses = [(math.sqrt(2 * leg**2)) for leg in legs]
hypotenuses<jupyter_output><empty_output><jupyter_text>Calculate Hypotenuses with NumPy<jupyter_code>r = np.arange(1, 101)
hypotenuses = np.hypot(r, r)
hypotenuses<jupyter_output><empty_output><jupyter_text>Compare Efficiency<jupyter_code>%%timeit -n 1000
legs = range(1, 101)
hypotenuses = [(math.sqrt(2 * leg**2)) for leg in legs]
%%timeit -n 1000
r = np.arange(1, 101)
hypotenuses = np.hypot(r, r)<jupyter_output>4.59 µs ± 311 ns per loop (mean ± std. dev. of 7 runs, 1000 loops each)
{'fraction_non_alphanumeric': 0.140625, 'fraction_numerical': 0.054086538461538464, 'mean_word_length': 7.087378640776699, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '448842', 'license': 'MIT', 'n_tokens_mistral': 394, 'n_tokens_neox': 343, 'n_words': 74, 'path': 'numpy/Solutions/hypotenuses.ipynb', 'repo_name': 'WebucatorTraining/classfiles-actionable-python', 'size': '832'}