Hi people. After many attempts, I managed to code the first part of this exercise, but I still don't know what to do in the second part.
Inst.: Calculate the number of wheat grains on a chessboard given that the number on each square doubles.
Write code that shows:
how many grains were on a given square, and
the total number of grains on the chessboard
My code:
#this is ok, I'll see what the linter has to say about it
def square(number):
if number > 64 or number <= 0:
raise ValueError("square must be between 1 and 64")
amount_of_grains = 1
for value in range(2, number+1):
amount_of_grains = amount_of_grains * 2
return amount_of_grains
# What am I supposed to do with this?
def total():
amount_of_grains = 1
for value in range(2, 64+1):
amount_of_grains = amount_of_grains * 2
return amount_of_grains