liveBook · Manning

Order

As explained in A Pythonic Adventure: From Python basics to a working web app

An order is a customer's requested set of products and options from a shop.

An order collects one customer's name, drink, flavor, and topping in a Python dictionary. The program gathers it, displays it for checking, then saves or cancels it. section 6.0 section 7.0

A small order workflow follows these steps:

  • Create an empty dictionary with {}. section 7.0
  • Store customer details and choices under keys such as name, drink, flavor, and topping. section 7.0
  • Pass the order to a printing function so the customer can check it. section 6.0 section 7.0
  • Save confirmed orders and return to the main menu; discard cancelled orders. section 6.0

A vanilla decaf order

The dictionary {'name': 'Erik', 'drink': 'decaf', 'flavor': 'vanilla', 'topping': 'chocolate'} represents Erik's completed order. A confirmation saves it; a cancellation forgets it. section 6.0 section 7.0

How A Pythonic Adventure: From Python basics to a working web app covers it

How deep it goes
Defines the order as a dictionary and works through its functions, stopping short of implementing permanent saving.
Examples
Uses Erik's decaf vanilla drink with chocolate topping, dictionary listings, confirmation prompts, and cancellation output.
What it assumes
Assumes basic menus, loops, and input while teaching dictionary creation, keyed assignment, function returns, and a NameError correction.
What you can do after
Build it from scratch by collecting order fields, printing the dictionary, and routing confirmed or cancelled orders.
How it connects
Connects orders with dictionaries, functions, input, loops, menus, confirmation, and top-down development.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of A Pythonic Adventure: From Python basics to a working web app. The section links point to the parts of the book it draws on.