8 AnswersNew Answer
Class is a description of an object. So very simple: Object is a "thing" in memory that has state and behaviour. For example an object is a light bulb that has state to produce light or not and methods turn on and turn off 😉👌 I think it's more than clear now
Yes Dejan it's clear what is class now.
A method is a sub-routine that is internal to a class. It performs an action, they’re very useful for cleaning up your code, but more importantly they allow you to use a single block of code numerous times without having to re-type the code multiple times, especially if you need to execute that block of code with different values. Passing an argument into a method or functions parameter allows you to pass data into it so it can perform an action based on the value you pass through. For example: the print() function in python: The paranthesis are the parameters, and the result is dependent on the argument you pass into the parameters, so if you type print(‘hello’) the result would be a console output of “hello” where as if you passed in print(‘spam’) the result would be “spam” now for example say we declare a method named add_one and we assign an argument named ‘num’, so it will look like this: add_one(num) and now we give it some code, we want it to add one to whatever number we pass into the argument: def add_one(num): return num+1 “num” is the variable assigned to the method, it is a essentially a placeholder, any number we pass into the argument will take the place of “num” So now we can use this method throughout our entire class with any given number we so desire: x = add_one(5) y = add_one(x) result: x = (5+1) = 6 y = (6+1) = 7
Simply said, method shows what one class does 😉👌
What is class then 😏.. looks like my questions will never end I'll check by myself too for what are classes
https://www.hackerearth.com/fr/practice/python/object-oriented-programming/classes-and-objects-i/tutorial/ looks good... so class is like a snake then? I mean a name given to a variable
Creo que lo.complicado no es la sintaxis si no las sentencias ya que al menos a mi en español me confunden