新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Python 程序:計算兩個數(shù)平均值
創(chuàng)新互聯(lián)python教程:

成都創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),德城企業(yè)網(wǎng)站建設(shè),德城品牌網(wǎng)站建設(shè),網(wǎng)站定制,德城網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,德城網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強企業(yè)競爭力。可充分滿足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學(xué)習、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實用型網(wǎng)站。
寫一個 Python 程序,求兩個數(shù)的平均值。這個 Python 示例接受兩個整數(shù),并計算總和和平均值。
x = int(input("Please Enter the First Number = "))
y = int(input("Please Enter the Second number = "))
sumOfTwo = x + y
avgOfTwo = sumOfTwo / 2
flooravgofTwo = sumOfTwo // 2
print('The sum of {0} and {1} = {2}'.format(x, y, sumOfTwo))
print('The Average of {0} and {1} = {2}'.format(x, y, avgOfTwo))
print('Floor Average of {0} and {1} = {2}'.format(x, y, flooravgofTwo))Python 程序求兩個浮點數(shù)的平均值。
x = float(input("Please Enter the First Number = "))
y = float(input("Please Enter the Second number = "))
sumOfTwo = x + y
avgOfTwo = sumOfTwo / 2
flooravgofTwo = sumOfTwo // 2
print('The sum of {0} and {1} = {2}'.format(x, y, sumOfTwo))
print('The Average of {0} and {1} = {2}'.format(x, y, avgOfTwo))
print('Floor Average of {0} and {1} = {2}'.format(x, y, flooravgofTwo))Please Enter the First Number = 22.9
Please Enter the Second number = 14.7
The sum of 22.9 and 14.7 = 37.599999999999994
The Average of 22.9 and 14.7 = 18.799999999999997
Floor Average of 22.9 and 14.7 = 18.0 網(wǎng)頁標題:Python 程序:計算兩個數(shù)平均值
瀏覽路徑:http://m.5511xx.com/article/copgedg.html


咨詢
建站咨詢
