Python Forum
Bill calculator with different prices
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bill calculator with different prices
#1
Hello.

I'm trying to write a program that calculates the total price of photocopies made at a photocpy business.
Prices are as follows:
The first ten are at 10 cents
The next 20 are at 9 cents
The rest are at 8 cents.

This is what I have done:
------------------------------------------------------
n = int(input("Number of copies: "))
Number of copies: 50
total_price = float
if (n <= 10):
total_price = n * .10
elif (n <= 30):
total_price = 10 * .10 + (n - 10) * .09
else:
total_price = 10 * .10 + 20 * .09 + (n - 30) * .08
print("The total price is", total_price)
------------------------------------------------------
I'm getting the following:

The total price is <class 'float'>

Would you please help?

Thank you!
Reply


Messages In This Thread
Bill calculator with different prices - by JHPythonLearner - Sep-14-2018, 06:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need help with creating dynamic columns with for loops for stock prices PaDat 2 1,004 Feb-22-2023, 04:34 AM
Last Post: PaDat
  SMA (simple moving avg) Not receiving Data (stock prices). gdbengo 2 1,526 Jul-31-2022, 08:20 PM
Last Post: paulyan
  Different prices per hour kemper 1 2,091 Jan-29-2019, 11:06 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020