What is method pls | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
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

9th Jul 2019, 8:37 PM
Tim
8 Réponses
+ 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
9th Jul 2019, 10:31 PM
Dejan Francuzūü•á
Dejan Francuzūü•á - avatar
+ 1
Yes Dejan it's clear what is class now.
9th Jul 2019, 10:35 PM
Tim
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
9th Jul 2019, 9:54 PM
Jake
Jake - avatar
0
Simply said, method shows what one class does ūüėČūüĎĆ
9th Jul 2019, 10:12 PM
Dejan Francuzūü•á
Dejan Francuzūü•á - avatar
0
What is class then ūüėŹ.. looks like my questions will never end I'll check by myself too for what are classes
9th Jul 2019, 10:28 PM
Tim
9th Jul 2019, 10:31 PM
Tim
11th Jul 2019, 10:32 AM
Tim
0
Creo que lo.complicado no es la sintaxis si no las sentencias ya que al menos a mi en espa√Īol me confunden
6th Nov 2019, 3:09 PM
Arland Curi
Arland Curi - avatar