Click here to Skip to main content
15,909,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
print(" 1st - 3rd floor = 10,000.00 ")
print(" 4th - 6th floor = 8,000.00 ")
print(" 7th - 10th floor = 7,000.00 ")
floor = input("What floor will you stay? ")
floor = int(floor)
print(" Here is the list of discount  per year ")
print(" 1-2 years - 3% discount ")
print(" 3-4 years - 4% discount ")
print(" 5 and up - 5% discount")
years = input("How many years will you stay? ")


for floor in range (1, 3):
  print("The Price is: 10,000.00")
  if floor in range (4, 6):
    print("The Price is: 8,000.00")
  elif floor in range (7, 10):
    print("The Price is: 7,000.00")
else: 
    print("We don't have any more floors")

for year in range (1, 2):
  print("You have a 3% discount for the selected year")
  if year in range (3, 4):
    print("You have a 4% discount for the selected year")
  elif year in range (5, 100):
      print("You have a 5% discount for the selected year")
else:
        print("We don't have anymore discounts")



This was the output that it gave me the question are for the inputs.

 1st - 3rd floor = 10,000.00 
 4th - 6th floor = 8,000.00 
 7th - 10th floor = 7,000.00 
What floor will you stay? 2
 Here is the list of discount  per year 
 1-2 years - 3% discount 
 3-4 years - 4% discount 
 5 and up - 5% discount
How many years will you stay? 2
The Price is: 10,000.00
The Price is: 10,000.00
We don't have any more floors
You have a 3% discount for the selected year
We don't have anymore discounts


What I have tried:

I have already tried to reverse some statements and conditions
Posted
Updated 11-Oct-21 0:01am
Comments
CHill60 11-Oct-21 5:50am    
Which results are wrong?
Myth23192810 11-Oct-21 6:06am    
We don't have any more floors
We don't have anymore discounts
and the result for the price was doubled
The Price is: 10,000.00
The Price is: 10,000.00

The reason for the "doubling" up of your outputs is this section here
Python
for floor in range (1, 3):
  print("The Price is: 10,000.00")
  if floor in range (4, 6):
    print("The Price is: 8,000.00")
  elif floor in range (7, 10):
    print("The Price is: 7,000.00")
else: 
    print("We don't have any more floors")
Why are you overriding the value of floor that was input and putting it in a loop? I think that should read
Python
if floor in range (1, 3):
  print("The Price is: 10,000.00")
  elif floor in range (4, 6):
    print("The Price is: 8,000.00")
  elif floor in range (7, 10):
    print("The Price is: 7,000.00")
else: 
    print("We don't have any more floors")
I suspect that will also fix your vague description "and wrong results"
 
Share this answer
 
Try
Python
print(" 1st - 3rd floor = 10,000.00 ")
print(" 4th - 6th floor = 8,000.00 ")
print(" 7th - 10th floor = 7,000.00 ")
floor = input("What floor will you stay? ")
floor = int(floor)
print(" Here is the list of discount  per year ")
print(" 1-2 years - 3% discount ")
print(" 3-4 years - 4% discount ")
print(" 5 and up - 5% discount")
years = input("How many years will you stay? ")
years = int(years)


if floor in range (1, 4):
  print("The Price is: 10,000.00")
elif floor in range (4, 7):
  print("The Price is: 8,000.00")
elif floor in range (7, 10):
  print("The Price is: 7,000.00")
else:
  print("We don't have any more floors")

if years in range (1, 3):
  print("You have a 3% discount for the selected year")
elif years in range (3, 5):
  print("You have a 4% discount for the selected year")
elif years in range (5, 100):
  print("You have a 5% discount for the selected year")
else:
  print("We don't have anymore discounts")
 
Share this answer
 
Comments
CPallini 11-Oct-21 6:25am    
1st - 3rd floor = 10,000.00
4th - 6th floor = 8,000.00
7th - 10th floor = 7,000.00
What floor will you stay? 2
Here is the list of discount per year
1-2 years - 3% discount
3-4 years - 4% discount
5 and up - 5% discount
How many years will you stay? 10
The Price is: 10,000.00
You have a 5% discount for the selected year

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900