Back

Code Challenge: Grocery Grab

Difficulty  

divider

Objective

Ask the user how many apples, bananas, and oranges they bought, then print a tidy grocery summary.

Skills to Practice

  • Prompting a user for input
  • Converting input to the correct data type
  • Performing arithmetic
  • Formatting custom output using variables

Tasks

  • Create a new Python program named cc-grocery-grab.
  • Prompt for a quantity of apples, then bananas, then oranges.
  • Display each fruit with its quantity.
  • Display the total number of pieces of fruit.

Sample Output

Sample Output
How many apples are you buying? 4 [Enter]
How many bananas are you buying? 6 [Enter]
How many oranges are you buying? 3 [Enter]
Grocery List:
Apples: 4
Bananas: 6
Oranges: 3
Total fruit: 13

Commence Challenge