写一个 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)