Professional Documents
Culture Documents
def calculate_average(marks):
return sum(marks) / len(marks)
def evaluate_result(average):
if average > 80:
return "Good Job"
elif average > 68:
return "Satisfactory"
elif average > 50:
return "Needs Improvement"
else:
return "Below Average"
def main():
student_name = input("Enter student's name: ")
subjects = []
for i in range(7):
subject_mark = float(input(f"Enter marks for subject {i + 1}: "))
subjects.append(subject_mark)
average_marks = calculate_average(subjects)
result = evaluate_result(average_marks)
print(f"\nAverage Marks: {average_marks}")
print(f"Result: {result}")
if __name__ == "__main__":
main()
What was used in the program
1. Functions:
- `calculate_average(marks)`: This function takes a list of marks as input and returns the average of
those marks.
- `evaluate_result(average)`: This function takes the average marks as input and returns a result based
on the specified criteria (Good Job, Satisfactory, Needs Improvement, or Below Average).
- `main()`: This is the main function where the program starts. It does the following:
- Asks the user to input the student's name using `input("Enter student's name: ")`.
- Initializes an empty list `subjects` to store the marks for each subject.
- Inside the loop, it asks the user to input marks for each subject using `float(input(f"Enter marks for
subject {i + 1}: "))` and appends the mark to the `subjects` list.
- Evaluates the result based on the average using the `evaluate_result` function.
3. Execution:
- `if __name__ == "__main__":`: This line ensures that the `main()` function is executed only when the
script is run directly (not imported as a module).