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 ▸

Write a program that computes the sum of all numbers up to a input number n


Explain why creating a list of several instances of one element using something like my_list = [a] * 5 can result in strange behaviour


Ask the user for a number and output the smallest divisor, bigger than one, for the inputted number. Output "Prime" if the number is a prime number.


What can be used to iterate through a list in python?