7 TH SEMfinal Project 2027253

Download as pdf or txt
Download as pdf or txt
You are on page 1of 72

PROJECT REPORT

ON
HOTEL MANAGEMENT SYSTEM

Project-I

Department of Artificial intelligence & Machine Learning


CHANDIGARH ENGINEERING COLLEGE JHANJERI,
MOHALI

In partial fulfillment of the requirements for the award of the Degree of


Bachelor of Technology in Artificial Intelligence & Machine Learning

SUBMITTED BY:s Under the Guidance of

Ankit Singh POOJA VERMA


2027253 Assistant Prof. CSE
MAY, 2023

Affiliated to I.K Gujral Punjab Technical University, Jalandhar


(Batch: 2020-2024)
DECLARATION

I, Ankit Singh hereby declare that the report of the project entitled “Hotel

Management System” has not presented as a part of any other academic work to

get my degree or certificate except Chandigarh Engineering College Jhanjeri,

Mohali, affiliated to I.K. Gujral Punjab Technical University, Jalandhar, for the

fulfillment of the requirements for the degree of B. Tech in Artificial Intelligence

& Machine Learning.

ANKIT SINGH POOJA VERMA


2027253 Assistant Prof. CSE
Semester: 7TH

Dr. Sahil Verma


DEAN (CSE, AI&DS and AIML)

i
ACKNOWLEDGEMENT

It gives me great pleasure to deliver this report on the Project-I, I worked on for my
B. Tech in Artificial Intelligence & Machine Learning final year, which was titled
“Hotel Management System”. I am grateful to my university for presenting me with
such a wonderful and challenging opportunity. I also want to convey my sincere
gratitude to all coordinators for their unfailing support and encouragement.
I am extremely thankful to Dr. Sahil Verma, Dean of Artificial Intelligence &
Machine Learning at Chandigarh Engineering College Jhanjeri, Mohali (Punjab)
for valuable suggestions and heartiest co-operation.
I am also grateful to the management of the institute, Dr. Vinod Kumar, Director
Engineering, and Dr. Anupam Shar, Director Academics, for giving me the chance
to acquire the information. I am also appreciative of all of my faculty members,
who have instructed me throughout my degree.

Ankit Singh

ii
List of Figures

Figures Figures Description Page no

Fig 6.3.1 Methodology 59

Fig 6.3.2 Flowchart 60

Fig 6.4.1 Code1 61

Fig 6.4.2 Code2 62

Fig 7.1.1 Project Screenshot 63

Fig 7.1.2 Project Screenshot 64

iii
CONTENTS

Topic Page No.

Declaration ii

Acknowledgement iii

List of Figures iv

CHAPTER 1 INTRODUCTION 1-5

2.1 Introduction to Python

2.2 Scripting Language

2.3 Object Oriented Programming

2.4 History of Python

CHAPTER 2 DATA TYPES AND OPERSTORS 6-18

2.1 Variable

2.2 String

2.3 Python Operator

2.2.1 Arithmetic Operator

2.2.2 Comparison Operator

2.2.3 logical Operator

iv
CHAPTER 3TUPLE AND LIST 19-33

3.1 Tuple

3.2 List

CHAPTER 4 LOOP & CONDITIONAL STATEMENTS 34-52

4.1 Loops

4.2 Conditional statements

4.3 Function

CHAPTER 5 PROJECT WORK 53-59

CHAPTER 6 RESULT AND DISCUSSION 60-61

CHAPTER 7 CONCLUSION AND FUTURE SCOPE 62-63

REFERENCES 64

v
2. INTRODUCTION
This Chapter involves detailed introduction about training and the complete
study of all the technologies that are taught in this time period with
information of projects also.

2.1 Introduction of Python Development

Python is an interpreted, object-oriented, high-level programming language with dynamic


semantics. Its high-level built in data structures, combined with dynamic typing and dynamic
binding, make it very attractive for Rapid Application Development, as well as for use as a
scripting or glue language to connect existing components together. Python's simple, easy to
learn syntax emphasizes readability and therefore reduces the cost of program maintenance.
Python supports modules and packages, which encourages program modularity and code reuse.
The Python interpreter and the extensive standard library are available in source or binary form
without charge for all major platforms, and can be freely distributed.

Often, programmers fall in love with Python because of the increased productivity it provides.
Since there is no compilation step, the edit-test-debug cycle is incredibly fast. Debugging Python
programs is easy: a bug or bad input will never cause a segmentation fault. Instead, when the
interpreter discovers an error, it raises an exception. When the program doesn't catch the
exception, the interpreter prints a stack trace. A source level debugger allows inspection of local
and global variables, evaluation of arbitrary expressions, setting breakpoints, stepping through the
code a line at a time, and so on. The debugger is written in Python itself, testifying to Python's
introspective power. On the other hand, often the quickest way to debug a program is to add a few
print statements to the source: the fast edit-test-debug cycle makes this simple approach very
effective.

Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is


designed to be highly readable. It uses English keywords frequently where as other languages use
punctuation, and it has fewer syntactical constructions than other languages.

1
• Python is Interpreted − Python is processed at runtime by the interpreter. You
do not need to compile your program before executing it. This is similar to PERL
and PHP.
• Python is Interactive − You can actually sit at a Python prompt and interact with
the interpreter directly to write your programs.
• Python is Object-Oriented − Python supports Object-Oriented style or technique
of programming that encapsulates code within objects.
• Python is a Beginner's Language − Python is a great language for the beginner-
level programmers and supports the development of a wide range of applications
from simple text processing to WWW browsers to games.

Python Features
Python's features include −

• Easy-to-learn − Python has few keywords, simple structure, and a clearly


defined syntax. This allows the student to pick up the language quickly.
• Easy-to-read − Python code is more clearly defined and visible to the eyes.
• Easy-to-maintain − Python's source code is fairly easy-to-maintain.
• A broad standard library − Python's bulk of the library is very portable and
cross-platform compatible on UNIX, Windows, and Macintosh.
• Interactive Mode − Python has support for an interactive mode which
allows interactive testing and debugging of snippets of code.
• Portable − Python can run on a wide variety of hardware platforms and
has the same interface on all platforms.
• Extendable − You can add low-level modules to the Python interpreter.
These modules enable programmers to add to or customize their tools to
be more efficient.
• Databases − Python provides interfaces to all major commercial
databases.
• GUI Programming − Python supports GUI applications that can be created
and ported to many system calls, libraries and windows systems, such as
Windows MFC, Macintosh, and the X Window system of Unix.
• Scalable − Python provides a better structure and support for large
programs than shell scripting.
2
Apart from the above-mentioned features, Python has a big list of good features, few
are listed below −

• It supports functional and structured programming methods as well as


OOP.
• It can be used as a scripting language or can be compiled to byte-code for
building large applications.
• It provides very high-level dynamic data types and supports dynamic type
checking.
• It supports automatic garbage collection.
• It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.

2.2 Scripting language

Yes, Python is scripting, general-purpose, high-level, and interpreted programming language. It


also provides the object-oriented programming approach. The filename extension of Python
can be various types such as .py, ,pyw, ,pyc, ,pyd, .pyz.

The scripting language is referred to perform the task based on automating a repeated task. It
includes same types of steps while implementing the procedure or program. It reduces time and
cuts the costs further. The scripting languages are interpreted language instead of a compiled
language. The name of few scripting languages is Perl, Visual Basic, JavaScript, Python, Unix
Shell Scripts, ECMAScript, and Bash etc.

Features of Scripting Language

Below are the features of the scripting language.

o It runs faster and complete task efficiently.


o It is easy to learn and easy to use.
o No IDEs are required to write code.
o It is suitable for automation tasks.

3
o Scripting language doesn't require the memory to run the program.
o Less line code requires completing the task as compared to other languages.

2.3 Object Oriented Programming

Like other general-purpose programming languages, Python is also an object-oriented language


since its beginning. It allows us to develop applications using an Object-Oriented approach.
In Python

, we can easily create and use classes and objects.

An object-oriented paradigm is to design the program using classes and objects. The object is
related to real-word entities such as book, house, pencil, etc. The oops concept focuses on writing
the reusable code. It is a widespread technique to solve the problem by creating objects.

Major principles of object-oriented programming system are given below.

o Class
o Object
o Method
o Inheritance
o Polymorphism
o Data Abstraction
o Encapsulation

2.4 History of Python

There is a fact behind choosing the name Python

. Guido van Rossum was reading the script of a popular BBC comedy series "Monty Python's
Flying Circus". It was late on-air 1970s.

4
Van Rossum wanted to select a name which unique, sort, and little-bit mysterious. So, he decided
to select naming Python after the "Monty Python's Flying Circus" for their newly created
programming language.

The comedy series was creative and well random. It talks about everything. Thus, it is slow and
unpredictable, which made it very interesting.

Python is also versatile and widely used in every technical field, such as Machine Learning

, Artificial Intelligence
, Web Development, Mobile Application
, Desktop Application, Scientific Calculation, etc.

• Python laid its foundation in the late 1980s.


• The implementation of Python was started in December 1989 by Guido Van Rossum at
CWI in Netherland.
• In February 1991, Guido Van Rossum published the code (labelled version 0.9.0) to
outsources.
• In 1994, Python 1.0 was released with new features like lambda, map, filter, and reduce.
• Python 2.0 added new features such as list comprehensions, garbage collection systems.
• On December 3, 2008, Python 3.0 (also called "Py3K") was released. It was designed to
rectify the fundamental flaw of the language.
• ABC programming language is said to be the predecessor of Python language, which was
capable of Exception Handling and interfacing with the Amoeba Operating System.
• The following programming languages influence Python:
o ABC language.
o Modula-3

5
3 DATATYPES AND OPERATORS

Data types are the classification or categorization of data items. It represents the kind of value
that tells what operations can be performed on a particular data. Since everything is an object in
Python programming, data types are actually classes and variables are instance (object) of these
classes.

Python Operators in general are used to perform operations on values and variables. These are
standard symbols used for the purpose of logical and arithmetic operations. In this article, we will
look into different types of Python operators.

3.1 Variables

Variable is a name that is used to refer to memory location. Python variable is also known
as an identifier and used to hold value.

In Python, we don't need to specify the type of variable because Python is a infer language
and smart enough to get variable type.

Variable names can be a group of both the letters and digits, but they have to begin with a
letter or an underscore.

It is recommended to use lowercase letters for the variable name. Rahul and rahul both are
two different variables.

Identifier Naming

Variables are the example of identifiers. An Identifier is used to identify the literals used in
the program. The rules to name an identifier are given below.

o The first character of the variable must be an alphabet or underscore ( _ ).


o All the characters except the first character may be an alphabet of lower-case(a-z), upper-
case (A-Z), underscore, or digit (0-9).
o Identifier name must not contain any white-space, or special character (!, @, #, %, ^, &, *).
o Identifier name must not be similar to any keyword defined in the language.
6
o Identifier names are case sensitive; for example, my name, and MyName is not the same.
o Examples of valid identifiers: a123, _n, n_9, etc.
o Examples of invalid identifiers: 1a, n%4, n 9, etc.

Declaring Variable and Assigning Values

Python does not bind us to declare a variable before using it in the application. It allows us
to create a variable at the required time.

We don't need to declare explicitly variable in Python. When we assign any value to the
variable, that variable is declared automatically.

The equal (=) operator is used to assign value to a variable.

Object References

It is necessary to understand how the Python interpreter works when we declare a variable.
The process of treating variables is somewhat different from many other programming
languages.

Python is the highly object-oriented programming language; that's why every data item
belongs to a specific type of class. Consider the following example.

1. print("John")

Output:

John

The Python object creates an integer object and displays it to the console. In the above print
statement, we have created a string object. Let's check the type of it using the Python built-
in type() function.

1. type("John")

7
Output:

<class 'str'>

In Python, variables are a symbolic name that is a reference or pointer to an object. The
variables are used to denote objects by that name.

Let's understand the following example

1. a = 50

In the above image, the variable a refers to an integer object.

Suppose we assign the integer value 50 to a new variable b.

a = 50

b=a

The variable b refers to the same object that a points to because Python does not create
another object.

Let's assign the new value to b. Now both variables will refer to the different objects.

a = 50

b =100
8
Python manages memory efficiently if we assign the same variable to two different values.

3.2 String

Till now, we have discussed numbers as the standard data-types in Python. In this section
of the tutorial, we will discuss the most popular data type in Python, i.e., string.

Python string is the collection of the characters surrounded by single quotes, double quotes,
or triple quotes. The computer does not understand the characters; internally, it stores
manipulated character as the combination of the 0's and 1's.

Each character is encoded in the ASCII or Unicode character. So we can say that Python
strings are also called the collection of Unicode characters.

In Python, strings can be created by enclosing the character or the sequence of characters
in the quotes. Python allows us to use single quotes, double quotes, or triple quotes to create
the string.

Consider the following example in Python to create a string.

Syntax:

1. str = "Hi Python !"

Here, if we check the type of the variable str using a Python script
9
1. print(type(str)), then it will print a string (str).

In Python, strings are treated as the sequence of characters, which means that Python
doesn't support the character data-type; instead, a single character written as 'p' is treated
as the string of length.

Creating String in Python

We can create a string by enclosing the characters in single-quotes or double- quotes.


Python also provides triple-quotes to represent the string, but it is generally used for
multiline string or docstrings.

1. #Using single quotes


2. str1 = 'Hello Python'

3. print(str1)
4. #Using double quotes

5. str2 = "Hello Python"


6. print(str2)

7.
8. #Using triple quotes

9. str3 = '''''Triple quotes are generally used for


10. represent the multiline or

11. docstring'''
12. print(str3)

Output:

Hello Python

Hello Python

Triple quotes are generally used for

10
represent the multiline or

docstring

Deleting the String

As we know that strings are immutable. We cannot delete or remove the characters from
the string. But we can delete the entire string using the del keyword

1. str = "JAVATPOINT"
2. del str[1]

Output:

TypeError: 'str' object doesn't support item deletion

Now we are deleting entire string.

1. str1 = "JAVATPOINT"
2. del str1

3. print(str1)

Output:

NameError: name 'str1' is not defined

String Operators

11
3.3 Python operator.

The operator can be defined as a symbol which is responsible for a particular operation
between two operands. Operators are the pillars of a program on which the logic is built in
a specific programming language. Python provides a variety of operators, which are
described as follows.

o Arithmetic operators

12
o Comparison operators
o Assignment Operators
o Logical Operators
o Bitwise Operators
o Membership Operators
o Identity Operator

Arithmetic Operators

Arithmetic operators are used to perform arithmetic operations between two operands. It
includes + (addition), - (subtraction), *(multiplication), /(divide), %(reminder), //(floor
division), and exponent (**) operators. Consider the following table for a detailed
explanationofarithmeticoperators.

Comparison operator
13
Comparison operators are used to comparing the value of the two operands and returns
Boolean true or false accordingly. The comparison operators are described in the following
table.

Assignment Operators

The assignment operators are used to assign the value of the right expression to the left
operand. The assignment operators are described in the following table.

14
Bitwise Operators

The bitwise operators perform bit by bit operation on the values of the two operands.
Consider the following example.

For example,

1. if a = 7
2. b=6

3. then, binary (a) = 0111

15
4. binary (b) = 0110

5. hence, a & b = 0011


6. a | b = 0111
7. a ^ b = 0100

8. ~ a = 1000

Logical Operators

The logical operators are used primarily in the expression evaluation to make a decision.
Python supports the following logical operators.

16
Membership Operators

Python membership operators are used to check the membership of value inside a Python
data structure. If the value is present in the data structure, then the resulting value is true
otherwise it returns false.

Identity Operators

The identity operators are used to decide whether an element certain class or type.

Operator Precedence
17
The precedence of the operators is essential to find out since it enables us to know which operator
should be evaluated first. The precedence table of the operators in Python is given below.

18
4 TUPLE AND LISTS

4.1 TUPLE

A tuple is a collection of objects which ordered and immutable. Tuples are sequences,
just like lists. The differences between tuples and lists are, the tuples cannot be
changed unlike lists and tuples use parentheses, whereas lists use square brackets.

Creating a tuple is as simple as putting different comma-separated values. Optionally


you can put these comma-separated values between parentheses also. For example −
tup1 = ('physics', 'chemistry', 1997, 2000);
tup2 = (1, 2, 3, 4, 5 );
tup3 = "a", "b", "c", "d";
The empty tuple is written as two parentheses containing nothing −
tup1 = ();

To write a tuple containing a single value you have to include a comma, even though
there is only one value −
tup1 = (50,);

Like string indices, tuple indices start at 0, and they can be sliced, concatenated, and so
on.

Accessing Values in Tuples


To access values in tuple, use the square brackets for slicing along with the index or
indices to obtain value available at that index. For example

#!/usr/bin/python

tup1 = ('physics', 'chemistry', 1997, 2000);


tup2 = (1, 2, 3, 4, 5, 6, 7 );
print "tup1[0]: ", tup1[0];
print "tup2[1:5]: ", tup2[1:5];
19
When the above code is executed, it produces the following result −
tup1[0]: physics
tup2[1:5]: [2, 3, 4, 5]

Updating Tuples
Tuples are immutable which means you cannot update or change the values of tuple
elements. You are able to take portions of existing tuples to create new tuples as the
following example demonstrates −

#!/usr/bin/python

tup1 = (12, 34.56);


tup2 = ('abc', 'xyz');

# Following action is not valid for tuples


# tup1[0] = 100;

# So let's create a new tuple as follows


tup3 = tup1 + tup2;
print tup3;

When the above code is executed, it produces the following result −


(12, 34.56, 'abc', 'xyz')

Delete Tuple Elements


Removing individual tuple elements is not possible. There is, of course, nothing wrong
with putting together another tuple with the undesired elements discarded.

To explicitly remove an entire tuple, just use the del statement. For example −

20
#!/usr/bin/python

tup = ('physics', 'chemistry', 1997, 2000);


print tup;
del tup;
print "After deleting tup : ";
print tup;

This produces the following result. Note an exception raised, this is because after del
tup tuple does not exist any more −
('physics', 'chemistry', 1997, 2000)
After deleting tup :
Traceback (most recent call last):
File "test.py", line 9, in <module>
print tup;
NameError: name 'tup' is not defined

Basic Tuples Operations


Tuples respond to the + and * operators much like strings; they mean concatenation and
repetition here too, except that the result is a new tuple, not a string.

In fact, tuples respond to all of the general sequence operations we used on strings in
the prior chapter

Indexing, Slicing, and Matrixes


Because tuples are sequences, indexing and slicing work the same way for tuples as
they do for strings. Assuming following input −

L = ('spam', 'Spam', 'SPAM!')

21
No Enclosing Delimiters
Any set of multiple objects, comma-separated, written without identifying symbols, i.e.,
brackets for lists, parentheses for tuples, etc., default to tuples, as indicated in these
short examples −

#!/usr/bin/python

print 'abc', -4.24e93, 18+6.6j, 'xyz';


x, y = 1, 2;
print "Value of x , y : ", x,y;

When the above code is executed, it produces the following result −


abc -4.24e+93 (18+6.6j) xyz
Value of x , y : 1 2

Built-in Tuple Functions


Python includes the following tuple functions −

Sr.No. Function with Description

1 cmp(tuple1, tuple2)

Compares elements of both tuples.

2 len(tuple)

Gives the total length of the tuple.

3 max(tuple)

Returns item from the tuple with max value.

4 min(tuple)

22
Returns item from the tuple with min value.

5 tuple(seq)

Converts a list into tuple.

4.2 LISTS
The most basic data structure in Python is the sequence. Each element of a sequence is
assigned a number - its position or index. The first index is zero, the second index is one,
and so forth.

Python has six built-in types of sequences, but the most common ones are lists and
tuples, which we would see in this tutorial.

There are certain things you can do with all sequence types. These operations include
indexing, slicing, adding, multiplying, and checking for membership. In addition, Python
has built-in functions for finding the length of a sequence and for finding its largest and
smallest elements.

Python Lists
The list is a most versatile datatype available in Python which can be written as a list of
comma-separated values (items) between square brackets. Important thing about a list
is that items in a list need not be of the same type.

Creating a list is as simple as putting different comma-separated values between


square brackets. For example −
list1 = ['physics', 'chemistry', 1997, 2000];
list2 = [1, 2, 3, 4, 5 ];
list3 = ["a", "b", "c", "d"]
Similar to string indices, list indices start at 0, and lists can be sliced, concatenated and
so on.

23
Accessing Values in Lists
To access values in lists, use the square brackets for slicing along with the index or
indices to obtain value available at that index. For example

#!/usr/bin/python

list1 = ['physics', 'chemistry', 1997, 2000];


list2 = [1, 2, 3, 4, 5, 6, 7 ];
print "list1[0]: ", list1[0]
print "list2[1:5]: ", list2[1:5]

When the above code is executed, it produces the following result −


list1[0]: physics
list2[1:5]: [2, 3, 4, 5]

Updating Lists
You can update single or multiple elements of lists by giving the slice on the left-hand
side of the assignment operator, and you can add to elements in a list with the append()
method. For example −

#!/usr/bin/python

list = ['physics', 'chemistry', 1997, 2000];


print "Value available at index 2 : "
print list[2]
list[2] = 2001;
print "New value available at index 2 : "
print list[2]

Note − append() method is discussed in subsequent section.

24
When the above code is executed, it produces the following result −
Value available at index 2 :
1997
New value available at index 2 :
2001

Delete List Elements


To remove a list element, you can use either the del statement if you know exactly which
element(s) you are deleting or the remove() method if you do not know. For example −

#!/usr/bin/python

list1 = ['physics', 'chemistry', 1997, 2000];


print list1
del list1[2];
print "After deleting value at index 2 : "
print list1

When the above code is executed, it produces following result −


['physics', 'chemistry', 1997, 2000]
After deleting value at index 2 :
['physics', 'chemistry', 2000]
Note − remove() method is discussed in subsequent section.

Basic List Operations


Lists respond to the + and * operators much like strings; they mean concatenation and
repetition here too, except that the result is a new list, not a string.

In fact, lists respond to all of the general sequence operations we used on strings in the
prior chapter.

25
Indexing, Slicing, and Matrixes
Because lists are sequences, indexing and slicing work the same way for lists as they
do for strings.

Assuming following input −


L = ['spam', 'Spam', 'SPAM!']

Built-in List Functions & Methods


Python includes the following list functions −

Sr.No. Function with Description

1 cmp(list1, list2)

Compares elements of both lists.

2 len(list)

Gives the total length of the list.

3 max(list)

Returns item from the list with max value.

4 min(list)

Returns item from the list with min value.

5 list(seq)

Converts a tuple into list.

26
Python includes following list methods

Sr.No. Methods with Description

1 list.append(obj)

Appends object obj to list

2 list.count(obj)

Returns count of how many times obj occurs in list

3 list.extend(seq)

Appends the contents of seq to list

4 list.index(obj)

Returns the lowest index in list that obj appears

5 list.insert(index, obj)

Inserts object obj into list at offset index

6 list.pop(obj=list[-1])

Removes and returns last object or obj from list

7 list.remove(obj)

Removes object obj from list

8 list.reverse()

27
Reverses objects of list in place

9 list.sort([func])

Sorts objects of list, use compare func if given

4.3 DICTIONARY

Each key is separated from its value by a colon (:), the items are separated by commas,
and the whole thing is enclosed in curly braces. An empty dictionary without any items
is written with just two curly braces, like this: {}.

Keys are unique within a dictionary while values may not be. The values of a dictionary
can be of any type, but the keys must be of an immutable data type such as strings,
numbers, or tuples.

Accessing Values in Dictionary


To access dictionary elements, you can use the familiar square brackets along with the
key to obtain its value. Following is a simple example −

#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}


print "dict['Name']: ", dict['Name']
print "dict['Age']: ", dict['Age']

When the above code is executed, it produces the following result −


dict['Name']: Zara
dict['Age']: 7

If we attempt to access a data item with a key, which is not part of the dictionary, we
get an error as follows −

28
#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}


print "dict['Alice']: ", dict['Alice']

When the above code is executed, it produces the following result −


dict['Alice']:
Traceback (most recent call last):
File "test.py", line 4, in <module>
print "dict['Alice']: ", dict['Alice'];
KeyError: 'Alice'

Updating Dictionary
You can update a dictionary by adding a new entry or a key-value pair, modifying an
existing entry, or deleting an existing entry as shown below in the simple example

#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}


dict['Age'] = 8; # update existing entry
dict['School'] = "DPS School"; # Add new entry

print "dict['Age']: ", dict['Age']


print "dict['School']: ", dict['School']

When the above code is executed, it produces the following result −


dict['Age']: 8
dict['School']: DPS School

Delete Dictionary Elements

29
You can either remove individual dictionary elements or clear the entire contents of a
dictionary. You can also delete entire dictionary in a single operation.

To explicitly remove an entire dictionary, just use the del statement. Following is a
simple example −

#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}


del dict['Name']; # remove entry with key 'Name'
dict.clear(); # remove all entries in dict
del dict ; # delete entire dictionary

print "dict['Age']: ", dict['Age']


print "dict['School']: ", dict['School']

This produces the following result. Note that an exception is raised because after del
dict dictionary does not exist any more −
dict['Age']:
Traceback (most recent call last):
File "test.py", line 8, in <module>
print "dict['Age']: ", dict['Age'];
TypeError: 'type' object is unsubscriptable

Note − del() method is discussed in subsequent section.

Properties of Dictionary Keys


Dictionary values have no restrictions. They can be any arbitrary Python object, either
standard objects or user-defined objects. However, same is not true for the keys.

There are two important points to remember about dictionary keys −

30
(a) More than one entry per key not allowed. Which means no duplicate key is allowed.
When duplicate keys encountered during assignment, the last assignment wins. For
example −

#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7, 'Name': 'Manni'}


print "dict['Name']: ", dict['Name']

When the above code is executed, it produces the following result −


dict['Name']: Manni

(b) Keys must be immutable. Which means you can use strings, numbers or tuples as
dictionary keys but something like ['key'] is not allowed. Following is a simple example

#!/usr/bin/python

dict = {['Name']: 'Zara', 'Age': 7}


print "dict['Name']: ", dict['Name']

When the above code is executed, it produces the following result −


Traceback (most recent call last):
File "test.py", line 3, in <module>
dict = {['Name']: 'Zara', 'Age': 7};
TypeError: unhashable type: 'list'

Built-in Dictionary Functions & Methods


Python includes the following dictionary functions −

31
E Function with Description

1 cmp(dict1, dict2)

Compares elements of both dict.

2 len(dict)

Gives the total length of the dictionary. This would be equal to the number
of items in the dictionary.

3 str(dict)

Produces a printable string representation of a dictionary

4 type(variable)

Returns the type of the passed variable. If passed variable is dictionary, then
it would return a dictionary type.

Python includes following dictionary methods −

Sr.No. Methods with Description

1 dict.clear()

Removes all elements of dictionary dict

2 dict.copy()

Returns a shallow copy of dictionary dict

3 dict.fromkeys()

Create a new dictionary with keys from seq and values set to value.

32
4 dict.get(key, default=None)

For key key, returns value or default if key not in dictionary

5 dict.has_key(key)

Returns true if key in dictionary dict, false otherwise

6 dict.items()

Returns a list of dict's (key, value) tuple pairs

7 dict.keys()

Returns list of dictionary dict's keys

8 dict.setdefault(key, default=None)

Similar to get(), but will set dict[key]=default if key is not already in dict

9 dict.update(dict2)

Adds dictionary dict2's key-values pairs to dict

10 dict.values()

Returns list of dictionary dict's values

33
5 LOOP &CONDITIONAL STATEMENTS

5.1 LOOPS

In general, statements are executed sequentially: The first statement in a function is


executed first, followed by the second, and so on. There may be a situation when you
need to execute a block of code several number of times.

Programming languages provide various control structures that allow for more
complicated execution paths.

A loop statement allows us to execute a statement or group of statements multiple


times. The following diagram illustrates a loop statement −

Python programming language provides following types of loops to handle looping


requirements.

Sr.No. Loop Type & Description

34
1 while loop

Repeats a statement or group of statements while a given condition is


TRUE. It tests the condition before executing the loop body.

2 for loop

Executes a sequence of statements multiple times and abbreviates the


code that manages the loop variable.

3 nested loops

You can use one or more loop inside any another while, for or do..while
loop.

Loop Control Statements


Loop control statements change execution from its normal sequence. When execution
leaves a scope, all automatic objects that were created in that scope are destroyed.

Python supports the following control statements. Click the following links to check
their detail.

Let us go through the loop control statements briefly

Sr.No. Control Statement & Description

1 break statement

Terminates the loop statement and transfers execution to the statement immediately
following the loop.

2 continue statement

35
Causes the loop to skip the remainder of its body and immediately retest its condition
prior to reiterating.

3 pass statement

The pass statement in Python is used when a statement is required syntactically but
you do not want any command or code to execute.

5.2 CONDITIOONAL STATEMENTS

An else statement can be combined with an if statement. An else statement contains


the block of code that executes if the conditional expression in the if statement resolves
to 0 or a FALSE value.

The else statement is an optional statement and there could be at most only
one else statement following if.

Syntax
The syntax of the if...else statement is −
if expression:
statement(s)
else:
statement(s)

Flow Diagram

36
Example

#!/usr/bin/python

var1 = 100
if var1:
print "1 - Got a true expression value"
print var1
else:
print "1 - Got a false expression value"
print var1

var2 = 0
if var2:
print "2 - Got a true expression value"
37
print var2
else:
print "2 - Got a false expression value"
print var2

print "Good bye!"

When the above code is executed, it produces the following result −


1 - Got a true expression value
100
2 - Got a false expression value
0
Good bye!

The elif Statement


The elif statement allows you to check multiple expressions for TRUE and execute a
block of code as soon as one of the conditions evaluates to TRUE.

Similar to the else, the elif statement is optional. However, unlike else, for which there
can be at most one statement, there can be an arbitrary number of elif statements
following an if.

syntax
if expression1:
statement(s)
elif expression2:
statement(s)
elif expression3:
statement(s)
else:

38
statement(s)

Core Python does not provide switch or case statements as in other languages, but we
can use if..elif...statements to simulate switch case as follows −

Example
#!/usr/bin/python

var = 100
if var == 200:
print "1 - Got a true expression value"
print var
elif var == 150:
print "2 - Got a true expression value"
print var
elif var == 100:
print "3 - Got a true expression value"
print var
else:
print "4 - Got a false expression value"
print var

print "Good bye!"

When the above code is executed, it produces the following result −


3 - Got a true expression value
100
Good bye!

5.3 FUNCTION
39
A function is a block of organized, reusable code that is used to perform a single, related
action. Functions provide better modularity for your application and a high degree of
code reusing.

As you already know, Python gives you many built-in functions like print(), etc. but you
can also create your own functions. These functions are called user-defined functions.

Defining a Function
You can define functions to provide the required functionality. Here are simple rules to
define a function in Python.

• Function blocks begin with the keyword def followed by the function name
and parentheses ( ( ) ).
• Any input parameters or arguments should be placed within these
parentheses. You can also define parameters inside these parentheses.
• The first statement of a function can be an optional statement - the
documentation string of the function or docstring.
• The code block within every function starts with a colon (:) and is indented.
• The statement return [expression] exits a function, optionally passing back
an expression to the caller. A return statement with no arguments is the
same as return None.
Syntax
def functionname( parameters ):
"function_docstring"
function_suite
return [expression]

By default, parameters have a positional behavior and you need to inform them in the
same order that they were defined.

Example

40
The following function takes a string as input parameter and prints it on standard
screen.

def printme( str ):


"This prints a passed string into this function"
print str
return

Calling a Function
Defining a function only gives it a name, specifies the parameters that are to be included
in the function and structures the blocks of code.

Once the basic structure of a function is finalized, you can execute it by calling it from
another function or directly from the Python prompt. Following is the example to call
printme() function −

#!/usr/bin/python

# Function definition is here


def printme( str ):
"This prints a passed string into this function"
print str
return;

# Now you can call printme function


printme("I'm first call to user defined function!")
printme("Again second call to the same function")

When the above code is executed, it produces the following result −


I'm first call to user defined function!

41
Again second call to the same function

Pass by reference vs value


All parameters (arguments) in the Python language are passed by reference. It means
if you change what a parameter refers to within a function, the change also reflects back
in the calling function. For example −

#!/usr/bin/python

# Function definition is here


def changeme( mylist ):
"This changes a passed list into this function"
mylist.append([1,2,3,4]);
print "Values inside the function: ", mylist
return

# Now you can call changeme function


mylist = [10,20,30];
changeme( mylist );
print "Values outside the function: ", mylist

Here, we are maintaining reference of the passed object and appending values in the
same object. So, this would produce the following result −
Values inside the function: [10, 20, 30, [1, 2, 3, 4]]
Values outside the function: [10, 20, 30, [1, 2, 3, 4]]
There is one more example where argument is being passed by reference and the
reference is being overwritten inside the called function.

42
#!/usr/bin/python

# Function definition is here


def changeme( mylist ):
"This changes a passed list into this function"
mylist = [1,2,3,4]; # This would assig new reference in mylist
print "Values inside the function: ", mylist
return

# Now you can call changeme function


mylist = [10,20,30];
changeme( mylist );
print "Values outside the function: ", mylist

The parameter mylist is local to the function changeme. Changing mylist within the
function does not affect mylist. The function accomplishes nothing and finally this
would produce the following result −
Values inside the function: [1, 2, 3, 4]
Values outside the function: [10, 20, 30]

Function Arguments
You can call a function by using the following types of formal arguments −

• Required arguments

• Keyword arguments

• Default arguments

• Variable-length arguments

43
Required arguments
Required arguments are the arguments passed to a function in correct positional order.
Here, the number of arguments in the function call should match exactly with the
function definition.

To call the function printme(), you definitely need to pass one argument, otherwise it
gives a syntax error as follows −

Keyword arguments
Keyword arguments are related to the function calls. When you use keyword arguments
in a function call, the caller identifies the arguments by the parameter name.

This allows you to skip arguments or place them out of order because the Python
interpreter is able to use the keywords provided to match the values with parameters.
You can also make keyword calls to the printme() function in the following ways −

#!/usr/bin/python

# Function definition is here


def printme( str ):
"This prints a passed string into this function"
print str
return;

# Now you can call printme function


printme( str = "My string")

When the above code is executed, it produces the following result −


My string

44
The following example gives more clear picture. Note that the order of parameters does
not matter.

#!/usr/bin/python

# Function definition is here


def printinfo( name, age ):
"This prints a passed info into this function"
print "Name: ", name
print "Age ", age
return;

# Now you can call printinfo function


printinfo( age=50, name="miki" )

When the above code is executed, it produces the following result −


Name: miki
Age 50

Default arguments
A default argument is an argument that assumes a default value if a value is not
provided in the function call for that argument. The following example gives an idea on
default arguments, it prints default age if it is not passed −

#!/usr/bin/python

# Function definition is here


def printinfo( name, age = 35 ):
"This prints a passed info into this function"
print "Name: ", name

45
print "Age ", age
return;

# Now you can call printinfo function


printinfo( age=50, name="miki" )
printinfo( name="miki" )

When the above code is executed, it produces the following result −


Name: miki
Age 50
Name: miki
Age 35
Variable-length arguments
You may need to process a function for more arguments than you specified while
defining the function. These arguments are called variable-length arguments and are
not named in the function definition, unlike required and default arguments.

Syntax for a function with non-keyword variable arguments is this −


def functionname([formal_args,] *var_args_tuple ):
"function_docstring"
function_suite
return [expression]

An asterisk (*) is placed before the variable name that holds the values of all
nonkeyword variable arguments. This tuple remains empty if no additional arguments
are specified during the function call. Following is a simple example −

#!/usr/bin/python

46
# Function definition is here
def printinfo( arg1, *vartuple ):
"This prints a variable passed arguments"
print "Output is: "
print arg1
for var in vartuple:
print var
return;

# Now you can call printinfo function


printinfo( 10 )
printinfo( 70, 60, 50 )

When the above code is executed, it produces the following result −


Output is:
10
Output is:
70
60
50

The return Statement


The statement return [expression] exits a function, optionally passing back an
expression to the caller. A return statement with no arguments is the same as return
None.

All the above examples are not returning any value. You can return a value from a
function as follows −

#!/usr/bin/python

47
# Function definition is here
def sum( arg1, arg2 ):
# Add both the parameters and return them."
total = arg1 + arg2
print "Inside the function : ", total
return total;

# Now you can call sum function


total = sum( 10, 20 );
print "Outside the function : ", total

48
7. INDUSTRIAL TRAINING WORK UNDERTAKEN

This Chapter involves detailed introduction about overview of project,


literature survey, software and hardware requirements of the project.

3.1 Overview of Project

Hotel management system is a Real time management system made with the
help of tkinter library of python that can be used by any to hotel to manage its
all the services. The main purpose behind creating this project to help

the hotel in managing all the activities in hotel like reserve a room and to
manage the staff and check the availability of the room . A hotel always have
to take care of all its services which is not possible manually. It is very difficult
to keep the things on check. So this project helps in managing all the services

49
related to hotel . [11:15, 12/3/2022] Ankit Aryan: Hotel Management System
is an easy script that is created in Python programming language, This system
teaches you how you can manage a hotel, restaurant, etc. So let’s begin; This
Script has 5 modules-

The first one is the main module which is used to control all the other modules
given in the script.

Second one is the “Customer Information” module which displayes the data
or the information of the customer.

Third one is the “Food Purchased” module which displayes the list of food
items that was ordered by the customer.

Fourth one is the “Room Rent” module which displayes the type of room is to
rent by the customer .

Fifth and the last one is the “Hotel Bill” module which is this module
displayed the total purchased of the customer.

Now, let’s see the coding part of the “hotel management system project using
python with source code”.

At last, after all these calculations the user can know about their total cost of
staying easily. In this feature, the system provides his/her details, with the
room number, room rent, food, laundry and games bill. The total sum is
displayed to the users with some additional charges. This simple console
based Hotel Management system provides the simplest management of hotel
service and transaction. In short, this projects mainly focus on adding and

50
calculating results. There’s no external database connection file used in this
mini project to save user’s data permanently.

3.3 Software Requirements

The general concept of feasibility is associated with projects of all kinds


(housing, marketing, ecological, scientific, industrial, and specifically bound
to an engineering approach to project development. Whenever a project of
any kind is to be carried out systematically, through careful consideration
and - wherever possible - measurement of the parameters involved, a
feasibility study becomes an integral part of the project work. In the field of
software development, due mainly to conceptual difficulties in identifying
the right parameters to measure, this engineering approach has been slow to
take hold. python, as a related sub-field, has suffered from the same problem.
An important question to be taken into account is that a feasibility study
should be relatively cheap and quick, and it should inform the decision of
whether to go ahead with a more detailed analysis

The input to a feasibility study is an outline description of the system and


how it will be used within an organization, and the result should be a report
that recommends whether or not it is worth carrying on with the
development of the project.

The necessary software specifications are divided into two sections


which are written below

Requirements for the development:

This whole project is built using the Windows 10 operation system and the
coding part is done on visual studio code which provides lot of features and
faster development tools. This software is widely used for developing web
projects as it has lot of extensions like syntax highlighter, auto correction,
51
and intelligence also. During development only we have to install python 3.6
version and import the library of python tkinter and visual studio code.

Requirements for the user:

There are no memory requirements. The computers must be equipped with


web browsers such as Internet explorer or chrome. There must be internet
connection. The product must be stored in such a way that allows the client
easy access to it. Response time for loading the product should take no longer
than five minutes. A general knowledge of basic computer skills is required
to use the product

3.4 Hardware Requirements

The following t lists the minimum and recommended hardware requirements


for this Python development project. This project is build using all the
hardware specification shown in the recommended section below.

Minimum Requirements

• Processor should be of 1.9 gigahertz (GHz) x86- or x64-bit dual


core processor with SSE2 instruction set

• A 2-GB RAM

• Display should be Super VGA with a resolution of 1024 x 768

Recommended Requirements

• 3.3 gigahertz (GHz) or faster 64-bit dual core processor with SSE2 instruction set

• 4-GB RAM or more

• Super VGA with a resolution of 1024 x 768

52
Running model-driven apps on a computer that has less than the
recommended requirements may result in inadequate performance.
Additionally, satisfactory

performance may be experienced running systems that use a different


hardware configuration than those published here—for example, a system
with a modern quad-core processor, lower clock speed, and more RAM.

A development environment in software and Python development is a


workspace for developers to make changes without breaking anything in a
live environment.

It is the software suite used by developers and is designed to maximize


productivity and efficiency for the developer.

An integrated development environment is the software suite used by


developers in a development environment and is designed to maximize
productivity and efficiency for the developer.

The IDE often consists of a source code editor, debugger, compiler, and
designer, which all are accessed through a single interface. On top of that
different IDEs offer features such as auto code completion and syntax
highlighting to speed up the development process. Combining all of these
tools in one software application enables the developer to complete multiple
different tasks in one interface while identifying and minimizing coding
mistakes and typos on the fly.

An integrated development environment must be compatible with the


programming language that is used for the website being produced.

Visual Studio Code text editor is used for creating the whole project
because it allows us to write code more and more fast with lot of
helping and awesome extension
53
6 PROJECT WORK

This Chapter involves detailed introduction about major project problem, objectives,
Methodology and flow charts. The whole information about the working and practical
implementation of the website including the system design with all the flowchart are shown
below

6.1 Major Project Problems

The development landscape is continuously evolving to satisfy the ever-changing market


demands. Business owners are now creating value-driven solutions that generate positive
experiences. However, we cannot deny the fact that ensuring top-notch quality across user
interactions is not an easy task. The aim of proposed system is to develop a system of
improved facilites the proposed system can overcome all the limitation of the existing
system .The system provides proper security and reduces the manual work.

• 6.2 Objectives

At last, after all these calculations the user can know about their total cost of staying, Food
eaten, and also including extra activities such as laundry bills, Game bills very easily. In this
feature, the system provides his/her details such as name, address, mobile no. , etc. Along
with her/his Room number, Room rent, Food was eaten, laundry, and games bill too. The
total sum is displayed to the users with some additional charges like tips given etc. This
simple console-based Hotel Management system project in Python provides the effective
and easy management of hotel service and transactions. In short, this article mainly focuses
on saving time as well as money by simply calculating the bill amount on the basis of user
expenditures. There’s no external database file used in this mini project to save users’ data
permanently but you can use it if you want to.

54
In order to run the Program/Script make sure you have installed Python on your PC. This is
a simple Console Based system, specially written for beginners and when you learn it
completely you can add more modules manually based on your business.

Project title “Hotel Management” (a project for keeping customers record and also calculate
customer bill slip and managers salary) The name of project is “Hotel Management”. The
objective of the project is to computerize the system of the hotel. “Hotel Management” is the
project not only keeps the record of various people like customers, manager etc. but as well as it
reduces the extensive paper work in the present system. It wills maker the system more versatile
and user friendly. It also calculates the proper billing slip of high level and middle level
customers. This project is based on description about the structure of HOTEL MANAGEMENT
SYSTEM .The project contains:

Keeping the record of all persons like customers, managers etc.

Maintains proper list of all persons.

Generating proper bill slip and calculate managers salary

Many economists have often described ‘Hotel Business’ as unique and different from much
other business. Hotel is selling both goods and services. It not only provides both tangible
intangible services, but one of its unusual characteristic is also that it is one of the very few
places where production and consumption occur simultaneously; for example, ordering
subsequent preparation,services and consumption of food items.Both the products and services
are offered on credit transaction .no other business allows the customer an immediate line of
credit, for example, the moment he registers ,his credit purchase starts with the room and a
sequence of financial charges throughout the facilities without immediately paying for them at
the ‘point of purchase’. For example, purchase of food in restaurant, drinks in bar valet
services,etc. no other business offers as varied a range of services and products at the same place
as hotel business. Each hotel must offer lodging, food and protection to their guest and assume a
liability for guest property, provide a high standard of hygiene, cleanliness and sanitation and

55
should confirm to the minimum requirements of the state regarding safe hotel construction such
as height of building, municipal-by-laws, fire and safety standard so no

6.3 Methodology and Flowcharts

Firstly, we will be doing the requirement and analysis part of the


development cycle, in which we will find out our project’s final goals and
what will get in the long run. Then, we will move onto the designing phase
of the cycle which will be deciding the designing and look of it. Then we’ll
deep dive into the implementation part which consists of Python
development. We’ll first start from the back-end of the project with the help
of the python and try to build the minimum valued product first which will
set the base of our working project and then we will add other backlogs of
the product and try to develop in their spring.

56
Fig 6.3.1 (Hotel Management flow charts)

57
Start

Login

Search

Check If Confirm
available Booking
Room

store
information

End Process

58
Fig 6.3.2 ( Methodlogy and flowcharts)

CODE

Fig 6.4.1 (CODE )

59
Fig 6.4.2(CODE)

60
7. RESULT AND DESICUSSION

Python development does not about ―know it all, it’s about being able to
adapt your knowledge to project requirements. There is a fast track to
becoming good in this industry; the road to success is paved with hard work,
dedication, talent, and enough learning material. Sometimes it happens that
the rooms get booked soon when one visits the place therefore user can make
advance booking using this system. It saves user time in search of rooms.
The system is useful as it calculates an exact cost for requested number of
days. It saves organization resources and expenses. This system is effective
and saves time and cost of users. Easy registration.

7.1 Screen

shots of Running Project

. Fig 7.1.1( shots of running project)

61
Fig 7.1.2 (shots of runing project)

62
CONCLUSION AND FUTURE SCOPE

The entire project has been developed and deployed as per the requirements stated by the

user, it is found to be bug free as per the testing standards that are implemented. Any

specification untraced errors will be concentrated in the coming versions, which are planned to

be developed in near future.The system at present does not take care of the money payment

methods, as the consolidated constructs need SSL standards and are critically to be initiated in

the first face, the application of the credit card transactions is applied as a developmental phase

in the coming

days. The system needs more elaborative technicality for its inception and evolution. At last,

after all these calculations the user can know about their total cost of staying easily. In this

feature, the system provides his/her details, with the room number, room rent, food, laundry and

games bill. The total sum is displayed to the users with some additional charges. This simple

console based Hotel Management system provides the simplest management of hotel service

and transaction. In short, this projects mainly focus on adding and calculating results. There’s no

external database connection file used in this mini project to save user’s data permanently

63
FUTURE SCOPES

One can also join this course because of its large scope in other countries also. Students wish to

do this course to make their career in abroad countries. With the increasing globalization, the

hotel chain is also increasing widely.

In hotel management and catering field, one can achieve a long term career in life.It is very

demanding profession in abroad. Through this course, you can join government and non-

government sectors.

There are a large number of degree/diploma/certificate courses which many institutes offer. You

can have a look at this link. It is very important to keep in mind the institute from where you are

pursuing these courses and the placement opportunities they provide. The Hotel management

Industry is not looking for scholars, but is looking for professionals who are smart and have

extremely great interpersonal and communication skills. Look for an institute which will garner

these ski

64
REFERENCES
[1]. Python GUI Programming with Tkinter: Develop responsive and powerful GUI
applications with Tkinter AD Moore.Python
and Tkinter programming John Grayson Manning publications Co. Greenwich, 2000
[2]. T. Berners-Lee, Web Issues, 1998.
[3]. Design and Implementation of Hotel Room Management System Wei Wei School of
Computer Science and Engineering,
Xi'an University of Technology.
[4]. V. DeBolt, Mastering Integrating python and tkinter, ISBN: 978-0-470-09754-0,
[5]. Python GUI Programming with Tkinter: Develop responsive and powerful GUI
applications with Tkinter AD Moore.Python
and Tkinter programming John Grayson Manning publications Co. Greenwich, 2000
[5]"Python Hotel Management System with Source Code" by CodeWithHarry: This is a
video tutorial that shows you how to create a hotel management system using Python
tkinter. The tutorial covers topics such as creating a GUI, connecting to a database, and
implementing various features.
[6] "Hotel Management System using Python Tkinter" by Programmers Point: This is a
tutorial that teaches you how to create a hotel management system using Python tkinter.
The tutorial includes features such as room booking, room availability, and room
management.
[7] Hotel Management System using ptyhon:. You can find the source code and tutorial
here: https://github.com/akashp1712/hotel-management-system-flask
[8] Automate the Boring Stuff with Python by Al Sweigart -
https://automatetheboringstuff.com/
[9] Python Weekly Newsletter - https://www.pythonweekly.com/
[10] Python.org - https://www.python.org/

65
66

You might also like