Book Your Movie Tickets with Python

Book Your Movie Tickets with Python

calendar_today agoschedule1 min read
— Originally published at dev.to

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")

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

1 Comment

0 votes
🔥 Join developers growing publicly
Share your knowledge, build in public, and grow your developer presence with a global community.

More Posts

Dashboard Operasional Armada Rental Mobil dengan Python + FastAPI

Masbadar - Mar 12

What Is SARIF and How Does It Help Security Tools Work Together?

Ganesh Kumar - Jul 4

I Wrote a Script to Fix Audible's Unreadable PDF Filenames

snapsynapseverified - Apr 20

Your Tech Stack Isn’t Your Ceiling. Your Story Is

Karol Modelskiverified - Apr 9

Implementing Cellular Redundancy: Cross-Cloud Failover with AWS Transit Gateway and Azure ExpressRou

Cláudio Raposo - May 5
chevron_left
216 Points6 Badges
4Posts
0Comments
1Connections

Related Jobs

View all jobs →

Commenters (This Week)

5 comments
2 comments
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!