Hướng dẫn dùng constants math python
botvietbai.com cung cấp các hướng dẫn, tài liệu tham khảo và bài tập trực tuyến miễn phí bằng tất cả các ngôn ngữ chính của web. Bao gồm các chủ đề phổ biến như HTML, CSS, JavaScript, Python, SQL, Java, và nhiều hơn nữa. Nội dung chính Show Nội dung chính
Nội dung chính
Nội dung chính
Nội dung chính
Hits:102 102
Related posts: Python math.nan ConstantVí dụ Cú pháp Related posts: ❮ Phương pháp Toán học Định nghĩa và Cách sử dụngIn giá trị nan: # Import math Libraryimport math Ví dụChi tiết kỹ thuật
Related posts: botvietbai.com ❮ Phương pháp Toán học
Thuộc tính đối tượng toán học PythonChức năng đặc biệt
Hằng số nan tương đương với pi Constant - Pi = 3.141592653589793 pi Constant - Degrees of Pi = 180.0 e Constant - e = 3.141592653589793 e Constant - Degrees of e = 155.74607629780772 tau Constant - tau = 6.283185307179586 tau Constant - Degrees of tau = 360.0 inf Constant - Positive Infinity = inf inf Constant - Negative Infinity = -inf NaN Constant - Not a Number = nan6 .
Hàm lũy thừa và lôgaritSau đây là danh sách các hàm Power và logarit có sẵn trong Thư viện toán học Python.
Hàm lượng giácSau đây là danh sách các hàm lượng giác có trong Thư viện toán học Python.
Phương pháp lượng giácacos (x)
sqrt (x)Căn bậc hai của một biểu thức Python được chỉ định hoặc một số riêng lẻ
log (x, cơ số)Hàm toán học lôgarit và Power trong Python này tìm giá trị log của một số có cơ số E.
log10 (x)Giá trị lôgarit của một số đã cho với cơ số E. pow (x)Hàm lũy thừa và logarit này tính lũy thừa của biểu thức được chỉ định import math as td print('pi Constant - Pi = ', td.pi) print('pi Constant - Degrees of Pi = ', td.degrees(td.pi)) print('ne Constant - e=", td.pi) print("e Constant - Degrees of e=", td.degrees(td.e)) print("ntau Constant - tau = ', td.tau) print('tau Constant - Degrees of tau = ', td.degrees(td.tau)) print('ninf Constant - Positive Infinity = ', td.inf) print('inf Constant - Negative Infinity = ', -td.inf) print('nNaN Constant - Not a Number=", td.nan) pi Constant - Pi = 3.141592653589793 pi Constant - Degrees of Pi = 180.0 e Constant - e = 3.141592653589793 e Constant - Degrees of e = 155.74607629780772 tau Constant - tau = 6.283185307179586 tau Constant - Degrees of tau = 360.0 inf Constant - Positive Infinity = inf inf Constant - Negative Infinity = -inf NaN Constant - Not a Number = nan sqrt (x)Căn bậc hai của một biểu thức Python được chỉ định hoặc một số riêng lẻ import math as mh x = 10.98 y = 30.22 z = -40.95 print("FABS - Absolute Value of z = ', mh.fabs(z)) print('FABS - Absolute Value of -124.897 = ', mh.fabs(-124.897)) print('ncopysign of x, z = ', mh.copysign(x, z)) print('copysign of z, x = ', mh.copysign(z, x)) print('nCEIL - Ceiling of x = ', mh.ceil(x)) print('CEIL - Ceiling of y = ', mh.ceil(y)) print('nFLOOR - Floor of x = ', mh.floor(x)) print('FLOOR - Floor of y = ', mh.floor(y)) print('nFactorial of 3 = ', mh.factorial(3)) print('Factorial of 5 = ', mh.factorial(5)) FABS - Absolute Value of z = 40.95 FABS - Absolute Value of -124.897 = 124.897 copysign of x, z = -10.98 copysign of z, x = 40.95 CEIL - Ceiling of x = 11 CEIL - Ceiling of y = 31 FLOOR - Floor of x = 10 FLOOR - Floor of y = 30 Factorial of 3 = 6 Factorial of 5 = 120 Các hàm trong toán học Python Ví dụ 2Trong ví dụ này, chúng tôi đã sử dụng fmod, frexp, fsum và gcd với các giá trị khác nhau. import math as gm print('FMOD - Mod of 2 and 3 = ', gm.fmod(2, 3)) print('FMOD - Mod of 225.55 and 5.5 = ', gm.fmod(222.55, 5.5)) print('nFREXP - Mantissa and Exponent Value of 5 = ', gm.frexp(5)) print('FREXP - Mantissa and Exponent Value of -9 = ', gm.frexp(-9)) print('nFSUM - Sum of Tuple Items=", gm.fsum((10, 20, 30, 40))) print("FSUM - Sum of List Items=", gm.fsum([5, 22, 35, 9])) print("nGCD of two 10 and 2 = ', gm.gcd(10, 2)) print('GCD of two 100 and 15 = ', gm.gcd(100, 15)) FMOD - Mod of 2 and 3 = 2.0 FMOD - Mod of 225.55 and 5.5 = 2.5500000000000114 FREXP - Mantissa and Exponent Value of 5 = (0.625, 3) FREXP - Mantissa and Exponent Value of -9 = (-0.5625, 4) FSUM - Sum of Tuple Items = 100.0 FSUM - Sum of List Items = 71.0 GCD of two 10 and 2 = 2 GCD of two 100 and 15 = 5 Các hàm trong toán học Python Ví dụ 3Trong ví dụ về Hàm toán học Python này, chúng tôi đã sử dụng round, ldexp, mode, trunc và phần còn lại. import math as at print('ROUND - Rounded Number 100.98763 = ', round(100.9876, 2)) print('ROUND - Rounded Number 125.932832 = ', round(125.932832, 3)) print('nLDEXP - LDEXP (FREXP inverse) Number of 4, 5 = ', at.ldexp(4, 5)) print('LDEXP - LDEXP (FREXP inverse) Number of -9, 2 = ', at.ldexp(-9, 2)) print('nMODF - Modf (Divided 1 to 2) Number of 100 = ', at.modf(100)) print('MODF - Modf (Divided 1 to 2) Number of 120.98 = ', at.modf(120.98)) print('nTRUNC - Truncated Number 100.98763 = ', at.trunc(100.9876)) print('ROUND - Truncated Number 125.932832 = ', at.trunc(-125.932832)) print('nRemainder of 29 and 5 = ', at.remainder(20, 5)) print('Remainder of 10 and 3 = ', at.remainder(10, 3)) ROUND - Rounded Number 100.98763 = 100.99 ROUND - Rounded Number 125.932832 = 125.933 LDEXP - LDEXP (FREXP inverse) Number of 4, 5 = 128.0 LDEXP - LDEXP (FREXP inverse) Number of -9, 2 = -36.0 MODF - Modf (Divided 1 to 2) Number of 100 = (0.0, 100.0) MODF - Modf (Divided 1 to 2) Number of 120.98 = (0.980000000000004, 120.0) TRUNC - Truncated Number 100.98763 = 100 ROUND - Truncated Number 125.932832 = -125 Remainder of 29 and 5 = 0.0 Remainder of 10 and 3 = 1.0 Ví dụ về hàm lôgaritTrong ví dụ Logarit Python này, chúng tôi sử dụng toán học exp, expm1 để nhận các giá trị exp. Tiếp theo, chúng tôi sử dụng log, log2 và log10 để lấy giá trị logarit tự nhiên, giá trị logarit cơ số 2. Và giá trị logarit cơ số 10. Sau đó, chúng tôi sử dụng pow để tìm x được nâng lên thành lũy thừa của y và sqrt để tìm căn bậc hai của một số. import math as th print('exp of 5 = ', th.exp(5)) print('exp of -3 = ', th.exp(-3)) print('nexpm1 of 8 = ', th.expm1(8)) print('expm1 of -5 = ', th.expm1(-5)) print('nLOG - logarithmic of 5 = ', th.log(5)) print('LOG - logarithmic of 100 Base 2 = ', th.log(100, 2)) print('nLOG2 - logarithmic of 120 Base 2 = ', th.log2(120)) print('nLOG10 - logarithmic of 150 Base 10 = ', th.log2(150)) print('nPOW - 2 Power 3 = ', th.pow(2, 3)) print('POW - 5 Power 4 = ', th.pow(5, 4)) print('nSQRT - Square Root of 25 = ', th.sqrt(25)) print('SQRT - Square Root of 19 = ', th.sqrt(19)) exp of 5 = 148.4131591025766 exp of -3 = 0.049787068367863944 expm1 of 8 = 2979.9579870417283 expm1 of -5 = -0.9932620530009145 LOG - logarithmic of 5 = 1.6094379124341003 LOG - logarithmic of 100 Base 2 = 6.643856189774725 LOG2 - logarithmic of 120 Base 2 = 6.906890595608519 LOG10 - logarithmic of 150 Base 10 = 7.22881869049588 POW - 2 Power 3 = 8.0 POW - 5 Power 4 = 625.0 SQRT - Square Root of 25 = 5.0 SQRT - Square Root of 19 = 4.358898943540674 Các hàm lượng giác Ví dụ 1Trong ví dụ toán lượng giác Python này, chúng ta sẽ sử dụng sin, cos và tan để tìm các giá trị sin, cosine và tiếp tuyến. Tiếp theo, chúng tôi sử dụng acos, asin, atan và atan2 để tìm các giá trị Arc cosine, Arc Sine và Arc Tangent. Trong tuyên bố cuối cùng, chúng tôi đã sử dụng giả thuyết pi Constant - Pi = 3.141592653589793 pi Constant - Degrees of Pi = 180.0 e Constant - e = 3.141592653589793 e Constant - Degrees of e = 155.74607629780772 tau Constant - tau = 6.283185307179586 tau Constant - Degrees of tau = 360.0 inf Constant - Positive Infinity = inf inf Constant - Negative Infinity = -inf NaN Constant - Not a Number = nan0 pi Constant - Pi = 3.141592653589793 pi Constant - Degrees of Pi = 180.0 e Constant - e = 3.141592653589793 e Constant - Degrees of e = 155.74607629780772 tau Constant - tau = 6.283185307179586 tau Constant - Degrees of tau = 360.0 inf Constant - Positive Infinity = inf inf Constant - Negative Infinity = -inf NaN Constant - Not a Number = nan1 Các hàm lượng giác Ví dụ 2Trong ví dụ toán học Python này, chúng tôi sử dụng các hàm lượng giác Hyperbolic. Đầu tiên, chúng tôi sử dụng cosh, sinh và tanh để tìm các giá trị Hyperbolic Cosine, Sine và Tiếp tuyến. Tiếp theo, acosh, asinh và atanh để tìm giá trị cosin Hyperbolic Arc, Arc Sine và Hyperbolic Arc Tangent. pi Constant - Pi = 3.141592653589793 pi Constant - Degrees of Pi = 180.0 e Constant - e = 3.141592653589793 e Constant - Degrees of e = 155.74607629780772 tau Constant - tau = 6.283185307179586 tau Constant - Degrees of tau = 360.0 inf Constant - Positive Infinity = inf inf Constant - Negative Infinity = -inf NaN Constant - Not a Number = nan2 pi Constant - Pi = 3.141592653589793 pi Constant - Degrees of Pi = 180.0 e Constant - e = 3.141592653589793 e Constant - Degrees of e = 155.74607629780772 tau Constant - tau = 6.283185307179586 tau Constant - Degrees of tau = 360.0 inf Constant - Positive Infinity = inf inf Constant - Negative Infinity = -inf NaN Constant - Not a Number = nan3 Ví dụ về hàm góc và hàm đặc biệtTrong ví dụ Angular này, chúng tôi đã sử dụng độ và radian để chuyển đổi độ sang radian ngược lại. Tiếp theo, chúng tôi sử dụng gamma và lgamma để trả về các giá trị gamma. pi Constant - Pi = 3.141592653589793 pi Constant - Degrees of Pi = 180.0 e Constant - e = 3.141592653589793 e Constant - Degrees of e = 155.74607629780772 tau Constant - tau = 6.283185307179586 tau Constant - Degrees of tau = 360.0 inf Constant - Positive Infinity = inf inf Constant - Negative Infinity = -inf NaN Constant - Not a Number = nan4 |