0
What is method pls
In this lesson they give the definition of argument they say it's value assigned to a function or a method
8 Respostas
+ 1
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
+ 1
Yes Dejan it's clear what is class now.
0
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
0
Simply said, method shows what one class does đđ
0
What is class then đ.. looks like my questions will never end I'll check by myself too for what are classes
0
https://www.hackerearth.com/fr/practice/JUMP_LINK__&&__python__&&__JUMP_LINK/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
0
Creo que lo.complicado no es la sintaxis si no las sentencias ya que al menos a mi en español me confunden