Help with Python Program: Calculate Student Grades & Averages

Click For Summary
SUMMARY

The discussion focuses on a Python program designed to calculate student grades and averages. The program requires user input for student names and grades, ensuring grades do not exceed 10, and continues until a zero is entered. Key features include listing students alphabetically and displaying each student's grades and average. The user seeks assistance with syntax errors and program structure, particularly in implementing loops and class definitions.

PREREQUISITES
  • Understanding of Python classes and object-oriented programming
  • Familiarity with Python input handling and loops
  • Knowledge of Python syntax and error handling
  • Basic concepts of calculating averages in programming
NEXT STEPS
  • Learn about Python class constructors and the __init__ method
  • Research Python loops, particularly while loops and break statements
  • Study error handling in Python to troubleshoot syntax errors
  • Explore how to format strings in Python using the format() method
USEFUL FOR

This discussion is beneficial for beginner to intermediate Python programmers, students learning object-oriented programming, and anyone needing to implement user input and data processing in Python.

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.
 

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
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 15 ·
Replies
15
Views
2K