Lesson 2.3– If Statement.pdf
exercises 2.3.pdf
#selectionEx1.py
price = float(input("enter meal price: "))
if price<4:
print("Wow! that's cheap!")
print(f"That'll be {price*1.05:.2f} after tax.")
elif price>4:
print(f"That'll be {price*1.13:.2f} after tax.")
#selectionEx2.py
name = input("Enter your file name: ")
dot = name.find(".")
ext = name[dot:]
if ext == ".docx":
print("This is a Word document")
elif ext == ".pdf":
print("This is a PDF document")
elif ext == ".pptx":
print("This is a PowerPoint document")
elif ext == ".py":
print("This is a python document")
elif ext == ".png":
print("This is a PNG document")
#selectionEx3.py
place = input("Where are you mailing to: ").lower()
if place == "canada":
print ("That'll be 0.52 cents")
elif place == "usa":
print ("That'll be 0.93 cents")
else:
print ("That'll be 1.55 cents")
# selectionEx4.py
length = int(input("Enter size of python: "))
if length <= 6:
area = length * 0.5
elif:
area = (6 * 0.5) + ((length - 6) * 0.75)
print(f"The minimum area needed for the enclosure is {area:.2f} square feet.")