Object Oriented Programming with Python

External Resources

Common Questions

Q1: Is self a local variable?

A: Yes, self is a local variable we use inside a constructor.

Q2: Does Python have reserved words?

A: Yes. Some of them are reserved words for example - class, is etc. Some words are semi-reserved i.e. they have a meaning but they can be reassigned for example - type etc.

Q3: Why are we passing lists of data when creating pandas dataframe class? Can it support other datatypes?

A: We want to replicate the simplest way to create a pandas dataframe and the simplest way is by using a dictionary of lists. You can try out other datatypes as well.

Q4: While defining a method in a class if we forget to put self as the argument, will Python create it automatically?

A: No. You have to put it or else you will run into issues.

Q5: Is df.method('column') same as DataFrame.method(df,'column') ?

A: Yes, they are same. Try it out.

Q6: Is innit the first function to create in a class?

A: Yes, innit is evaluated first in a class so it is the first function we create in a class.

Q7: What is the difference between class and variable?

A: Class does not have any data in it. It simply contains instructions for creating an object which will have data inside it. Variable has data in it.

Q8: Is there a similarity between recursive function and a generator? Are they completely different?

A: No. Recursive function and a generator are completely different.

Q9: Can we modify a class for project purpose?

A: Yes but you don't modify the existing class, you extend it using inheritance.

Q10: Is read_csv in Pandas using class method?

A: No. In Pandas, read_csv is a function.