Listing 04-10: Bye Plans with elif

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 04\04.10 - Bye Plans with elif.py
# Description: Bye Plans with elif
##############################################################################

valid = True
plan = input("What's your cell phone plan? ")
if plan == "LittleTalk":
    minutes_on_plan = 100
    extra = 0.20
    price = 50
elif plan == "TalkMore":
    minutes_on_plan = 500
    extra = 0.15
    price = 99
else:
    valid = False
if not valid:
    print(f"Error: I don't know this plan {plan}")
else:
    minutes_consumed = int(input("How many minutes did you consume? "))
    print("You will pay:")
    print(f"Plan price ${price:10.2f}")
    supplement = 0
    if minutes_consumed > minutes_on_plan:
        supplement = extra * (minutes_consumed - minutes_on_plan)
    print(f"Supplement ${supplement:10.2f}")
    print(f"Total      ${price + supplement:10.2f}")
Click here to download the file