2019年10月15日火曜日

数学 - Python - 円の中にひそむ関数 - 三角関数 - 一般角と三角関数 - 角とその大きさ - 角の大きさの表し方、弧度法(ラジアン)

1. $\begin{array}{l}75·\frac{\pi }{180}\\ =\frac{5}{12}\pi \end{array}$

2. $\begin{array}{l}120·\frac{\pi }{180}\\ =\frac{2}{3}\pi \end{array}$

3. $\begin{array}{l}135·\frac{\pi }{180}\\ =27·\frac{\pi }{36}\\ =\frac{3}{4}\pi \end{array}$

4. $\begin{array}{l}150·\frac{\pi }{180}\\ =\frac{5}{6}\pi \end{array}$

5. $\begin{array}{l}210·\frac{\pi }{180}\\ =\frac{7}{6}\pi \end{array}$

6. $\begin{array}{l}225·\frac{\pi }{180}\\ =45·\frac{\pi }{36}\\ =\frac{5}{4}\pi \end{array}$

7. $\begin{array}{l}270·\frac{\pi }{180}\\ =\frac{3}{2}\pi \end{array}$

8. $\begin{array}{l}300·\frac{\pi }{180}\\ =\frac{5}{3}\pi \end{array}$

コード

Python 3

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import pprint, symbols, pi

print('1.')

def f(x: int) -> float:
return x * pi / 180

class MyTestCase(TestCase):
def setUp(self):
pass

def tearDown(self):
pass

def test(self):
spam = [75, 120, 135, 150, 210, 225, 270, 300]
egg = [5 * pi / 12, 2 * pi / 3, 3 * pi / 4, 5 * pi /
6, 7 * pi / 6, 5 * pi / 4, 3 * pi / 2, 5 * pi / 3]
for s, t in zip(spam, egg):
self.assertEqual(f(s), t)

if __name__ == '__main__':
main()


% ./sample1.py -v
1.
test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.006s

OK
%