SlideShare a Scribd company logo
1 of 17
PRESENTATION ON PYTHON
SETH JAI PARKASH MUKAND LAL INSTITUTE OF ENGINEERING AND TECHNOLOGY, RADAUR
PRESENTED BY :
ABHISHEK
1220162
B.TECH (CSE) 2ND YEAR
INDEX :
 Introduction To Python
 Operators & Data Type
 Conditions & Loops
 Function & Exceptional Handling
 Classes & Inheritance
 Python Libraries
 Project On Python
 Queries
Introduction to Python
 Python is a popular programming language. It was
created by Guido van Rossum, and released in 1991.
 It is used for:
 Web Development (server-side),
 Software Development,
 Mathematics,
 System Scripting.
OPERATORS & DATA TYPES
OPERATORS :
 Arithmetic Operators
 Comparison (Relational) Operators
 Assignment Operators
 Logical Operators
 Bitwise Operators
 Membership Operators
 Identity Operators
DATA TYPES :
 Numbers
 String
 List
 Tuple
 Dictionary
Conditions & loops
 if statement : if statement is the most simple decision-making statement. It is
used to decide whether a certain statement or block of statements will be
executed or not .
 if-else : The if statement alone tells us that if a condition is true it will execute
a block of statements and if the condition is false it won’t. But what if we want
to do something else if the condition is false.
Python programming language provides following types of loops to handle
looping requirements.
 while loop : Repeats a statement or group of statements while a given
condition is TRUE. It tests the condition before executing the loop body.
 for loop: Executes a sequence of statements multiple times and abbreviates the
code that manages the loop variable.
 nested loops : We can use one or more loop inside any another while, for or
do..while loop.
FUNCTIONS AND EXCEPTION HANDLING
The try-expect statement
 If the Python program contains suspicious code that may throw the
exception, we must place that code in the try block.
 The try block must be followed with the except statement, which
contains a block of code that will be executed if there is some exception
in the try block.
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.
Calling a Function
 Call by Value
 Call by Reference
 Call by Address
Classes & inheritance
 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.
 To understand the meaning of classes we have to understand the built-in __init__()
function. All classes have a function called __init__(), which is always executed when
the class is being initiated. Use the __init__() function to assign values to object
properties, or other operations that are necessary to do when the object is being created.
 Inheritance allows us to define a class that inherits all the methods and properties from
another class. Parent class is the class being inherited from, also called base class. Child
class is the class that inherits from another class, also called derived class.
 Single Inheritance
 Multiple Inheritance
 Multilevel Inheritance
PYTHON LIBRARIES
NUMPY :
 NumPy is a Python library used for working with arrays.
 It also has functions for working in domain of linear algebra, fourier
transform, and matrices.
 NumPy was created in 2005 by Travis Oliphant. It is an open source
project and you can use it freely.
 NumPy stands for Numerical Python.
PANDAS :
 Pandas is a Python library used for working with data sets.
 It has functions for analyzing, cleaning, exploring, and manipulating data.
 Pandas allows us to analyze big data and make conclusions based on
statistical theories.
 The name "Pandas" has a reference to both "Panel Data", and "Python
Data Analysis" and was created by Wes McKinney in 2008.
Project
LIBRARY
In this project, We create a Library Class which includes
i). Display Book
ii). Lend Book
iii). Add Book
iv). Return Book
Create a Object and passing Parameters in the Constructors.
Create a main function and run an infinite while loop that asks the
users for their input whether they want to display,lend,add or return
the book.
Code :
class Library():
def __init__(self,list_of_books,library_name): #constructor
self.list_of_books = list_of_books
self.library_name = library_name
self.lend_dict = {}
def display_book(self): #display function display the list of
books
print(f"nWe Have Following Books In {self.library_name}")
for item in self.list_of_books:
print(item)
def lend_book(self,user,book): #lend function is for lending a
book from library
if book not in self.lend_dict.keys():
self.lend_dict.update({book:user})
print("Lender-Book database has been updated. You Can Take Your Book Now")
else:
print(f"Book is Already being used by {self.lend_dict[book]}")
def add_book(self,book): #add function is for adding a book in Library
self.list_of_books.append(book)
print("Book has been added to the book List")
def return_book(self,book): #return function is for return the book in library
self.lend_dict.pop(book)
if __name__ == '__main__': # main function starts
bookandname = Library(["LET US C", "DSA", "C++", "PYTHON", "JAVA"], "ABHISHEK'S LIBRARY")
while True:
print(f"nn..............WELCOME TO {bookandname.library_name}..............")
name = input("Enter Your Name : ")
print(f"nHii {name.capitalize()} Welcome to {bookandname.library_name}")
choose = int(input("nPress 1 to Display Bookn"
"Press 2 to Lend Bookn"
"Press 3 to Add Bookn"
"Press 4 To Return Book : "))
if choose == 1:
bookandname.display_book()
elif choose == 2:
book = input("Enter the name of book you want to lend : ")
user = input("Enter Your Name : ")
bookandname.lend_book(user,book)
elif choose == 3:
book = input("Enter the name of book you want to add : ")
bookandname.add_book(book)
elif choose == 4:
book = input("Enter the name of book you want to add : ")
bookandname.return_book(book)
else:
print("Please Enter Valid Number")
choice = input("nEnter Q to quit or C to Continue : ")
if choice == "Q":
exit()
elif choice == "C":
continue #while loop continue after entering C
else:
print("Enter Q or C only")
OUTPUT :
..............WELCOME TO ABHISHEK'S LIBRARY..............
Enter Your Name : Chirag
Hii Chirag Welcome to ABHISHEK'S LIBRARY
Press 1 to Display Book
Press 2 to Lend Book
Press 3 to Add Book
Press 4 To Return Book :
IF WE PRESS 1 THEN:
We Have Following Books In ABHISHEK'S LIBRARY:
LET US C
DSA
C++
PYTHON
JAVA
ANY QUERY????
THANK YOU!!

More Related Content

Similar to PRESENTATION ON PYTHON.pptx

pythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxpythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxRohitKumar639388
 
Standardizing arrays -- Microsoft Presentation
Standardizing arrays -- Microsoft PresentationStandardizing arrays -- Microsoft Presentation
Standardizing arrays -- Microsoft PresentationTravis Oliphant
 
Government Polytechnic Arvi-1.pptx
Government Polytechnic Arvi-1.pptxGovernment Polytechnic Arvi-1.pptx
Government Polytechnic Arvi-1.pptxShivamDenge
 
Interview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdfInterview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdfExaminationSectionMR
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonMohammed Rafi
 
Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experiencedzynofustechnology
 
Python Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & stylePython Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & styleKevlin Henney
 
presentation_intro_to_python
presentation_intro_to_pythonpresentation_intro_to_python
presentation_intro_to_pythongunanandJha2
 
presentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptpresentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptMohitChaudhary637683
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An IntroductionSwarit Wadhe
 
Introduction to Python Programming Language For Artificial Intelligence
Introduction to Python Programming Language For Artificial IntelligenceIntroduction to Python Programming Language For Artificial Intelligence
Introduction to Python Programming Language For Artificial Intelligencesaraahmed870035
 
Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizeIruolagbePius
 
20120314 changa-python-workshop
20120314 changa-python-workshop20120314 changa-python-workshop
20120314 changa-python-workshopamptiny
 
Python: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopersPython: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopersGlenn De Backer
 

Similar to PRESENTATION ON PYTHON.pptx (20)

PYTHON PPT.pptx
PYTHON PPT.pptxPYTHON PPT.pptx
PYTHON PPT.pptx
 
Shivam PPT.pptx
Shivam PPT.pptxShivam PPT.pptx
Shivam PPT.pptx
 
pythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxpythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptx
 
Standardizing arrays -- Microsoft Presentation
Standardizing arrays -- Microsoft PresentationStandardizing arrays -- Microsoft Presentation
Standardizing arrays -- Microsoft Presentation
 
Government Polytechnic Arvi-1.pptx
Government Polytechnic Arvi-1.pptxGovernment Polytechnic Arvi-1.pptx
Government Polytechnic Arvi-1.pptx
 
Interview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdfInterview-level-QA-on-Python-Programming.pdf
Interview-level-QA-on-Python-Programming.pdf
 
Python training
Python trainingPython training
Python training
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python Interview Questions For Experienced
Python Interview Questions For ExperiencedPython Interview Questions For Experienced
Python Interview Questions For Experienced
 
Python ppt
Python pptPython ppt
Python ppt
 
Python Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & stylePython Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & style
 
bhaskars.pptx
bhaskars.pptxbhaskars.pptx
bhaskars.pptx
 
presentation_intro_to_python
presentation_intro_to_pythonpresentation_intro_to_python
presentation_intro_to_python
 
presentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptpresentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.ppt
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An Introduction
 
Introduction to Python Programming Language For Artificial Intelligence
Introduction to Python Programming Language For Artificial IntelligenceIntroduction to Python Programming Language For Artificial Intelligence
Introduction to Python Programming Language For Artificial Intelligence
 
обзор Python
обзор Pythonобзор Python
обзор Python
 
Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualize
 
20120314 changa-python-workshop
20120314 changa-python-workshop20120314 changa-python-workshop
20120314 changa-python-workshop
 
Python: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopersPython: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopers
 

Recently uploaded

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

PRESENTATION ON PYTHON.pptx

  • 1. PRESENTATION ON PYTHON SETH JAI PARKASH MUKAND LAL INSTITUTE OF ENGINEERING AND TECHNOLOGY, RADAUR PRESENTED BY : ABHISHEK 1220162 B.TECH (CSE) 2ND YEAR
  • 2. INDEX :  Introduction To Python  Operators & Data Type  Conditions & Loops  Function & Exceptional Handling  Classes & Inheritance  Python Libraries  Project On Python  Queries
  • 3. Introduction to Python  Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.  It is used for:  Web Development (server-side),  Software Development,  Mathematics,  System Scripting.
  • 4. OPERATORS & DATA TYPES OPERATORS :  Arithmetic Operators  Comparison (Relational) Operators  Assignment Operators  Logical Operators  Bitwise Operators  Membership Operators  Identity Operators DATA TYPES :  Numbers  String  List  Tuple  Dictionary
  • 5. Conditions & loops  if statement : if statement is the most simple decision-making statement. It is used to decide whether a certain statement or block of statements will be executed or not .  if-else : The if statement alone tells us that if a condition is true it will execute a block of statements and if the condition is false it won’t. But what if we want to do something else if the condition is false. Python programming language provides following types of loops to handle looping requirements.  while loop : Repeats a statement or group of statements while a given condition is TRUE. It tests the condition before executing the loop body.  for loop: Executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.  nested loops : We can use one or more loop inside any another while, for or do..while loop.
  • 6. FUNCTIONS AND EXCEPTION HANDLING The try-expect statement  If the Python program contains suspicious code that may throw the exception, we must place that code in the try block.  The try block must be followed with the except statement, which contains a block of code that will be executed if there is some exception in the try block. 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. Calling a Function  Call by Value  Call by Reference  Call by Address
  • 7. Classes & inheritance  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.  To understand the meaning of classes we have to understand the built-in __init__() function. All classes have a function called __init__(), which is always executed when the class is being initiated. Use the __init__() function to assign values to object properties, or other operations that are necessary to do when the object is being created.  Inheritance allows us to define a class that inherits all the methods and properties from another class. Parent class is the class being inherited from, also called base class. Child class is the class that inherits from another class, also called derived class.  Single Inheritance  Multiple Inheritance  Multilevel Inheritance
  • 8. PYTHON LIBRARIES NUMPY :  NumPy is a Python library used for working with arrays.  It also has functions for working in domain of linear algebra, fourier transform, and matrices.  NumPy was created in 2005 by Travis Oliphant. It is an open source project and you can use it freely.  NumPy stands for Numerical Python. PANDAS :  Pandas is a Python library used for working with data sets.  It has functions for analyzing, cleaning, exploring, and manipulating data.  Pandas allows us to analyze big data and make conclusions based on statistical theories.  The name "Pandas" has a reference to both "Panel Data", and "Python Data Analysis" and was created by Wes McKinney in 2008.
  • 9. Project LIBRARY In this project, We create a Library Class which includes i). Display Book ii). Lend Book iii). Add Book iv). Return Book Create a Object and passing Parameters in the Constructors. Create a main function and run an infinite while loop that asks the users for their input whether they want to display,lend,add or return the book.
  • 10. Code : class Library(): def __init__(self,list_of_books,library_name): #constructor self.list_of_books = list_of_books self.library_name = library_name self.lend_dict = {} def display_book(self): #display function display the list of books print(f"nWe Have Following Books In {self.library_name}") for item in self.list_of_books: print(item) def lend_book(self,user,book): #lend function is for lending a book from library if book not in self.lend_dict.keys(): self.lend_dict.update({book:user}) print("Lender-Book database has been updated. You Can Take Your Book Now") else: print(f"Book is Already being used by {self.lend_dict[book]}")
  • 11. def add_book(self,book): #add function is for adding a book in Library self.list_of_books.append(book) print("Book has been added to the book List") def return_book(self,book): #return function is for return the book in library self.lend_dict.pop(book) if __name__ == '__main__': # main function starts bookandname = Library(["LET US C", "DSA", "C++", "PYTHON", "JAVA"], "ABHISHEK'S LIBRARY") while True: print(f"nn..............WELCOME TO {bookandname.library_name}..............") name = input("Enter Your Name : ") print(f"nHii {name.capitalize()} Welcome to {bookandname.library_name}")
  • 12. choose = int(input("nPress 1 to Display Bookn" "Press 2 to Lend Bookn" "Press 3 to Add Bookn" "Press 4 To Return Book : ")) if choose == 1: bookandname.display_book() elif choose == 2: book = input("Enter the name of book you want to lend : ") user = input("Enter Your Name : ") bookandname.lend_book(user,book) elif choose == 3: book = input("Enter the name of book you want to add : ") bookandname.add_book(book)
  • 13. elif choose == 4: book = input("Enter the name of book you want to add : ") bookandname.return_book(book) else: print("Please Enter Valid Number") choice = input("nEnter Q to quit or C to Continue : ") if choice == "Q": exit() elif choice == "C": continue #while loop continue after entering C else: print("Enter Q or C only")
  • 14. OUTPUT : ..............WELCOME TO ABHISHEK'S LIBRARY.............. Enter Your Name : Chirag Hii Chirag Welcome to ABHISHEK'S LIBRARY Press 1 to Display Book Press 2 to Lend Book Press 3 to Add Book Press 4 To Return Book :
  • 15. IF WE PRESS 1 THEN: We Have Following Books In ABHISHEK'S LIBRARY: LET US C DSA C++ PYTHON JAVA