Control flow - Practice module

Hello all,

I’m doing Python 3 course and I’m stuck in Control flow’s practice module (which is module no. 2).

In this exercise I need to create a function that should return either a True or False value.

This is the link to the exercise

I’m not sure the link to the exercise will lead to where its supposed to, so here is print screen:

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.

Please advise.

1 Like

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). :woman_shrugging:

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.)

Write some code and test it out.

Docs:

and,

1 Like

omg i had the same problem and I got upset because we haven’t learned functions in control flow but I was still confused thought I should’ve known how to solve that, glad wasn’t the problem on our end :smile:

1 Like