LEARNING PYTHON RESERVED init METHOD!!
class Student:
def __init__(self,first,last,major):
self.first=first
self.last=last
self.major=major
self.email= first + '.'+ last + '@'+ 'university.edu'
stud= Student("Leo","Umesh","Computer")
print(stud.email)
The output of the above program is as follows:
When you create the first instance of the class i.e. the object, the init method is called and the parameter self is set to the object value.
Run this python code online here
Thanks for sharing your creative and inspirational post!
This post got curated by our fellow curator @tibfox and you received a 100% upvote from our non-profit curation service!
Join the official DIYHub community on steem and show us more of your amazing work!