20.8k views
0 votes
There are 3 students in a class. Teacher wants to see average of the grades of the students. Grades of students are; Student A=83 Student B=97 Student C=90 Take grades as a variable from teacher with the input function and calculate average. Define new variable called grades_average and assign average grade to grades_average then print it. Please write Python Script for this scenario.

User Sinelaw
by
8.6k points

1 Answer

1 vote

Final answer:

To calculate the average grade of three students using Python, collect grades with the input function, sum them, divide by three to find the average, and print the result.

Step-by-step explanation:

To calculate the average of grades for three students using Python, we can take input from the teacher for each student's grade, sum these grades, and then divide by the number of students to get the average. Here's a sample Python script that accomplishes this:

student_a = int(input('Enter grade for Student A: '))
student_b = int(input('Enter grade for Student B: '))
student_c = int(input('Enter grade for Student C: '))

grades_sum = student_a + student_b + student_c
grades_average = grades_sum / 3

print('The average grade is:', grades_average)

This code uses the input function to collect grades and calculates the grades_average which is then printed out.

User OldUgly
by
8.2k points