132k views
3 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 Raginggoat
by
8.1k points

1 Answer

1 vote

Final answer:

The Python script provided asks for the grades of three students as input, calculates the average, assigns it to 'grades_average', and then prints this average grade.

Step-by-step explanation:

To calculate the average of the grades for three students using Python, you need a script that takes input for the student grades, computes the average, and then prints it. You can accomplish this by using the input() function to collect the grades and then calculating the average.

Example Python Script:

# Input grades from the teacher
grade_A = float(input('Enter grade for Student A: '))
grade_B = float(input('Enter grade for Student B: '))
grade_C = float(input('Enter grade for Student C: '))

# Calculate the average
grades_average = (grade_A + grade_B + grade_C) / 3

# Print the average
print('The average grade is:', grades_average)

This script defines a variable called grades_average that contains the calculated average grade. It ensures that the grades entered are treated as floating point numbers, which allows for decimal grades, and it prints out the average for the teacher to see.

User Valentin Simonov
by
8.2k points