Hiii... Can you please check the code and see whether I might have done a mistake ? Beginner's eyes can be misleading quite easily. I feel like there's something wrong in this solution. I can't figure out what. so please check the solution and let me know. keep in mind i'm native sinhala speaker.
Assume hot dogs come in packages of 10, and hot dog buns come in packages of 8. Write a program that calculates the number of packages of hot dogs and the number of packages of hot dog buns needed for a cookout, with the minimum amount of leftovers. The program should ask the user for the number of people attending the cookout and the number of hot dogs each person will be given. The program should display the following details:
- The minimum number of packages of hot dogs required.
- The minimum of hot dogs that will be left over.
- The number of hot dog buns that will be left over.
# Declare hot dogs and hot dog buns
HOT_DOGS_PER_PACKAGE = 10
HOT_DOGS_BUNS_PER_PACKAGE = 8
# Get the number of attendees
attendees = int(input('Enter the number of guests: '))
# Number of hot dogs per person
hot_dogs_per_person = int(input('Hot dogs per person: '))
# Number of hot dogs required
required_hot_dogs = attendees * hot_dogs_per_person
packages_of_hot_dogs = required_hot_dogs / HOT_DOGS_PER_PACKAGE
# Number of hot dog buns required
packages_of_hot_dog_buns = required_hot_dogs / HOT_DOGS_BUNS_PER_PACKAGE
print(f"You require {packages_of_hot_dogs} hot dogs for the cookout.")
print(f"You require {packages_of_hot_dog_buns} buns for the cookout.")
# Number of left over hot dogs
remain_hotdogs = required_hot_dogs % HOT_DOGS_PER_PACKAGE
if remain_hotdogs != 0:
print(f'You have {remain_hotdogs} left over hot dogs')
remain_buns = required_hot_dogs % HOT_DOGS_BUNS_PER_PACKAGE
if remain_buns != 0:
print(f'you have {remain_buns} left over hot dog buns. ')
Program output
Enter the number of guests: 25
Hot dogs per person: 5
You require 12.5 hot dogs for the cookout.
You require 15.625 buns for the cookout.
You have 5 left over hot dogs
you have 5 left over hot dog buns.