across many filessplit into individual stepsand so on in prototype like thisfrequent change is almost guaranteed coding methods what we really want to do here is employ software design concept known as encapsulation--wrapping up operation logic behind interfacessuch that each operation is coded only once in our program that wayif our needs change in the futurethere is just one copy to update moreoverwe're free to change the single copy' internals almost arbitrarilywithout breaking the code that uses it in python termswe want to code operations on objects in class' methodsinstead of littering them throughout our program in factthis is one of the things that classes are very good at--factoring code to remove redundancy and thus optimize maintainability as an added bonusturning operations into methods enables them to be applied to any instance of the classnot just those that they've been hardcoded to process this is all simpler in code than it may sound in theory the following achieves encapsulation by moving the two operations from code outside the class to methods inside the class while we're at itlet' change our self-test code at the bottom to use the new methods we're creatinginstead of hardcoding operationsadd methods to encapsulate operations for maintainability class persondef __init__(selfnamejob=nonepay= )self name name self job job self pay pay def lastname(self)return self name split()[- def giveraise(selfpercent)self pay int(self pay ( percent)behavior methods self is implied subject must change here only if __name__ ='__main__'bob person('bob smith'sue person('sue jones'job='dev'pay= print(bob namebob payprint(sue namesue payprint(bob lastname()sue lastname()use the new methods sue giveraise instead of hardcoding print(sue payas we've learnedmethods are simply normal functions that are attached to classes and designed to process instances of those classes the instance is the subject of the method call and is passed to the method' self argument automatically the transformation to the methods in this version is straightforward the new last name methodfor examplesimply does to self what the previous version hardcoded more realistic example