0% found this document useful (0 votes)
19 views3 pages

Program 10

The document outlines a Python program that defines a Student class to manage student details, including name, USN, and marks for three subjects. It includes methods for initializing attributes, getting marks from user input, calculating total marks and percentage, and displaying a score card. The program ultimately prompts the user for input and outputs the student's details along with their calculated scores.

Uploaded by

Nomita Chawla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views3 pages

Program 10

The document outlines a Python program that defines a Student class to manage student details, including name, USN, and marks for three subjects. It includes methods for initializing attributes, getting marks from user input, calculating total marks and percentage, and displaying a score card. The program ultimately prompts the user for input and outputs the student's details along with their calculated scores.

Uploaded by

Nomita Chawla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Introduction to Python Programming

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

Prof. Nomitha Chawla - BIET


Introduction to Python Programming

OUTPUT 1

OUTPUT 2

Prof. Nomitha Chawla - BIET


Introduction to Python Programming

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.

Prof. Nomitha Chawla - BIET

You might also like