Practice makes perfect--PLEASE HELP thanks


#1


Please help me. Thank you.


#2

Hi!

I don't know what your aim is... Do you mind explaining that or giving a link to the exercise?

To fix the current issue, here you go:

def cube(n):
  return n**3
def by_three(n):
  if n%3 == 0:
    return cube(n)
  else:
    return False
print by_three(9)

OUTPUT:

729

You will notice I place your intended n value in the parenthesis while calling the by_three function, which is the right way to do it.


#3

his way is the right way too :grin:
doesnt matter if you pass a literal or a variable as argument

@cloudpro63665:
it seems you run into a glitch, try to reload the webpage
your code is absolutly correct


#4

Hi!

It would be great you first read my whole comment and not jump in...

and

Well well well, have the stage.

Thank you! :slight_smile: :slight_smile:


#5

Thank you very much! I fixed it :slight_smile:


#7

Hello there!

One question, why do you need to write the argument:
if n%3 == 0
instead of:
if n%3

Thanks!


#8

Sorry this is coming late.

We need to have it as if n % 3 == 0: because we are trying to confirm that the value of n when divided by 3, will give no remainder; meaning that it is exactly divisible by 3. Writing it as if n % 3: will return an error because this in itself is no condition.

== is used for value comparison.
=== is used for both value and data-type comparison.

I hope this helps! :slight_smile:


#9

Worked truly awesome. Nice work!


#10

Yeah!

You're welcome. Have fun coding. :smile:


#11

Quick question, why does blood taste like metal (Coins).


#12

And what does an apple taste like?


#13

Haha... I honestly haven't given that a thought. :wink:


#14

:smiley: :smiley: :smiley:


#15

Lol we've got a lot of iron in our red cells, that bind with hemoglobin.


#16

How do you know to set the value n to 9? Or can you just pick any number that is equally divisible by 3?


#17

Hehe I knew that. I was just asking questions, like "What's the color of GREEN"


#18

Chlorophyll, quite often. But sorry - we've drifted off-topic, counter to the guidelines, unless we do this ...

green = 0x00ff00 # hexadecimal for green
print by_three(green)

Output ...

278189309952000

Evidently, green is divisible by 3, and therefore it got cubed. :smiley:


#19