which class gets declared automatically in the middle of the of the expression automatically and can be public , private in python code example

Example 1: class in python

class ComplexNumber:
    def __init__(self, r=0, i=0):
        self.real = r
        self.imag = i

    def get_data(self):
        print(f'{self.real}+{self.imag}j')


# Create a new ComplexNumber object
num1 = ComplexNumber(2, 3)

# Call get_data() method
# Output: 2+3j
num1.get_data()

# Create another ComplexNumber object
# and create a new attribute 'attr'
num2 = ComplexNumber(5)
num2.attr = 10

# Output: (5, 0, 10)
print((num2.real, num2.imag, num2.attr))

# but c1 object doesn't have attribute 'attr'
# AttributeError: 'ComplexNumber' object has no attribute 'attr'
print(num1.attr)

Example 2: how to write a class with inputs in python

class Person:
     """
     A representation of a person 
     Attributes:
         Firstname(string)
         Lastname(String)
     """
     def __init__(self, firstname, lastname):
         self.firstname = firstname
         self.lastname = lastname

     def show_full_name(self):
         return self.firstname + ' ' + self.lastname

     @classmethod
     def get_user_input(self):
         while 1:
             try:
                 firstname = input('Enter first name: ')
                 lastname = input('Enter last name')
                 return self(firstname,lastname)
             except:
                 print('Invalid input!')
                 continue

#creating a person object and returning their full name
person3 = Person.get_user_input()
person3.show_full_name()