網站首頁 編程語言 正文
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
相關推薦
- 2023-02-17 Python?樹表查找(二叉排序樹、平衡二叉樹)_python
- 2023-03-05 Python協程的四種實現方式總結_python
- 2022-11-18 Redis?存儲對象信息用?Hash?和String的區(qū)別_Redis
- 2022-09-22 初始化列表 static成員
- 2023-05-31 E:?無法定位軟件包?python3-pip問題及解決_python
- 2022-09-25 什么是模板引擎(web)?常見的模板引擎有哪些?thymeleaf的常用指令介紹
- 2022-03-15 feign.RetryableException: Read timed out executing
- 2023-01-31 go中make用法及常見的一些坑_Golang
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發(fā)現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支