Write a python program to demonstrate object as argument

In this source code example, we will write a python program to demonstrate an object as argument.

Write a python program to demonstrate the object as an argument

class Student:

  # object as argument - 1
  def student_details(self,obj):
    print("Name:", obj.name)
    print("Age:", obj.age)

class StudentDetail:
  def __init__(self, name, age):
    self.name = name
    self.age = age

  def printStudentDetails(self):
    print('Student details')
    print("Name:", self.name)
    print("Age:", self.age)
    s1 = Student()

sd = StudentDetail('Ram', 21)


Student details
Name: Ram
Age: 21
Name: Ram
Age: 21

Free Spring Boot Tutorial - 5 Hours Full Course

Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course