DEV Community

Cover image for Book Your Movie Tickets with Python
Muhammad
Muhammad

Posted on

Book Your Movie Tickets with Python

My simple Python Movie Ticket Booking Calculator that helps users simulate booking a ticket by changing ticket types , prices and more and then calculating the total cost in a clear and easy way

The Movie Ticket Booking Calculator


base_price = 15 # Place Holder
age = 21 # Place Holder
seat_type = "Gold" # Place Holder
show_time = "Evening" # Place Holder

if age > 17:
    print("User is eligible to book a ticket")

if age >= 21:
    print("User is eligible for Evening shows")
else:
    print("User is not eligible for Evening shows")

is_member = False # Place Holder
is_weekend = False # Place Holder

discount = 0
if is_member and age >= 21:
    discount = 3
    print("User qualifies for membership discount")
else:
    print("User does not qualify for membership discount")
print(f"Discount: ${discount}")

extra_charges = 0
if is_weekend or show_time == "Evening":
    extra_charges = 2
    print("Extra charges will be applied")
else:
    print("No extra charges will be applied")
print(f"Extra charges: ${extra_charges}")

if age >= 21 or age >= 18 and (show_time != "Evening" or is_member):
    print("Ticket booking condition satisfied")

    service_charges = 0
    if seat_type == "Premium":
        service_charges = 5
        print(f"Service charges: ${service_charges}")
    elif seat_type == "Gold" :
        service_charges = 3
        print(f"Service charges: ${service_charges}")
    else:
        service_charges = 1
        print(f"Service charges: ${service_charges}")
    final_price = extra_charges + service_charges + base_price - discount
    print(f"Final price of ticket: ${final_price}")
else:
    print("Ticket booking failed due to restrictions")
Enter fullscreen mode Exit fullscreen mode

Features


  • Checks if the user is eligible to book a movie ticket
  • Adds extra charges for evening shows or weekend bookings
  • Applies a membership discount only when the user qualifies
  • Supports different seat types
  • Uses clear conditional logic with if , elif, and else statements

Top comments (1)

Collapse
 
mu54mm4d profile image
Muhammad • Edited

"A person who never made a mistake never tried anything new." - Albert Einstein