So confuzzled


#1



what does the instructions for 2:6 mean?

First, def a function called cube that takes an argument called number. Don't forget the parentheses and the colon!
Make that function return the cube of that number (i.e. that number multiplied by itself and multiplied by itself once again).
Define a second function called by_three that takes an argument called number.
if that number is divisible by 3, by_three should call cube(number) and return its result. Otherwise, by_three should return False.

Don't forget that if and else statements need a : at the end of that line!


Replace this line with your code.


#2

You've to define two functions.

1.First that takes a number then returns cube of it.

2.Second function that takes a number and tests

Part A.
if it is divisible by 3,
If the number is divisible by three then it will return cube of number
but we don't use number ** 3 but we will use the First function to accomplish this task.

Part B.
If number is not divisible by 3 then it will return False.


#3

what do they mean by calling out cube(number)?


#4

Functions--
Functions are like reusable ideas , like a Swiss Army knife that is used to solve many problems of same nature
1. Function can solve so many problems of same nature
2. Function makes your code more well structured
3. It lessens programming bugs
4. neat and clean code.

Lets understand what I meant by that...

lets see we made a small function that takes a number and checks if number is zero or non zero.

def checkZero(x):
    if x == 0:
        return "Number is zero"
    return "Number is not  zero"

Now why I called function a Swiss Army knife?
Because this special function can work for any number..

To use Functions we need to CALL them with arguments they need.

checkZero(9)  # It will return  "Number is not  zero"
checkZero(0)  # It will return  "Number is  zero"
checkZero(19)  # It will return  "Number is not  zero"
checkZero(12 % 3)  # It will return  "Number is  zero"

So your function can be used for many numbers!

I hope it helps you! :slight_smile:


#5

it really helped! thanks!


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.