So onto functions.
The ‘print’ function is the first that we learned. It shows the output of the work we did.
There are 60+ different functions in general Python. Not even counting the 3rd party libraries. We’re gonna build our way up to those.
So past ‘print’, we have the ‘len’ function that returns you the length of an element.
When I say ‘returns you’ that means it’s the information it’s giving you in response to your function. Using the function is ‘calling’ for it.
x = len("word")
print(x)
Output: 4
So if I put the ‘len’ function in front of a string with a 4-letter word, it’ll return in the output, 4.
If you’re doing multiple words, it counts those spaces too. So ‘hello world’ would return you 11. They’re both 5-letter words, but there’s a space in between.
We also have the ‘min‘ function, which returns the smallest value of an element.
print(min(34, 57))
Output: 34
It’s obvious for numbers, but it works with words too. It does it alphabetically
print(min("apple", "bear"))
Output: apple
And even though I just called them elements, the values inside of these elements, letters and numbers, are called ‘arguments‘. Any time you use a comma to separate a value, that’s another argument you’re adding.