Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Inventory Sorting Capstone | Variables and Types
Introduction to Python (generated task tests)

Swipe to show menu

book
Challenge: Inventory Sorting Capstone

Great job mastering variables, data types, slicing, and concatenation!

Now, let's apply your new skills to a realistic scenario involving organizing new grocery store inventory.

Task

Swipe to start coding

Manage a grocery store inventory by extracting item names and categories using string slicing, assigning prices, and printing formatted statements.

  • Slice the items string to extract:
    • "Bubblegum" β†’ candy1
    • "Chocolate" β†’ candy2
    • "Pasta" β†’ dry_goods
  • Slice the categories string to extract:
    • "Candy Aisle" β†’ category1
    • "Pasta Aisle" β†’ category2
  • Create price variables:
    • bubblegum_price = $1.50
    • chocolate_price = $2.00
    • pasta_price = $5.40
  • Use print() to display item names, prices, and categories.

Output Requirements

Print the following:

  • We have <candy1> for <bubblegum_price> in the <category1>
  • We have <candy2> for <chocolate_price> in the <category1>
  • We have <dry_goods> for <pasta_price> in the <category2>

Requirements checklist

  1. Check that the value of candy1 is equal to the substring of items from the start up to the first comma.
  2. Check that the value of candy2 is equal to the substring of items between the first and second commas, with leading/trailing spaces removed.
  3. Check that the value of dry_goods is equal to the substring of items after the last comma, with leading/trailing spaces removed.
  4. Check that the value of category1 is equal to the substring of categories from the start up to the first comma.
  5. Check that the value of category2 is equal to the substring of categories after the comma, with leading/trailing spaces removed.
  6. Check that bubblegum_price is equal to "$1.50".
  7. Check that chocolate_price is equal to "$2.00".
  8. Check that pasta_price is equal to "$5.40".

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 7
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

Awesome!

Completion rate improved to 2.17

book
Challenge: Inventory Sorting Capstone

Great job mastering variables, data types, slicing, and concatenation!

Now, let's apply your new skills to a realistic scenario involving organizing new grocery store inventory.

Task

Swipe to start coding

Manage a grocery store inventory by extracting item names and categories using string slicing, assigning prices, and printing formatted statements.

  • Slice the items string to extract:
    • "Bubblegum" β†’ candy1
    • "Chocolate" β†’ candy2
    • "Pasta" β†’ dry_goods
  • Slice the categories string to extract:
    • "Candy Aisle" β†’ category1
    • "Pasta Aisle" β†’ category2
  • Create price variables:
    • bubblegum_price = $1.50
    • chocolate_price = $2.00
    • pasta_price = $5.40
  • Use print() to display item names, prices, and categories.

Output Requirements

Print the following:

  • We have <candy1> for <bubblegum_price> in the <category1>
  • We have <candy2> for <chocolate_price> in the <category1>
  • We have <dry_goods> for <pasta_price> in the <category2>

Requirements checklist

  1. Check that the value of candy1 is equal to the substring of items from the start up to the first comma.
  2. Check that the value of candy2 is equal to the substring of items between the first and second commas, with leading/trailing spaces removed.
  3. Check that the value of dry_goods is equal to the substring of items after the last comma, with leading/trailing spaces removed.
  4. Check that the value of category1 is equal to the substring of categories from the start up to the first comma.
  5. Check that the value of category2 is equal to the substring of categories after the comma, with leading/trailing spaces removed.
  6. Check that bubblegum_price is equal to "$1.50".
  7. Check that chocolate_price is equal to "$2.00".
  8. Check that pasta_price is equal to "$5.40".

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

close

Awesome!

Completion rate improved to 2.17

Swipe to show menu

some-alt