输入学生的语文,数学,英语和物理四门课程的成绩,计算该学生的总成绩和平均成绩并输出。
时间: 2023-05-20 15:01:24 浏览: 104
好的,以下是计算学生总成绩和平均成绩的代码:
```python
chinese = float(input("请输入学生的语文成绩:"))
math = float(input("请输入学生的数学成绩:"))
english = float(input("请输入学生的英语成绩:"))
physics = float(input("请输入学生的物理成绩:"))
total_score = chinese + math + english + physics
average_score = total_score / 4
print("学生的总成绩为:", total_score)
print("学生的平均成绩为:", average_score)
```
请注意,这段代码只是一个简单的示例,实际应用中可能需要更复杂的计算和处理。
相关问题
输入学生的语文数学英语物理四门课程的成绩,计算
总分和平均分,可以给出以下代码示例:
```python
def calculate_score(chinese, math, english, physics):
total_score = chinese + math + english + physics
average_score = total_score / 4
return total_score, average_score
```
使用示例:
```python
chinese_score = 90
math_score = 85
english_score = 95
physics_score = 80
total_score, average_score = calculate_score(chinese_score, math_score, english_score, physics_score)
print("总分为:", total_score)
print("平均分为:", average_score)
```
输出结果:
```
总分为: 350
平均分为: 87.5
```
写程序输入一个学生的语文数学英语物理成绩计算并输出该学生的总成绩和平均成绩
score_chinese = float(input("请输入学生的语文成绩:"))
score_math = float(input("请输入学生的数学成绩:"))
score_english = float(input("请输入学生的英语成绩:"))
score_physics = float(input("请输入学生的物理成绩:"))
total_score = score_chinese + score_math + score_english + score_physics
average_score = total_score / 4
print("该学生的总成绩为:", total_score)
print("该学生的平均成绩为:", average_score)