Here is Python Program Displays Student Details

Here is a python program that prints student details. The student details are first name, last name, student id. The tricky of this program is it uses the class.

Python Class

Python supports object-oriented programming. So you can write classes in python fearlessly. But the point to recollect is supply of self argument (that is mandatory; says current object).

What you’ll see in this post

  1. Sample Python program: It tells how to write class to display student details.
  2. Execution of the program: you’ll see the output of the program.

“Your “I CAN” is more important than your IQ.”

― Robin Sharma, The Monk Who Sold His Ferrari

Sample Python program

python script to display student details using class

Here I’ve defined two methods. Those are init and str. And I have supplied self as argument. At line number4, here defined init, at line number8 defined str.

Both are internal methods. In the init method, I did initilization. In the str mthod, I used inilized varibale to concatenate the string.


  1. Let us say, by mistake you typed init method/str method name incorrrectly, then you’ll get Type error
  2. The supplied self argument in the str method helps to get initilized variables
  3. By default in all the methods you need to supply self argument

“The ability to observe without evaluating is the highest form of intelligence.”

― J. Krishnamurti, Author of Freedom from the known

Execution of the program

Output of python script. Here you'll get student details displayed.

So in the result, you can see concatented student details. This is useful for your project ansd interviews.

Related posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.