新聞中心
創(chuàng)新互聯(lián)Python教程:

成都創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括雨湖網(wǎng)站建設(shè)、雨湖網(wǎng)站制作、雨湖網(wǎng)頁(yè)制作以及雨湖網(wǎng)絡(luò)營(yíng)銷策劃等。多年來(lái),我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,雨湖網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到雨湖省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
寫一個(gè) Python 程序,用算術(shù)運(yùn)算符和函數(shù)計(jì)算一個(gè)數(shù)的平方,并舉例說(shuō)明。
計(jì)算數(shù)字平方的 Python 程序
這個(gè) Python 程序允許用戶輸入任何數(shù)值。接下來(lái),Python 使用算術(shù)運(yùn)算符 找到該數(shù)字的平方
# Python Program to Calculate Square of a Number
number = float(input(" Please Enter any numeric Value : "))
square = number * number
print("The Square of a Given Number {0} = {1}".format(number, square))數(shù)字輸出的 Python 平方
Please Enter any numeric Value : 9
The Square of a Given Number 9.0 = 81.0
Python 程序求一個(gè)數(shù)的平方示例 2
這個(gè) Python 平方的一個(gè)數(shù)字例子同上。但是,這次我們使用的是指數(shù)算子。
number = float(input(" Please Enter any numeric Value : "))
square = number ** 2
print("The Square of a Given Number {0} = {1}".format(number, square))
Please Enter any numeric Value : 10
The Square of a Given Number 10.0 = 100.0
用函數(shù)求一個(gè)數(shù)的平方的 Python 程序
在這個(gè) Python 程序的例子中,我們定義了一個(gè)函數(shù),它返回一個(gè)數(shù)字的平方。
def square(num):
return num * num
number = float(input(" Please Enter any numeric Value : "))
sqre = square(number)
print("The Square of a Given Number {0} = {1}".format(number, sqre)) 當(dāng)前標(biāo)題:Python程序:計(jì)算數(shù)字平方
網(wǎng)頁(yè)網(wǎng)址:http://m.fisionsoft.com.cn/article/cdccgds.html


咨詢
建站咨詢
