資訊內容
python e怎么表示
python e的表示方法:使用【exp()】方法,代碼為【import math;math.exp( x );】,【exp()】是不能直接訪問的,需要導入math模塊,通過靜態對象調用該方法。a7H少兒編程網-https://www.pxcodes.com
a7H少兒編程網-https://www.pxcodes.com
本教程操作環境:windows7系統、python3.9版,DELL G3電腦。a7H少兒編程網-https://www.pxcodes.com
python e的表示方法:a7H少兒編程網-https://www.pxcodes.com
exp()方法返回x的指數,ex。a7H少兒編程網-https://www.pxcodes.com
語法a7H少兒編程網-https://www.pxcodes.com
以下是 exp() 方法的語法:a7H少兒編程網-https://www.pxcodes.com
import math math.exp( x )注意:exp()是不能直接訪問的,需要導入 math 模塊,通過靜態對象調用該方法。a7H少兒編程網-https://www.pxcodes.com
參數a7H少兒編程網-https://www.pxcodes.com
x -- 數值表達式。a7H少兒編程網-https://www.pxcodes.com
返回值a7H少兒編程網-https://www.pxcodes.com
返回x的指數,ex。a7H少兒編程網-https://www.pxcodes.com
實例a7H少兒編程網-https://www.pxcodes.com
以下展示了使用 exp() 方法的實例:a7H少兒編程網-https://www.pxcodes.com
#!/usr/bin/python import math # 導入 math 模塊 print "math.exp(-45.17) : ", math.exp(-45.17) print "math.exp(100.12) : ", math.exp(100.12) print "math.exp(100.72) : ", math.exp(100.72) print "math.exp(119L) : ", math.exp(119L) print "math.exp(math.pi) : ", math.exp(math.pi)以上實例運行后輸出結果為:a7H少兒編程網-https://www.pxcodes.com
math.exp(-45.17) : 2.41500621326e-20 math.exp(100.12) : 3.03084361407e+43 math.exp(100.72) : 5.52255713025e+43 math.exp(119L) : 4.7978133273e+51 math.exp(math.pi) : 23.1406926328相關免費學習推薦:python視頻教程a7H少兒編程網-https://www.pxcodes.com
以上就是python e怎么表示的詳細內容,更多請關注少兒編程網其它相關文章!a7H少兒編程網-https://www.pxcodes.com

- 上一篇
python如何保留小數點位數
簡介python保留小數點位數的方法:首先新建py文件,輸入【a=('%.2f'%a)】即可保留2位小數;然后如果輸入【a=('%.4f'%a)】,就保留4位小數;最后也可以輸入【a=format(a,'.2f')】來保留小數點位數。本教程操作環境:win
- 下一篇
python如何判斷字符串是否為整數
簡介python判斷字符串是否為整數的方法:首先可以根據字符串的第一個字符確定整數的正負;然后對字符串從右向左遍歷,例如111,可以看成【11*10+1】,而11又可以看成【1*10+1】。本教程操作環境:windows7系統、python3.9版,DELLG3電腦。python判斷字符串是否為整數的方