0% found this document useful (0 votes)
16 views10 pages

Theater Management Using Python Incorporating NumPy and Pandas

The document presents a Python program for theater management that utilizes MySQL, NumPy, and Pandas. It allows users to sign up, log in, book tickets for movies, display user information, and log out. The program includes various functionalities and prompts based on user interactions with the menu options.

Uploaded by

ar5592
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views10 pages

Theater Management Using Python Incorporating NumPy and Pandas

The document presents a Python program for theater management that utilizes MySQL, NumPy, and Pandas. It allows users to sign up, log in, book tickets for movies, display user information, and log out. The program includes various functionalities and prompts based on user interactions with the menu options.

Uploaded by

ar5592
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Theater management using

python incorporating NumPy and


Pandas: -
Done by Aaron Ebenezer Samuel

Cse A

RA2311003020014

Source code: -

import mysql.connector as sql

import numpy as np

import pandas as pd

from getpass import getpass

# Establishing a database connection

conn = sql.connect(host='localhost', user='root', passwd='', database='soft')

cc = conn.cursor()

LOGIN = False

PA = None

UID = None

def sign_up():

global LOGIN, PA, UID

v_fn = input("Enter your First Name: ")

v_ln = input("Enter your Last Name: ")

v_pn = int(input("Enter Phone Number: "))


v_uid = int(input("Enter your UserID (6 Digit No.): "))

u=0

cc.execute("SELECT * FROM users")

f = cc.fetchall()

for i in f:

if i[3] == v_uid:

u += 1

print("UID already exists")

if u == 0:

v_pwd = getpass("Enter your Password: ")

v_ins = "INSERT INTO users VALUES('{}','{}',{}, {},'{}')".format(v_fn, v_ln, v_pn, v_uid, v_pwd)

print("***** SIGNED UP SUCCESSFULLY *****")

LOGIN = True

PA = v_pwd

UID = v_uid

cc.execute(v_ins)

conn.commit()

def login():

global LOGIN, PA, UID

if not LOGIN:

u = int(input("*Enter your USERID: "))

p = getpass("*Enter your PASSWORD: ")


cc.execute("SELECT * FROM users")

f = cc.fetchall()

for i in f:

user_id = i[3]

user_pwd = i[4]

if user_id == u:

if user_pwd == p:

UID = int(user_id)

print("******************** LOGIN SUCCESSFUL ********************")

LOGIN = True

PA = p

break

else:

print("Password is Incorrect.")

break

else:

print("UserID not Found")

else:

print("Already Logged IN")

def booking():

global LOGIN, PA, UID

if LOGIN:

print("WELCOME TO THE BOX OFFICE (NON-AC)")

print("""Movies Running:

1: John Wick 4

2: Leo

3: Mark Antony
4: The Marvels

5: Avengers Endgame

6: Spiderman

7: Jailer""")

movie_choice = int(input("Enter your Movie No.: "))

if movie_choice in (1, 2, 3, 4, 5, 6, 7):

name = input("Enter your Name: ")

total_tickets = int(input("Enter Total No. of Tickets: "))

phone_number = int(input("Enter your Phone Number: "))

print("""Classes Available:

1: Classic

2: Premium

3: First Class

4: Majestic""")

class_choice = int(input("Enter your Class No.: "))

classes = ["Classic", "Premium", "First Class", "Majestic"]

class_selection = classes[class_choice - 1]

password = getpass("Enter the password: ")

if PA == password:

print("Ticket Booked!")

print("Thank you for visiting Java Theatre")

rating = int(input("Ratings(0-5): "))

b_ins = "INSERT INTO booking VALUES({}, '{}', {}, {}, {}, '{}')".format(

movie_choice, name, total_tickets, phone_number, UID, class_selection)

cc.execute(b_ins)

conn.commit()
else:

print("Error, Invalid Password")

else:

print("Invalid Movie Choice")

else:

print("Log in to Proceed")

def display_users():

cc.execute("SELECT * FROM users")

users_data = cc.fetchall()

column_names = ["First Name", "Last Name", "Phone Number", "User ID", "Password"]

users_df = pd.DataFrame(users_data, columns=column_names)

print("\n=== Users Information ===")

print(users_df)

def main():

print("""JAVA THEATRE (AC)

1: SIGN UP

2: LOG IN

3: Ticket Booking

4: Display Users

5: LOG OUT

6: Exit""")

while True:

choice = int(input("Enter your Choice: "))


if choice == 1:

sign_up()

elif choice == 2:

login()

elif choice == 3:

booking()

elif choice == 4:

display_users()

elif choice == 5:

global LOGIN, PA, UID

LOGIN = False

PA = None

UID = None

print("Logged Out Successfully")

elif choice == 6:

break

else:

print("Invalid Choice")

if __name__ == "__main__":

main()
Working of the program: -

The provided code is designed to interact with a database, allowing users to sign up, log in, book
tickets, and display user information. The output of the program would be based on the user's
interactions with the menu options and database operations.

Here's a walkthrough of potential outputs based on the user's choices:

1. Sign Up (Option 1):

 Entering user details (first name, last name, phone number, user ID, and password).

 If the user ID is unique, the program will confirm successful sign-up. Otherwise, it
will prompt that the UID already exists.

2. Log In (Option 2):

 Entering user ID and password.

 If the credentials match, it will display "LOGIN SUCCESSFUL". Otherwise, it will


indicate that the password is incorrect or that the user ID is not found.

3. Ticket Booking (Option 3):

 After logging in, users can select a movie, enter their details (name, phone number,
tickets, etc.), and book tickets if the password provided matches the stored
password.

4. Display Users (Option 4):

 Choosing this option will display the user information stored in the 'users' table,
including first name, last name, phone number, user ID, and password.

5. Log Out (Option 5):

 Logging out will reset the session, setting LOGIN, PA, and UID to None, effectively
logging the user out.

6. Exit (Option 6):

 Selecting this option will exit the program.

The actual output of the program will depend on the user's actions, such as signing up, logging in,
booking tickets, or viewing user information. The displayed information will include various prompts,
confirmation messages, and database-related outputs (e.g., successful inserts or queries).
Additionally, any errors or incorrect inputs would prompt respective error messages to guide the
user.

Example Output : -

JAVA THEATRE (AC)

1: SIGN UP

2: LOG IN

3: Ticket Booking

4: Display Users

5: LOG OUT

6: Exit

Enter your Choice: 1

Enter your First Name: Aaron

Enter your Last Name: Samuel

Enter Phone Number: 1234567890

Enter your UserID (6 Digit No.): 123456

Enter your Password: ********

***** SIGNED UP SUCCESSFULLY *****

Enter your Choice: 2

*Enter your USERID: 123456

*Enter your PASSWORD: ********

******************** LOGIN SUCCESSFUL ********************

Enter your Choice: 3

WELCOME TO THE BOX OFFICE (NON-AC)


Movies Running:

1: John Wick 4

2: Leo

3: Mark Antony

4: The Marvels

5: Avengers endgame

6: Spiderman

7: Jailer

Enter your Movie No.: 2

Enter your Name: John Doe

Enter Total No. of Tickets: 2

Enter your Phone Number: 1234567890

Classes Available:

1: Classic

2: Premium

3: First Class

4: Majestic

Enter your Class No.: 3

Enter the password: ********

Ticket Booked!

Thank you for visiting Java Theatre

Ratings(0-5): 4

Enter your Choice: 4

=== Users Information ===

First Name Last Name Phone Number User ID Password

0 Aaron Samuel 1234567890 123456 ********

Enter your Choice: 5

Logged Out Successfully


Enter your Choice: 6

You might also like