Which function is ran when an object is instantiated?

The function is called init. This is the constructor, which is used to initiate the attributes of the object and allows arguments to be passed upon instantiation.

KC

Related Python Mentoring answers

All answers ▸

Given a list of N numbers, use a single list comprehension to produce a new list that only contains those values that are: (a) even numbers, and (b) from elements in the original list that had even indices .


What is the difference between a cycle "if" and "while"?


Write a python function that takes a string as parameter and returns the character in the string with the most occurrences, along with the number of times this character occurs


What's the difference between a local and a global variable?