新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
Python程序:計(jì)算數(shù)字平方根
創(chuàng)新互聯(lián)Python教程:

創(chuàng)新互聯(lián)公司2013年至今,先為富民等服務(wù)建站,富民等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為富民企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問(wèn)題。
用一個(gè)例子寫(xiě)一個(gè) Python 程序,用 sqrt 和冪函數(shù)求一個(gè)數(shù)的平方根。
這個(gè)程序允許用戶輸入任何數(shù)字。接下來(lái),這個(gè) Python 平方根程序使用名為 sqrt() 的數(shù)學(xué)函數(shù)找到該數(shù)字的平方根。
# Python Program to find Square root of a Number
import math
number = float(input(" Please Enter any numeric Value : "))
squareRoot = math.sqrt(number)
print("The Square Root of a Given Number {0} = {1}".format(number, squareRoot))
Please Enter any numeric Value : 64
The Square Root of a Given Number 64.0 = 8.0
使用冪()的數(shù)字平方根
在本 Python 平方根程序中,我們使用 pow()函數(shù)來(lái)求一個(gè)數(shù)的平方根。記住,√數(shù)=數(shù)
import math
number = float(input(" Please Enter any numeric Value : "))
squareRoot = math.pow(number, 0.5)
print("The Square Root of a Given Number {0} = {1}".format(number, squareRoot)) 網(wǎng)站欄目:Python程序:計(jì)算數(shù)字平方根
標(biāo)題網(wǎng)址:http://www.dlmjj.cn/article/cojggip.html


咨詢
建站咨詢
