新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
Python程序:計(jì)算五個(gè)科目的總平均值和百分比
創(chuàng)新互聯(lián)python教程:

寫一個(gè) Python 程序,通過(guò)一個(gè)例子找到五個(gè)科目的總平均值和百分比。
Python 程序查找五個(gè)科目的總平均值和百分比示例
這個(gè) python 程序允許用戶為五個(gè)科目輸入五個(gè)不同的分?jǐn)?shù)。接下來(lái), Python 找到這五個(gè)主體的總數(shù)、平均值和百分比。對(duì)于這個(gè) python 程序,我們使用算術(shù)運(yùn)算符來(lái)執(zhí)行算術(shù)運(yùn)算。
# Python Program to find Total, Average, and Percentage of Five Subjects
english = float(input("Please enter English Marks: "))
math = float(input("Please enter Math score: "))
computers = float(input("Please enter Computer Marks: "))
physics = float(input("Please enter Physics Marks: "))
chemistry = float(input("Please enter Chemistry Marks: "))
total = english + math + computers + physics + chemistry
average = total / 5
percentage = (total / 500) * 100
print("\nTotal Marks = %.2f" %total)
print("Average Marks = %.2f" %average)
print("Marks Percentage = %.2f" %percentage) 文章題目:Python程序:計(jì)算五個(gè)科目的總平均值和百分比
鏈接地址:http://www.dlmjj.cn/article/dhhsopd.html


咨詢
建站咨詢
