Python Forum
A three if statement problem I am having
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A three if statement problem I am having
#1
When I run it I have the problem in which the overall price always calculates as if the carpet is basic, so if I choose a luxury carpet the carpet price will be the same as if I have chosen basic. I have asked my teacher for help and they are unsure

This is my code:

#oneSquareMetre fitting price = £3.75
#One Square metre of basic is £6.50
#One Square metre of standard is £18.75
#One Square metre of luxury is £29.50


oneSquareMetre = float(3.75)
print ("What type of Carpet do you want?")
TypeOfCarpet = input()
print ("What is the size of the room in Square Metres")
SizeOfRoom = float(input())
FittingPrice = float(oneSquareMetre * SizeOfRoom)
print ("Your fitting price in GBP is")
print (FittingPrice)
print ("Your overall price in GBP is")
if ((TypeOfCarpet) == ("basic") or ("Basic")):
    CarpetCost = ((6.50) * SizeOfRoom)
    print (CarpetCost + FittingPrice)
    #print ((float(6.50) * SizeOfRoom))
    
elif ((TypeOfCarpet) == ("standard") or ("Standard")):
    CarpetCost = ((18.75) * SizeOfRoom)
    print (CarpetCost + FittingPrice)
    #print ((float(6.50) * SizeOfRoom))
    
elif ((TypeOfCarpet) == ("luxury") or  ("Luxury")):
    print ((float(29.50) * SizeOfRoom))
Reply
#2
You will most likely find the answer in this tutorial on our forums.
Reply


Forum Jump:

User Panel Messages

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