寫一個 Python 程序,通過一個例子找到五個科目的總平均值和百分比。
Python 程序查找五個科目的總平均值和百分比示例
這個 python 程序允許用戶為五個科目輸入五個不同的分數。接下來, Python 找到這五個主體的總數、平均值和百分比。對於這個 python 程序,我們使用算術運算符來執行算術運算。
# 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)
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/285821.html