Not all functions need parameters though. The function:
f(x) = 2
does not even use the provided x! So just leave it out:
f() = 2
Similarly, you could give a function two parameters:
f(x, y) = x + y
Programmers use functions to primarily organize their code. Otherwise it would get very unreadable very quickly. Those function are usually a bit more complicated than a single line, though.
dog.walk() would call the walk() function of “dog”. Some valid code could be:
dog.walk()
wait(10)
dog.stop()
This code would make the dog walk for 10 seconds assuming every function used is actually defined somewhere.
Python is not a descriptive language, it’s a commands based language.
Go do functional programming if you want to describe instead of command.
Transpiling python and describing stuff when actually you are commanding is overly backwards and stupid, but I’d not expect anything else from a 4chan post. XD
to me method names are imperatives, like when we order the dog to walk.
dog.walk() = “Dog, walk!”
I don’t python, but I know there’s tons of ()
why is there so much () and other empty brackets?
It’s calling a function without a parameter.
You know how in math you had something like:
f(x) = x²
Not all functions need parameters though. The function:
f(x) = 2
does not even use the provided x! So just leave it out:
f() = 2
Similarly, you could give a function two parameters:
f(x, y) = x + y
Programmers use functions to primarily organize their code. Otherwise it would get very unreadable very quickly. Those function are usually a bit more complicated than a single line, though.
dog.walk() would call the walk() function of “dog”. Some valid code could be:
dog.walk() wait(10) dog.stop()This code would make the dog walk for 10 seconds assuming every function used is actually defined somewhere.
i know that’s how you’re supposed to read it…and guess what…it’s wrong
How do you tell a dog to walk? “Dog, walks!” or “Dog, walk!”
i’m not telling the dog to walk, i’m describing it walking
Python is an imperative language.
which was a mistake
But the dog can fail to walk before he ever walked, so you’re not describing him walking, you’re telling him to start walking.
Python is not a descriptive language, it’s a commands based language.
Go do functional programming if you want to describe instead of command.
Transpiling python and describing stuff when actually you are commanding is overly backwards and stupid, but I’d not expect anything else from a 4chan post. XD
Elaborate?