Program 10
Program 10
10. Develop a program that uses class Student which prompts the user to enter marks in
three subjects and calculates total marks, percentage and displays the score card details.
[Hint: Use list to store the marks in three subjects and total marks. Use init () method to
initialize name, USN and the lists to store marks and total, Use getMarks() method to
read marks into the list, and display() method to display the score card details.]
#Student.py
OUTPUT 1
OUTPUT 2
BRIEF EXPLANATION
• Class Definition: The program defines a class called Student, which will store details
about a student.
• Attributes:
o name: Student's name.
o usn: Unique student number.
o marks: A list to store marks for 3 subjects.
o total: Total marks of the 3 subjects.
o percentage: Percentage of the total marks (out of 300).
• Methods:
o __init__(self, name, usn): Initializes the student's name, USN, marks list, total,
and percentage.
o getMarks(self): Prompts the user to enter marks for 3 subjects and stores them
in the marks list.
o calculate(self): Computes the total marks by adding the 3 subject marks and
calculates the percentage using the formula:
percentage=(total/300) ×100
o display(self): Prints the student's details (name, USN, marks, total, and
percentage).
• User Input:
o The program asks for the student’s name, USN, and marks for 3 subjects.
• Calculation:
o Total marks are calculated as the sum of the marks in the 3 subjects.
o The percentage is calculated based on the total marks out of 300.
• Output:
o After the calculations, the program displays a "Score Card" showing the
student’s name, USN, marks in the 3 subjects, total marks, and percentage.