This is my first repository on GitHub. 🎉
It includes a simple example of a Python class named Student
that stores and displays student information.
- Defines a
Student
class with attributes:name
age
grade
- Uses a
display_info()
method to neatly return the student's information. - Creates an instance of
Student
and prints the info.
class Student:
def __init__(self, name, age, grade):
self.name = name
self.age = age
self.grade = grade
def display_info(self):
return f"Name: {self.name} \nAge: {self.age}\nGrade: {self.grade}"
s1 = Student("hassan", 12, "d")
print(s1.display_info())
Name: hassan
Age: 12
Grade: d
📁 How to Run
- Make sure Python is installed on your system.
2.Copy the code into a file named student.py.
- Run the file in your terminal or command prompt:1
python main.py