FAQ: Learn Python: Classes - Methods with Arguments

This community-built FAQ covers the “Methods with Arguments” exercise from the lesson “Learn Python: Classes”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science

FAQs on the exercise Methods with Arguments

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

6 posts were merged into an existing topic: What is the difference between calling a variable with self or the ClassName?

A post was split to a new topic: When are classes defined with parenthesis?

3 posts were split to a new topic: What is the difference between calling a variable with self or the ClassName?

Two questions here:

  1. Can a class be thought of as a library and the method as the portion of the module you wish to import?

  2. Is it best practice to save the class in a variable like class = Class() before calling methods or is it a matter of preference as the two scripts below yield the same answer.

circle = Circle()
pizza_area = circle.area(6)


pizza_area = Circle().area(6)

Hi, I have a question regarding variables in a class.

In this exercise there was the following code:

class Circle():
def area(self, radius):
return Circle().pi*radius**2

Why can’t you call pi straight away. It’s a variable that has already been defined within the scope of the class. At least, that is what I assumed. Why do you need to call the variable with self or ClassName?