網站首頁 編程語言 正文
math常用方法
1.math.ceil()向上取整
import math
print(math.ceil(56.1))
57
2.math.floor()向下取整
import math
print(math.floor(56.1))
56
3.math.fabs()取絕對值
import math
print(math.fabs(56))
print(math.fabs(-56))
56.0
56.0
4.math.fmod()求模運算
import math
print(math.fmod(56,2))
0.0
5.math.isnan()判斷是不是(nan)不是一個數字
import math
print(math.isnan(56))
print(math.isnan(math.nan))
False
True
注意:不是數字則返回Ture,是數字則返回Flase
6.math.isinf()判斷是不是無窮大
import math
print(math.isinf(56))
print(math.isinf(math.inf))
False
True
注意:正無窮大或負無窮大則返回Ture,否則返回Flase
7.math.isfinite()判斷是不是無限
8.math.e 屬性,自然常數
返回歐拉數
9.math.pi 圓周率
返回圓周率
import math
print(math.e)
print(math.pi)
2.718281828459045
3.141592653589793
10.math.power 冪次方
11.math.sqrt 開平方根
import math
print(math.pow(2,2))
print(math.sqrt(4))
4.0
2.0
原文鏈接:https://blog.csdn.net/Thewei666/article/details/125815275
相關推薦
- 2022-05-25 Python中PyAutoGUI幫助文檔(推薦!)_python
- 2023-12-09 出現錯誤:SLF4J: Class path contains multiple SLF4J bin
- 2022-08-04 Go?slice切片使用示例詳解_Golang
- 2022-02-11 git clone報RPC failed; curl 18 transfer closed with
- 2022-07-25 View事件分發原理和ViewPager+ListView嵌套滑動沖突_Android
- 2022-10-03 C++模擬實現vector流程詳解_C 語言
- 2022-04-26 Python?Socket?編程知識點詳細介紹_python
- 2022-07-20 C/C++詳解實現二層轉發_C 語言
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支