lukaszwasyl
#naukaprogramowania #pytanie #python #programowanie mam takie zadanie

Define a function called cube that takes a number and returns the cube of that number (which is that number raised to the third power).

Define a second function called bythree that takes one number as an argument. If that number is evenly divisible by 3, bythree should call cube on that number. Otherwise, by_three should return False

Taki napisałem kod

def cube(n):

return n^3

def bythree(m):

if n % 3 == 0:

return cube(m)

else:

return False

print bythree(3)

#osochodzi Gdzie popełniłem błąd ?
1
  • Najlepsze
  • Wszystkie komentarze
akurczak
@lukaszwasyl: W Pythonie

^
to operator XOR, do potęgowania użyj

**
9
Yahoo_
@lukaszwasyl: 1. Pastebin
1
p.....y
p.....y
@akurczak: aż sobie fejspalma jebnę :D
1
p.....y
p.....y
@lukaszwasyl:

n % 3
-->

m % 3
0
m21d24
@lukaszwasyl: n i m to nie to samo
0
lukaszwasyl
@m21d24: @paffnucy: dalej nic
0
koob
@lukaszwasyl: w bythree argumentem jest M a reszte z dzielenia sprawdzasz dla N
0
dzien_dobry
@lukaszwasyl:
0