情報学部 | 菅沼ホーム | 目次 | 索引 |
>>> from math import * >>> degrees(acos(0.5)) 60.00000000000001
>>> from math import * >>> acosh(1.0) 0.0 >>> cosh(0.0) 1.0
>>> from math import * >>> degrees(asin(0.5)) 30.000000000000004
>>> from math import * >>> asinh(1.0) 0.8813735870195429 >>> sinh(0.8813735870195429) 0.9999999999999999
>>> from math import * >>> degrees(atan(1.0)) 45.0
>>> from math import * >>> degrees(atan(-1.0 / -1.0)) 45.0 >>> degrees(atan2(-1.0, -1.0)) -135.0 >>> degrees(atan2(1.0, 0.0)) 90.0
>>> from math import * >>> atanh(0.1) 0.1003353477310756 >>> tanh(0.1003353477310756) 0.10000000000000002
>>> from math import * >>> ceil(3.14) 4 >>> ceil(-3.14) -3
>>> from math import * >>> copysign(3.14, -2.0) -3.14
>>> from math import * >>> cos(radians(60.0)) 0.5000000000000001
>>> from math import * >>> acosh(1.0) 0.0 >>> cosh(0.0) 1.0
>>> from math import * >>> x = radians(45.0) >>> x 0.7853981633974483 >>> degrees(x) 45.0
>>> from math import * >>> erf(0.5) 0.5204998778130465 >>> erfc(0.5) 0.4795001221869535 >>> 1.0 - erf(0.5) 0.4795001221869535
>>> from math import * >>> erf(0.5) 0.5204998778130465 >>> erfc(0.5) 0.4795001221869535 >>> 1.0 - erf(0.5) 0.4795001221869535
>>> from math import * >>> x = exp(-0.1) >>> x 0.9048374180359595 >>> log(x) -0.10000000000000006
>>> from math import * >>> exp(0.00001) - 1.0 1.0000050000069649e-05 >>> expm1(0.00001) 1.0000050000166667e-05
>>> from math import * >>> fabs(-4.6) 4.6
>>> from math import * >>> factorial(5) 120
>>> from math import * >>> floor(3.4) 3 >>> floor(-3.4) -4
>>> from math import * >>> fmod(4.5, 2.1) 0.2999999999999998
>>> from math import * >>> frexp(0.00123) (0.62976, -9) >>> 0.62976 * pow(2, -9) 0.00123 >>> ldexp(0.62976, -9) 0.00123
>>> from math import * >>> fsum([1.2, 3.4, 0.001]) 4.601
>>> from math import * >>> gamma(5) 24.0 >>> lgamma(5) 3.178053830347945 >>> log(24.0) 3.1780538303479458
>>> from math import * >>> gcd(6, 15) 3
>>> from math import * >>> hypot(1.0, 2.0) 2.23606797749979
>>> from math import * >>> isclose(0.001, 0.001001, rel_tol=1e-3) True >>> isclose(0.001, 0.001001, rel_tol=0.0, abs_tol=0.001) True
>>> from math import * >>> isfinite(inf) False
>>> from math import * >>> isinf(inf) True
>>> from math import * >>> isnan(nan) True
>>> from math import * >>> frexp(0.00123) (0.62976, -9) >>> 0.62976 * pow(2, -9) 0.00123 >>> ldexp(0.62976, -9) 0.00123
>>> from math import * >>> gamma(5) 24.0 >>> lgamma(5) 3.178053830347945 >>> log(24.0) 3.1780538303479458
>>> from math import * >>> x = exp(-0.1) >>> x 0.9048374180359595 >>> log(x) -0.10000000000000006
>>> from math import * >>> log1p(0.00001) 9.99995000033333e-06 >>> log(1 + 0.00001) 9.999950000398841e-06
>>> from math import * >>> modf(-3.14) (-0.14000000000000012, -3.0)
>>> from math import * >>> pow(2.0, 0.5) 1.4142135623730951 >>> 2.0 ** 0.5 1.4142135623730951 >>> sqrt(2.0) 1.4142135623730951
>>> from math import * >>> x = radians(45.0) >>> x 0.7853981633974483 >>> degrees(x) 45.0
>>> from math import * >>> sin(radians(30.0)) 0.49999999999999994
>>> from math import * >>> asinh(1.0) 0.8813735870195429 >>> sinh(0.8813735870195429) 0.9999999999999999
>>> from math import * >>> pow(2.0, 0.5) 1.4142135623730951 >>> 2.0 ** 0.5 1.4142135623730951 >>> sqrt(2.0) 1.4142135623730951
>>> from math import * >>> tan(radians(45.0)) 0.9999999999999999
>>> from math import * >>> atanh(0.1) 0.1003353477310756 >>> tanh(0.1003353477310756) 0.10000000000000002
>>> from math import * >>> trunc(3.14) 3
>>> from cmath import * >>> cos(1 + 1j) (0.8337300251311491-0.9888977057628651j) >>> acos(0.8337300251311491-0.9888977057628651j) (0.9999999999999999+1j)
>>> from cmath import * >>> cosh(1 + 1j) (0.8337300251311491+0.9888977057628651j) >>> acosh(0.8337300251311491+0.9888977057628651j) (1+0.9999999999999999j)
>>> from cmath import * >>> sin(1 + 1j) (1.2984575814159773+0.6349639147847361j) >>> asin(1.2984575814159773+0.6349639147847361j) (1+1j)
>>> from cmath import * >>> sinh(1 + 1j) (0.6349639147847361+1.2984575814159773j) >>> asinh(0.6349639147847361+1.2984575814159773j) (1+1j)
>>> from cmath import * >>> tan(1 + 1j) (0.2717525853195117+1.0839233273386946j) >>> atan(0.2717525853195117+1.0839233273386946j) (1+1j)
>>> from cmath import * >>> tanh(1 + 1j) (1.0839233273386946+0.2717525853195117j) >>> atanh(1.0839233273386946+0.2717525853195117j) (1+1j)
>>> from cmath import * >>> cos(1 + 1j) (0.8337300251311491-0.9888977057628651j) >>> acos(0.8337300251311491-0.9888977057628651j) (0.9999999999999999+1j)
>>> from cmath import * >>> cosh(1 + 1j) (0.8337300251311491+0.9888977057628651j) >>> acosh(0.8337300251311491+0.9888977057628651j) (1+0.9999999999999999j)
>>> from cmath import * >>> exp(complex(0, pi / 2)) (6.123233995736766e-17+1j)
>>> from cmath import * >>> isclose(1+1j, 1+1.0001j, rel_tol=0.001) True
>>> from cmath import * >>> isfinite(inf + 1j) False
>>> from cmath import * >>> isinf(inf + 1j) True
>>> from cmath import * >>> isnan(nan + 1j) True
>>> from cmath import * >>> log(1 + 1j) (0.34657359027997264+0.7853981633974483j)
>>> from cmath import * >>> log10(1 + 1j) (0.15051499783199057+0.3410940884604603j)
>>> from cmath import * >>> degrees(phase(complex(1.0, 1.0))) 45.0
>>> from cmath import * >>> polar(complex(1.0, 1.0)) (1.4142135623730951, 0.7853981633974483)
>>> from cmath import * >>> import math >>> rect(math.sqrt(2.0), radians(45.0)) (1.0000000000000002+1j)
>>> from cmath import * >>> sin(1 + 1j) (1.2984575814159773+0.6349639147847361j) >>> asin(1.2984575814159773+0.6349639147847361j) (1+1j)
>>> from cmath import * >>> sinh(1 + 1j) (0.6349639147847361+1.2984575814159773j) >>> asinh(0.6349639147847361+1.2984575814159773j) (1+1j)
>>> from cmath import * >>> sqrt(1 + 1j) (1.09868411346781+0.45508986056222733j)
>>> from cmath import * >>> tan(1 + 1j) (0.2717525853195117+1.0839233273386946j) >>> atan(0.2717525853195117+1.0839233273386946j) (1+1j)
>>> from cmath import * >>> tanh(1 + 1j) (1.0839233273386946+0.2717525853195117j) >>> atanh(1.0839233273386946+0.2717525853195117j)(1+1j)
>>> from random import * >>> betavariate(1.0, 2.0) 0.7137512751672623
>>> from random import * >>> choice([1, 2, 3, 4, 5]) 4 >>> choice([1, 2, 3, 4, 5]) 3
>>> from random import * >>> expovariate(2.0) # 2.0 は平均値の逆数(λ) 0.3687274660201018
>>> from random import * >>> gammavariate(1.0, 2.0) 1.4556376656902985
>>> from random import * >>> gauss(0, 1.0) # 標準正規分布 0.6178997336284542
>>> from random import * >>> getrandbits(20) 54907
>>> from random import * >>> lognormvariate(0, 1.0) 16.76806615681981
>>> from random import * >>> normalvariate(0, 1.0) 0.44329264392416573
>>> from random import * >>> paretovariate(1.0) 6.006394708695113
>>> from random import * >>> random() 0.8786303371012171
>>> from random import * >>> randrange(100) 34 >>> randrange(100) 11
>>> from random import * >>> sample(range(100), 5) [20, 0, 55, 99, 11]
>>> from random import * >>> x = [1, 2, 3, 4, 5] >>> shuffle(x) >>> x [2, 1, 4, 5, 3]
>>> from random import * >>> triangular(5, 10) 8.919537010144266 >>> triangular() 0.3819695793057113
>>> from random import * >>> uniform(0, 2) 1.4640785075474039
>>> from random import * >>> vonmisesvariate(pi, 1.0) 4.14502416163938
>>> from random import * >>> weibullvariate(1.0, 5.0) 0.8853138662142248
>>> from statistics import * >>> mean([1, 2, 3, 3, 4, 4, 4, 5]) 3.25
>>> from statistics import * >>> median([1, 2, 3, 3, 4, 4, 4, 5]) 3.5
>>> from statistics import * >>> median_grouped([1, 2, 3, 3, 4, 4, 4, 5]) 3.5 >>> median_grouped([1, 2, 3, 3, 4, 4, 4, 5], 4) 2.0
>>> from statistics import * >>> median_high([1, 2, 3, 3, 4, 4, 4, 5]) 4
>>> from statistics import * >>> median_low([1, 2, 3, 3, 4, 4, 4, 5]) 3
>>> from statistics import * >>> mode([1, 2, 3, 3, 4, 4, 4, 5]) 4
>>> from statistics import * >>> pvariance([1, 2, 3, 3, 4, 4, 4, 5]) 1.4375 >>> pstdev([1, 2, 3, 3, 4, 4, 4, 5]) 1.1989578808281798 >>> math.sqrt(pvariance([1, 2, 3, 3, 4, 4, 4, 5])) 1.1989578808281798
>>> from statistics import * >>> pvariance([1, 2, 3, 3, 4, 4, 4, 5]) 1.4375 >>> variance([1, 2, 3, 3, 4, 4, 4, 5]) 1.6428571428571428
>>> from statistics import * >>> variance([1, 2, 3, 3, 4, 4, 4, 5]) 1.6428571428571428 >>> stdev([1, 2, 3, 3, 4, 4, 4, 5]) 1.2817398889233114 >>> math.sqrt(variance([1, 2, 3, 3, 4, 4, 4, 5])) 1.2817398889233114
>>> from statistics import * >>> pvariance([1, 2, 3, 3, 4, 4, 4, 5]) 1.4375 >>> variance([1, 2, 3, 3, 4, 4, 4, 5]) 1.6428571428571428
>>> from fractions import Fraction >>> x = Fraction(0.75) >>> x.numerator 3 >>> x.denominator 4
>>> from fractions import Fraction >>> Fraction(numerator=3, denominator=4) Fraction(3, 4) >>> Fraction(0.75) Fraction(3, 4) >>> Fraction(1.75) Fraction(7, 4) >>> Fraction(0.73) Fraction(1643813863990231, 2251799813685248) >>> Fraction(2) Fraction(2, 1) >>> Fraction(0) Fraction(0, 1) >>> Fraction() Fraction(0, 1) >>> Fraction("3/4") # '/' の前後にスペースを入れてはいけない Fraction(3, 4) >>> Fraction("0.75") Fraction(3, 4)
>>> from fractions import Fraction >>> Fraction(3,10) Fraction(3, 10) >>> Fraction.from_float(0.3) Fraction(5404319552844595, 18014398509481984) >>> from decimal import Decimal >>> Fraction.from_decimal(Decimal("0.3")) Fraction(3, 10)
>>> from fractions import Fraction >>> Fraction(3,10) Fraction(3, 10) >>> Fraction.from_float(0.3) Fraction(5404319552844595, 18014398509481984) >>> from decimal import Decimal >>> Fraction.from_decimal(Decimal("0.3")) Fraction(3, 10)
>>> from fractions import Fraction >>> x = Fraction(0.3) >>> x.limit_denominator(20) Fraction(3, 10)
>>> from fractions import Fraction >>> x = Fraction(0.75) >>> x.numerator 3 >>> x.denominator 4
情報学部 | 菅沼ホーム | 目次 | 索引 |