You are on page 1of 6

02.

03 Input & Selection Structures

Name: Anshi

Directions

You will follow the four steps in computational thinking to develop and design this program.

Step One: Decomposition


Decomposition involves identifying a problem and breaking it down into smaller, more manageable
steps.

Example: A retailer thinks its online sales should be higher. They identify that their customers are not
making as many large purchases online compared to in the physical store. Looking even closer, they
identify a lack of $200 and higher purchases.
Step Two: Pattern Recognition
After the problem has been broken down in the decomposition step, additional data is needed.

Example: The retailer recognizes a pattern in online sales. When the purchase price is $200 or more, the
shipping costs are also quite high, making customers less likely to make these purchases online. Perhaps
an incentive is needed?

Step Three: Algorithmic Design


Here's where the fun (and the assignment) really begins. Choose one of the options provided below:

Option 1: Spend More, Get More


You've been hired by a store to write a program that helps improve online sales. The retailer
wants to find out how much money customers want to spend, offer a recommendation, and
encourage customers to spend at least $200 by offering a free gift at this price point.

First, you should ask the customers how much money they would like to spend. Then
recommend a product that can be purchased within the amount entered. Finally, let the
customers know how much more money they need to spend in order to receive a free gift (or let
them know they qualify if their initial purchase is $200 or above).

Option 2: Choose Your Own Adventure


Do you enjoy being creative and making up your own scenarios? If you do, then this option is for
you! Come up with any scenario for this assignment as long as you do the following:

 Make it shopping-related (this includes delivery, sales, accounting, or anything else that
works directly with retailers).
 Ensure people reading your code understand your scenario (Hint: Use lots of comments
in your code).
 Follow the requirements described below.

Algorithmic Design and Pseudocode

Use the algorithmic design stage of computational thinking to design a program. Remember that
algorithmic design is where you create step-by-step instructions to solve a problem. This must begin with
pseudocode, then translate to Python using your pseudocode as a guide.
Write your pseudocode where indicated below. Your pseudocode should be written in English (not
Python), should indicate a program that is improving the retail industry, and must:

be written in a series of steps that reflect algorithmic design


print a description of your online store for the user to read
obtain user input in order to make a recommendation
demonstrate proper use of the int(), float(), and str() functions
use proper order of operations and appropriate math functions for calculations
include at least one nested if-else/elif statement
provide output based on user input and results of calculations

Example of expected output: The output for your program should resemble the following screenshot.
Your specific results will vary depending on the choices you make and the input provided.

Pseudocode Hint: Pseudocode for the example output above began with "Start" (which represented the
main function). The next line of pseudocode read "Store Description" (which later turned into a print
function to inform the user about the store). Then the pseudocode read "Ask how much the customer
wants to spend" (this was the eventual input), etc. When you're finished writing your pseudocode, ask
yourself if a non-programmer would be able to read it and understand what your program is going to do.
If the answer is yes – you've probably done a great job!

Write your pseudocode here:

Input:

 create print code for welcome message


 create input code to receive customer budget data
 create variable and declare as integer to set beneficiary amount budget data
 set if statements to follow up whether customer purchase exceeds beneficiary
amount
 if it does not exceed, give extra offers that attracts customers to buy more
products
 if exceeded, display with customer pleasing offers and coupons
 set input statements for offers and create if statements according to
customer’s answers
 create print code for thank you message

Output:

 display welcome message


 display input popup box to receive customer budget value
 display input popup box to ask customer their interest in accepting offers
 display thank you message

Pseudocode to Program Code

Use the Python IDLE built into this course to code and run your program. Your code must:

Use comments for internal documentation (including a heading with your name, today’s date,
and a short description of the program). Remember that you can copy/paste much of your
pseudocode for this internal documentation.
Follow the Python style conventions regarding indentation and the use of white space in your
program.
Run successfully and produce output similar to the example above.

When you’ve completed writing your program code, save your work by selecting ‘Save’ in the Python
IDLE. When you submit your assignment, it will be in two files:
1. Your Python code (as a .py file)
2. This completed assignment template
#Anshi Prem
#03/18/23

def main():

#using print to display welcome message


print("******************************")
print("Welcome to bath and body!")
print("******************************")

#creating variable name and declaring its input as integer


totalCost =int(input("enter budget"))

#creating variable name for budget and declaring it an integer


amount = int(200)

#creating if statement for when customer's bedget is greater than benificiary amount
if (totalCost > amount):
print("YAY! Since your amount exceeds $200, you get free shipping!")
point = input("Would you like to save points from your purchase which can be used to
buy free products on your next purchase?(Y/N)")

#creating commands to be displayed if user answers "yes"


if (point == "Y"):
print("Great! You earned " + str(totalCost) + " points from this purchase.")
print("You can guy products, giftcards, or deliver free gifts using your points.")
prod = input("Buying products using points is a great way to save your money.
Would you like to go back and add something to your cart using your points?(Y/N)")
if (prod == "Y"):
print("Wonderful choice! Here are the products available according to
your preferences that can be bought with your points.")

#creating commands to be displayed if user answers "no"


if (point == "N"):
print("******************************")
print("Thanks for Shopping! Your items are ready to be checked out.")
print("******************************")

#Commands to be followed when customer's budget is less than benificiary amount.


if (totalCost < amount):
print("Buy $" + str(amount-totalCost) + " more to claim special offers!")
offer = input("Would you like to buy our brand new strawberry slush scented candles
that are 75$ and will give 40% discount off your total purchase?(Y/N)")
if (offer == "Y"):
print("Awesome! Strawberry slush scented candles added to cart")
print("******************************")
print("Thanks for Shopping!")
print("******************************")
if (offer == "N"):
print("******************************")
print("Thanks for Shopping!")
print("******************************")
main()
Step Four: Generalize & Assess
Complete the Post Mortem Review (PMR). Write thoughtful two- to three-sentence responses to all the
questions in the PMR chart.

Post Mortem Review Question Response

What was the purpose of your program? To help improve online sales.

How could your program be useful in the real It would improve online sales and bring more
world? profit to the company just as the physical store

What is a problem you ran into, and how did you I kept repeating characters such as “)”, when I
fix it? was using print. That was because IDLE didn’t let
me see my entire code so I wasn’t sure whether I
put all my characters

Describe one thing you would do differently the I would find another way instead of using so
next time you write a program. much if statements

How could your program be generalized and It can be used for any online store app.
useful in other areas?

You might also like