-1

This is the problem I am working through:

The program asks the user for the number of pieces of cake and the number of party-goers, in that order. Print the number of pieces of cake each party-goer receives and the number of pieces of cake left over

My code:

pieces_cake = int(input('Number of pieces of cake:'))
party_goers = int(input('Number of party-goers: '))

def cake_per_person(pieces_cake, party_goers):
    cake_per_person = pieces_cake//party_goers
    return cake_per_person
def leftover_cake(pieces_cake, party_goers):
    leftover_cake = pieces_cake % party_goers
    return leftover_cake


print(f"Each party-goer recieves {cake_per_person} pieces of cake\n Pieces of cake that won't be distributed: {leftover_cake}")

Output:

Number of pieces of cake:12
Number of party-goers: 5
Each party-goer recieves <function cake_per_person at 0x000001947A3C51F0> pieces of cake
 Pieces of cake that won't be distributed: <function leftover_cake at 0x000001947A5B7EE0>

What am I doing wrong?

Brian61354270
  • 8,690
  • 4
  • 21
  • 43

1 Answers1

0

You are not calling the functions, just printing them. The correct line should probably be:

print(f"Each party-goer recieves {cake_per_person(pieces_cake, party_goers)} pieces of cake\n Pieces of cake that won't be distributed: {leftover_cake(pieces_cake, party_goers)}")
Amit Sides
  • 274
  • 2
  • 6