Question 5: Operator Sharing Fruits

🍎 Sharing Fruits

Use: import task_operators_05

Sam has 27 apples and 5 friends. He wants to share the apples equally with all of them (including himself). He also wants to know how many apples will be left over after the share.

Write a Python program that calculates how many apples each person gets and how many are left.

  • Store Sam’s name in a variable called name and set it to “Sam”.
  • Store the number of apples in a variable called apples and set it to 27.
  • Store the number of friends in a variable called friends and set it to 5.
  • Calculate how many people are sharing (Sam plus his friends) and store it in people using friends + 1.
  • Calculate how many apples each person gets and store it in apples_each using apples // people.
  • Calculate how many apples are left over and store it in leftover using apples - (apples_each * people).
  • Print exactly one line in this format:
    <name> gives <apples_each> apples to each of <people> people. Leftover: <leftover>
Write what you are looking for, and press enter to begin your search!