I’m super confused here, as I don’t recall any lessons discussing functions (yet). The concept of the latter is explained in module 5.
The only time I came across functions was with first lesson of module Lists (which is module no. 3) - and even that wasn’t in lesson itself, but in Community forum section, where I found this thread
I also looked in the cheatheets of module I’m stuck in and there is nothing about functions. But functions cheatsheets are of little value to me as I’m not familiar with the concept.
Is this supposed to be that way?
I’m aware that one should not try to memorize everything, instead one should be familiar with finding solutions either by looking in cheatsheets or googling. It just seems odd to just jump between modules.
It might be that this portion was part of a challenge in a previous version of the course & it got moved around w/o any editing. (to my memory it was part of the functions portion, but I could be wrong).
This challenge for writing this function is that it does contain control flow. (I wasn’t clear if you had already looked up python functions or not, so, if this is repetitive, I’m sorry.)
A function is just a shortcut of sorts; a reusable piece of code that has parameters (placeholder variables)–where you call the function and pass arguments through it. The function has logic contained in it and is applied to the arguments.
So, when you come across questions like this that you’re not really sure of, break it down into more digestible bits (and do what you’ve already done, google, consult docs).
1.) define the function with one parameter. Every function you write will have the same general format: def insert_function_name(parameter(s)):
Ex: def divisible_by_ten(num):
2.) function should return True if num is divisible by 10, and return False otherwise.
3.) see the given code with the print() statements. You’re able to call the function and pass through any argument–divisible_by_ten(20) & divisible_by_ten(25). (You should be able to pass through any number.)
So, how would you write that logic utilizing control flow? (Hint: note the italics of return. And remember that indentation matters in Python too.)