Advertisement
James_reply

Untitled

Oct 22nd, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.21 KB | None | 0 0
  1. LEARN PYTHON 3
  2. Create Purchasing Information and Receipts for Lovely Loveseats
  3. We’ve decided to pursue the dream of small-business ownership and open up a furniture store called Lovely Loveseats for Neat Suites on Fleet Street. With our newfound knowledge of Python programming, we’re going to build a system to help speed up the process of creating receipts for your customers.
  4.  
  5. In this project, we will be storing the names and prices of a furniture store’s catalog in variables. You will then process the total price and item list of customers, printing them to the output terminal.
  6.  
  7. Please note: Projects do not run tests against your code. This experience is more open to your interpretation and gives you the freedom to explore. Remember that all variables must be declared before they are referenced in your code.
  8.  
  9. If you get stuck during this project or would like to see an experienced developer work through it, click “Get Help“ to see a project walkthrough video.
  10.  
  11. Tasks
  12. 19/20Complete
  13. Mark the tasks as complete by checking them off
  14. Adding In The Catalog
  15. 1.
  16. Let’s add in our first item, the Lovely Loveseat that is the store’s namesake. Create a variable called lovely_loveseat_description and assign to it the following string:
  17.  
  18. Lovely Loveseat. Tufted polyester blend on wood. 32 inches high x 40 inches wide x 30 inches deep. Red or white.
  19. 2.
  20. Great, now let’s create a price for the loveseat. Create a variable lovely_loveseat_price and set it equal to 254.00.
  21.  
  22. 3.
  23. Let’s extend our inventory with another characteristic piece of furniture! Create a variable called stylish_settee_description and assign to it the following string:
  24.  
  25. Stylish Settee. Faux leather on birch. 29.50 inches high x 54.75 inches wide x 28 inches deep. Black.
  26. 4.
  27. Now let’s set the price for our Stylish Settee. Create a variable stylish_settee_price and assign it the value of 180.50.
  28.  
  29. 5.
  30. Fantastic, we just need one more item before we’re ready for business. Create a new variable called luxurious_lamp_description and assign it the following:
  31.  
  32. Luxurious Lamp. Glass and iron. 36 inches tall. Brown with cream shade.
  33. 6.
  34. Let’s set the price for this item. Create a variable called luxurious_lamp_price and set it equal to 52.15.
  35.  
  36. 7.
  37. In order to be a business, we should also be calculating sales tax. Let’s store that in a variable as well.
  38.  
  39. Define the variable sales_tax and set it equal to .088. That’s 8.8%.
  40.  
  41. Our First Customer
  42. 8.
  43. Our first customer is making their purchase! Let’s keep a running tally of their expenses by defining a variable called customer_one_total. Since they haven’t purchased anything yet, let’s set that variable equal to 0 for now.
  44.  
  45. 9.
  46. We should also keep a list of the descriptions of things they’re purchasing. Create a variable called customer_one_itemization and set that equal to the empty string "". We’ll tack on the descriptions to this as they make their purchases.
  47.  
  48. 10.
  49. Our customer has decided they are going to purchase our Lovely Loveseat! Add the price to customer_one_total.
  50.  
  51. 11.
  52. Let’s start keeping track of the items our customer purchased. Add the description of the Lovely Loveseat to customer_one_itemization.
  53.  
  54. 12.
  55. Our customer has also decided to purchase the Luxurious Lamp! Let’s add the price to the customer’s total.
  56.  
  57. 13.
  58. Let’s keep the itemization up-to-date and add the description of the Luxurious Lamp to our itemization.
  59.  
  60. 14.
  61. They’re ready to check out! Let’s begin by calculating sales tax. Create a variable called customer_one_tax and set it equal to customer_one_total times sales_tax.
  62.  
  63. 15.
  64. Add the sales tax to the customer’s total cost.
  65.  
  66. 16.
  67. Let’s start printing up their receipt! Begin by printing out the heading for their itemization. Print the phrase "Customer One Items:".
  68.  
  69. 17.
  70. Print customer_one_itemization.
  71.  
  72. 18.
  73. Now add a heading for their total cost: Print out "Customer One Total:"
  74.  
  75. 19.
  76. Now print out their total! Our first customer now has a receipt for the things they purchased.
  77.  
  78. 20.
  79. Congratulations! We created our catalog and served our first customer. We used our knowledge of strings and numbers to create and update variables. We were able to print out an itemized list and a total cost for our customer. Lovely!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement