Need help with writing an algorithm:

Department Store Sale! Prompt the user to enter the sticker price of each of the clothing items they’re purchasing (make sure all input prices are positive). The user should be allowed to purchase as many items as he or she would like. For each individual item, the user should input whether the item is a White Tag (regular price), Blue Tag (25% off), Orange Tag (50% off), or Red Tag (75% off) item. Output the final bill, including tax.

I'm new to this.

Main ()
         Declare Tax_Price as Real
         Declare Final_Price as Real
         Declare Discount as Real
         Declare Item_Price as Real
         Display “Please enter the item price”
         Input Item_Price
         Display “Please enter discount as decimal”

Recommended Answers

All 2 Replies

In Python you don't declare variables.
To read an input value, and supposing you use Python2, try the following at the interactive prompt:

price = input("Give price: ")
print price

(entering a value when pompted). This should give you an idea. If you want to read string values rather than numbers, use raw_input.

If you are useing Python3, then do something like:

price = input("Give price: ")
price = float(price)
print(price)

You can use input() for both versions of Python:

# Python2 uses raw_input() for strings
# Python3 uses input() for strings

# ----------------------------------------------
# add these few lines near the start of you code
import sys
# make string input work with Python2 or Python3
if sys.version_info[0] < 3:
    input = raw_input
# ----------------------------------------------

# test ...
# now you can avoid using raw_input()
name = input("Enter your name: ")
# if you expect float input, use float() instead of int()
age = int(input("Enter your age: "))
print("%s you are %d old" % (name, age))
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.