You are on page 1of 2

ICT HOME WORK Class 8

MAKE A PROGRAM IN PYTHON

 User Input name of student and 7 subjects marks


 Take an average of those marks and give result average over
 80< Good Job 68< Satisfactory and 50< Needs improvement

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).

2. Loop and Input:

- `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.

- Uses a `for` loop to iterate over the range of 7 subjects.

- 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.

- Calculates the average of the marks using the `calculate_average` function.

- Evaluates the result based on the average using the `evaluate_result` function.

- Finally, prints the average marks and the result.

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).

You might also like