Movie Ticket Booking System

SHIBIKANTH R
3 min readApr 17, 2022

--

Here we are going to look into the movie ticket booking system using Python.

This is a simple and an efficient code for the booking system.

The code is designed on a section basis beginning from class.

Class & Def->

Python is an object oriented programming language.

Almost everything in Python is an object, with its properties and methods.

A Class is like an object constructor, or a “blueprint” for creating objects.

Hence we begin the code by defining the class.

The __init__ method is similar to constructors in C++ and Java. Constructors are used to initialize the object’s state.

By using the “self” keyword we can access the attributes and methods of the class in python.

Name of the movie , booked movie and the total cost are initialized with self.

Input->

In order to display the availability of movies and their respective tickets, we must declare them in a dictionary format. It contains a key and a value assigned to it.

Also the username should be got from the user as input form.

For Loop->

We initiate the program with for loop to get across the tickets and availability.

Since we used a dictionary as a content holder, we go through keys and values in for loop for execution.

User Input->

Now we need to get the input from the user end. The user has to enter his choice of the movie within the given limit.

Incase if he enter greater than the limit, the code gets terminated.

If else part->

The inputs are taken into coding only if the if else condition is declared for certain values of input.

With the input given, the chosen value gets into the condition equal to its value.

Booking section->

The booking of tickets must keep track of remaining tickets too. This section has the input of booking, go back or exit. Whatever the users decision is given here and the tickets count also gets reduced after each booking.

def function gets initiated at the end

Calling def->

On the other hand if the go back option is entered, then the program gets called from the def function and the code runs again from the start.

calling def at the end

Output->

For a successful booking
For a sold out movie

So I hope the above code might be a good one in a simple and a well executed manner.

--

--