首页 > 编程知识 正文

Python 程序:计算五个科目的总平均值和百分比

时间:2023-11-24 15:33:38 阅读:308819 作者:YFRY

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

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。