Python Help with Python Program: Calculate Student Grades & Averages

Click For Summary
The discussion revolves around a student seeking assistance with a Python program required for an assignment due soon. The program's objective is to collect student names and grades, ensuring grades do not exceed 10, and to calculate and display the average grade for each student. The program should continue to prompt for names and grades until a '0' is entered to terminate the input process. The user is struggling with syntax errors and the overall structure of the program, particularly in implementing loops and handling input correctly. Initial code attempts include a class definition for students and a method to start the algorithm, but issues with syntax and logic are causing frustration. The user is open to hints or suggestions to resolve these problems and complete the assignment on time.
acurate
Messages
17
Reaction score
1
I really need help with a big Python program. Our professor has been MIA for the whole term and now we need to submit a program. I thought I was doing and learning fine on my own, but the program simply does not work for me.

I need it till Thursday and I am ripping my hair out because I cannot afford getting a bad grade on this work.

The program is

Using the input function, the program asks to enter a student's name, then a grade (there has to be a few grades because you will need to count the average of every student). The program asks the person to keep on entering the grade until the grade is entered correctly (that means the grade cannot go higher than 10). When the name and number is entered correctly, the program asks to enter a new name and grade. The cycle is broken off when a 0 is entered.

The grades are listed by the name (from A - Z).

At the end of the program there has to be this information written about every student (name):

Name, his grades and the average of his given grades.

There has to be #comments made in the program to explain what you did.


Thank you for anyone that can help! I'm in a crisis.

Here's how I think it should start but I am not sure, even hints or SUGGESTIONS will be fine.

Code:
class Student(object):
    def__init__(self, name, grades, average):
        self.grade = grade
        self.average = average

        def __str__(self)
        return "Name {0}, Grade {1}, Average {3}".format (self.name, self.grade, self.average)def startalgorithm():
    student = []
    While True:
        student = input("Insert your name:" )
        if student[0] == "1": #i don't really know how to break a cycle off without having to write every number separately
            break

This is the part where I'm stuck at since I do not know if I am going on this the right way and I keep getting messages of invalid syntax, any hints?
 
Last edited:
Technology news on Phys.org
You'll have to give more information about what loops you're using and what the error messages are, and then we can nudge you in the right direction.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 18 ·
Replies
18
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 15 ·
Replies
15
Views
2K