Naren, Harish CS Project

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 26

OVERVIEW OF PYTHON

Python is an interpreted, object-oriented, high-level programming

language with dynamic semantics developed by Guido van

Rossum. It was originally released in 1991.

HISTORY OF PYTHON
 1989: Guido van Rossum begins working on Python.

 1991: Python 0.9.0 is released.

 1994: Python 1.0 is released.

 2000: Python 2.0 is released.

 2008: Python 3.0 is released.

 2010: Python 2.6 is released.

 2014: Python 3.4 is released.

 2020: Python 3.9 is released.

 2021:Python 3.10 is realeased.

 2022:Python 3.11 is released.


What can Python do?

 Data science:Perform complex statistical calculations, analyse and


manipulate data, and create data visualizations

 Machine learning:Implement Python libraries to clean, manipulate, and


preprocess data for model training

 Web development:Create elements of a website or application that


users don't interact with, such as data transfer, database
communication, and URL routing

 Game development:Use Python's object-oriented programming


techniques to develop games

 Web scraping:Use libraries like Beautiful Soup, Scrapy, and Selenium to


parse HTML, automate web browsing, and extract data from websites

 System scripting:Automate tasks that are performed repeatedly, such


as checking for errors across multiple files

Why Python?
 Easy to learn
Python is considered to be simple to learn and master, and beginners
can build a basic game in a few days.

 Versatile
Python is platform-independent and can be used for a variety of
purposes, including automation, machine learning, and data science.
 Supportive community
Python has a large and supportive community, with many libraries
and frameworks available
.
 Used by many companies
Python is used by many companies and institutions around the
world.

 Excellent for data science


Python is considered one of the most essential languages for data
science, with many powerful statistical and data visualization
libraries.

 Good for machine learning and AI


Python is stable, flexible, and simple, making it ideal for machine
learning and artificial intelligence projects.

 Good for automation


Python has many tools, packages, and modules to help automate
applications quickly.

Disadvantages of Python:
 Slow execution speed: Python is an interpreted language, which means
it's slower than compiled languages like C or Java. This is because Python
translates code into machine code line by line during execution.

 Large memory consumption: Python's data structures require more


memory space, making it unsuitable for development with limited memory.

 Not ideal for mobile and game development: Python is mainly used for
desktop and web server-side development. It's not considered ideal for
mobile app and game development due to its slow processing speed and
high memory consumption.
 Less secure: Python is a dynamically typed language, which can lead to
vulnerabilities.

Overview of Mysql

What is SQL?
Structured query language (SQL) is a programming language for storing and
processing information in a relational database. A relational database stores
information in tabular form, with rows and columns representing different
data attributes and the various relationships between the data values.

 SQL is used to interact with relational databases. It works by


understanding and analysing data of virtually any size, from small
datasets to large stacks. It’s a powerful tool that enables you to
perform many functions efficiently and quickly.

 How it interacts with databases is ‘non-procedural.’ This means


SQL’s syntax is very simple, and the coder must only specify
“what to do”, not “how to do it.” These interactions are
essentially commands, which fall into five categories: data
definition, data manipulation, data control, transaction control
and data query.

Why SQL?

 Retrieve data: Extract specific information from the

database.
 Insert data: Add new data to the database.

 Update data: Modify existing data.

 Create, modify, and delete database structures:

Organize and restructure the database itself.

A Brief History of SQL

 1970 − Dr. Edgar F. "Ted" Codd of IBM is known as the


father of relational databases. He described a relational
model for databases.

 1974 − Structured Query Language (SQL) appeared.

 1978 − IBM worked to develop Codd's ideas and


released a product named System/R.

 1986 − IBM developed the first prototype of relational


database and standardized by ANSI. The first relational
database was released by Relational Software which
later came to be known as Oracle.

 1987 − SQL became the part of the International


Organization for Standardization (ISO).

How SQL Works?


 You write an SQL query: This query is a specific
instruction telling the database what you want to do,
like "Give me all customers from California."
 The DBMS parses the query: The DBMS breaks down
the query into smaller parts to understand its meaning.
 The query is optimized: The DBMS determines the
most efficient way to execute the query.
 The query is executed: The DBMS accesses the
database, retrieves the requested data, and processes
it according to the query.
 The results are returned: The DBMS sends the
results back to you, usually in a tabular format.

Commonly used datatypes in MySQL:

 Char(n) – specifies character type of data of length ‘n’


where n could be any value from 0-255. It is of fixed
length.

 Varchar(n) – specifies character type of data of length ‘n’


where n could be any value from 0-65535. It is of
variable length data type.

 int – it specifies integer value & occupies 4 bytes of


storage. The range of value will be from 0-294967295.

 Float – it specifies numbers with decimal points. Each


float value occupies 4 bytes.
 Date – It is used for storing date in ‘YYYY-MM-DD’ format.

Commonly used constraints:

 NOT NULL

 UNIQUE

 DEFAULT

 PRIMARY KEY

 FOREIGN KEY

TYPES OF COMMANDS IN MYSQL:

 DDL - DATA DEFINITION LANGUAGE

 DML – DATA MANIPULATION LANGUAGE

 TCL – TRANSACTION QUERY LANGUAGE

 DCL – DATA CONTROL LANGUAGE

Key Concepts:

Relational Databases:

SQL is primarily used with relational databases, which organize


data into tables consisting of rows and columns. These tables
establish relationships between different sets of data, ensuring
efficient and organized data storage.

SQL Statements:
SELECT: Retrieves data from one or more tables.

INSERT: Adds new records into a table.

UPDATE: Modifies existing records in a table.

DELETE: Removes records from a table.

CREATE: Creates new databases, tables, or views.

ALTER: Modifies existing database objects.

DROP: Deletes databases, tables, or views

ABSTRACT
REQUIREMENTS
SOURCE CODE

class Movie:
def __init__(self, title, duration, rating, total_seats):
self.title = title
self.duration = duration
self.rating = rating
self.total_seats = total_seats
self.available_seats = total_seats

def book_ticket(self, num_tickets):


if num_tickets <= self.available_seats:
self.available_seats -= num_tickets
return True
return False

def __str__(self):
return f"{self.title} | Duration: {self.duration} min | Rating:
{self.rating}/10 | Available Seats: {self.available_seats}"
class User:
def __init__(self, name, age):
self.name = name
self.age = age
self.bookings = []

def add_booking(self, movie, num_tickets):


self.bookings.append((movie.title, num_tickets))

def show_bookings(self):
if not self.bookings:
return "No bookings found."
return "\n".join([f"{title}: {num_tickets} tickets" for title,
num_tickets in self.bookings])

class MovieBookingSystem:
def __init__(self):
self.movies = []
self.users = []

def add_movie(self, movie):


self.movies.append(movie)

def show_movies(self):
return "\n".join([str(movie) for movie in self.movies])

def find_movie(self, title):


for movie in self.movies:
if movie.title.lower() == title.lower():
return movie
return None

def register_user(self, name, age):


user = User(name, age)
self.users.append(user)
return user
def main():
system = MovieBookingSystem()

# Adding some sample movies


system.add_movie(Movie("Inception", 148, 8.8, 100))
system.add_movie(Movie("The Matrix", 136, 8.7, 80))
system.add_movie(Movie("Interstellar", 169, 8.6, 50))
system.add_movie(Movie("Parasite", 132, 8.6, 30))

print("Welcome to the Movie Ticket Booking System!")

while True:
print("\n1. Show Movies")
print("2. Register User")
print("3. Book Ticket")
print("4. Show User Bookings")
print("5. Exit")

choice = input("Enter your choice: ")


if choice == '1':
print("\nAvailable Movies:")
print(system.show_movies())

elif choice == '2':


name = input("Enter your name: ")
age = int(input("Enter your age: "))
user = system.register_user(name, age)
print(f"User registered successfully: {user.name}")

elif choice == '3':


user_name = input("Enter your name: ")
user = next((u for u in system.users if u.name ==
user_name), None)
if not user:
print("User not found. Please register first.")
continue

movie_title = input("Enter movie title: ")


movie = system.find_movie(movie_title)
if not movie:
print("Movie not found.")
continue

num_tickets = int(input("Enter number of tickets: "))


if movie.book_ticket(num_tickets):
user.add_booking(movie, num_tickets)
print(f"{num_tickets} tickets booked for
{movie.title}.")
else:
print("Not enough available seats.")

elif choice == '4':


user_name = input("Enter your name: ")
user = next((u for u in system.users if u.name ==
user_name), None)
if user:
print("Your Bookings:")
print(user.show_bookings())
else:
print("User not found.")
elif choice == '5':
print("Thank you for using the Movie Ticket Booking
System!")
break

else:
print("Invalid choice. Please try again.")

if __name__ == "__main__":
main()

OUTPUT

You might also like