the second line here creates new attribute new_attr for the instance of myclass such addition of attributes is entirely validbut it is rarely good programming practice since we can end up with instances of the same class having different attributes it is good habit to always equip class with constructor and to primarily define attributes inside the constructor protected class attributes for more classical computer science example of python classlet us look at class representing bank account natural attributes for such class will be the name of the ownerthe account numberand the balanceand we can include methods for depositswithdrawalsand printing information about the account the code for defining such class could look like thisclass bankaccountdef __init__(selffirst_namelast_namenumberbalance)self first_name first_name self last_name last_name self number number self balance balance def deposit(selfamount)self balance +amount def withdraw(selfamount)self balance -amount def print_info(self)first self first_namelast self last_name number self numberbal self balance '{first{last}{number}balance{balance}print(stypical use of the class could be something like the followingwhere we create two different account instances and call the various methods for depositswithdrawalsand printing informationa account('john''olsson'' ' account('liz''olsson'' ' deposit( withdraw( withdraw( withdraw( print " ' balance:" balance ' balance print_info(john olsson balance print_info(