2013-10-03 31 views
1

Class Grade List - PYTHON我们想要一个能够让我们打印同级学生的“成绩单”的程序

我真的不知道从哪里开始。我意识到这是基本的,但如果有人可以通过这个步骤,我将不胜感激。

我们希望有一个课程能让我们在课堂上打印出学生的“成绩单”。 程序应循环,要求提供名称,中期分数和最终分数。然后它应该回应输入,并打印输入的信息以及学生的平均水平。 要退出循环,用户输入小写的“完成”。该程序将打印班级平均值,然后终止。

+1

首先创建一个名为gradebook的类,一个名为student(具有名称,期中和最终分数作为属性)的类,并将函数放入您的班级成绩册中,并使用raw_input获取每个学生的信息。当你尝试过的代码被卡住时。 –

回答

3

首先将一部分描述一次转换为Python。

while True: 
    ask for a name, midterm score, and final score 
    echo the input 
    print the information entered, plus the student's average 
    to exit the loop, the user enters "done" in lower case 
print the class average and terminate 

然后:

while True: 
    name = input('Name') 
    if name == 'done': 
     break 
    midterm = input('Midterm score') 
    final = input('Final score') 
    average = the student's average 
    print('Name', name, 
      'Midterm score', midterm, 'Final score', final, 'Average', average) 
class_average = ??? 
print('Class average', class_average) 

计算学生的平均水平是很容易 - 你必须要midtermfinal转换为数字,然后平均这些数字。

计算班级平均值是棘手的。但是,如果你可以将每个分数附加到某种你可以稍后总结的集合 - 或者找出需要跟踪而不需要整个集合的更小的一组数字 - 这并不难。

相关问题