Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (2015) Python for Beginners The Python Shell

Classes, object, methods?

What exactly is a class, an object, a method and def? Also what is arguments or parameters. I know the definition of these, but can someone show me them in code?

def my_function_name():          <--- Is this considered an object?
    Print("this is the functions body")     <------- is this considered a method?

What is print? An object method or class? Once again, I know the definition what can someone show me them in code so I can see them in action?

Also what do you mean when you say "not all values are variables"?

1 Answer

Be patient... I know the beginning of this course can get really confusing, but I know you are smart and eventually you'll understand :smile:

  1. print Is a built-in Python function that prints a value of any type onto the screen.
  2. A type is like the kind of value like for example the text "Hello world" is type of String, and 3 is type Int (short for integer)
  3. In Python, you can even (basically) create your own types, and these are called classes.
  4. In Python, def is short for "define". You use this key word to tell Python "Over here, I'm going to create my very own function".
  5. In Python, parameters and arguments are the values you pass in to a function. The meaning are slightly different...
  6. Arguments are the actual values passed in. Parameters are the name of the argument you use in the function definition.

Again, don't worry too much about this, you will see these all come together in close future :smile:

Got more questions I didn't catch? Feel free to ask below. :)

I hope this helps. ~Alex