Python Project | Python Library Management System Project - Full Tutorial#39

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys i hope you are doing well i am very excited for this session and this session is specifically designed for python project of library management system and guys using this project your all python will revise as we have discussed from the first session of our python series in this project we will design four modules so i am telling you the importance of each module in brief so first of all we will have display book so guys using this module user can show all the book which are part of our library and apart from that you will have the status of each book which is available or not fine and the second module will be issued user can issue any book by using this module and based on the book availability okay and system will have the details of that user like username and date and time of that particular book fine and the next module will be how we can add books okay so guys using this module user can add or donate the book to the library for that user will enter books title and system will generate the unique id against that book okay and the last module will be how we can return the book so guys using this module user can return the book based on the book id if that book issue to the user and system will update the database or you can say that update the status of book availability fine and guys one important note here in this particular project we will be use python classes python function file handling control structure and data structure with looping concept and other useful python system so guys whatever the concept and technique i will be writing here watch that carefully so that you can easily understand this project in greater details and this project we will do in the visual studio so let's go to the visual studio so guys i have opened my the visual studio now i need to create a file after that you need to save this file based on python extension so here i am going to type python lms and here you can select the extension which is python this one okay let me import few library which is import date time and import os okay so using the os we can check where we are working right now so how we can check os dot get cwd so you can run this so here as of now we are working in this particular folder fine and guys first let me show you the notepad file where we will have all available list of book in our library so this is the notepad file where i have some of the specific books name okay now i am creating a class let me close this class lms okay so guys when you are creating a class first of all you should define the docu string of that class okay so how we can define let's say here you can define this class is used to keep records of books library right and you can define a status what does that particular class so it has total four modules which is display book fine and issue book and return books and add books fine okay let me hide this mini map so alt v m okay now guys i'm going to create a constructor let's say def init and here i'm going to create some of the useful information so first of all we will have self and list of books and your library name right so let's say self dot list of books equal to so you can define the of that notepad file name which is list of books okay fine dot txt and after that you need to define your library name so self dot library name this one which is library so guys here i'm going to create a another variable which is books dictionary using this variable we can have all the information of my books like books title like lender name issue date and the status of that book fine and we will have also the id of book the id of book i am going to start by default from 1 0 1 ok we will have the concept of file handling so first of all how we can read the our notepad file so how we can read so simple with open self dot list of books okay and here i'm going to define elias name which is bk bk represent as a book and content equal to bk dot read lines this one fine so all the content will store in the content variable okay then how how we can read the each line so i will apply a loop on content how we can do that so for line and content and here i am going to show you only the line okay now let me intentionate our class so let's say print lms and here we need to define the list of books txt and the library name which is python library let me run this so guys you can see that we have read our file where i have some of the books okay so this is very simple concept fine now let me remove this so what i will do so using this line i will update my the books dictionary how we can update so self dot books dictionary dot update okay so this is nothing this is the concept of your python dictionary data structure which is update okay so let me give you the example how we can update our dictionary so let me create another file and let me save as a test so guys here what i'm doing i'm taking a variable which is d and here i am going to assign some of the dictionary keys and values and i want to update my dictionary using some different keys and values so you can see that in my the original dictionary i have 1 and 2 and they are values which is 2 and 4 respectively and using the second line i am going to update my dictionary so the original value was 2 but i am going to overwrite the value which is 2 by 5 and here the 2 and 4 is already available so i'm not going to do anything and here i'm going to add which is another key and values okay now let me print the d and let me run this i have update my dictionary right so the original value was 2 but i have updated by 5 so you can see 1 and their value 5 the 2 and 4 i'm not doing anything so it will remain same and here i'm going to assign another key and value which is seven in line i hope you understood how we can update our dictionary okay so now let's go to the our project so guys what i want first of all i will have my the id which is let me convert our id into the string so str and our id fine and here i am going to update some of the information which is first of all i want book titles which is let's say books title what can i do for the book titles so simple whatever the line i am reading dot replace replace so the slice n i'm going to replace by the blank okay so because when you are reading each line so we will have slice n right okay so that's less n i am going to replace by the blank fine now then we will have lender name vendor name which is also blank because we are not assigning any lender name here and here we are defining issue date so as of now there is no issue date so it it has to be blank and the status which is also by default available fine and after that what we are doing id equal to id plus 1 okay now let me show you the books dictionary so how we can show that so we need to create another function let's say d e f display books and i'm doing some kind of formatting just list of books so what we want first of all we want book id and here i'm going to provide another tab which is celesti and i want title this one okay now once again print kind of formatting and guys we need to assign a loop over the book's dictionary okay so how we can do that so i want key of the dictionary and i want the value of dictionary in self dot books dictionary dot items fine simple i am going to assign a loop over the dictionary so what i want i want the key it means i want that particular books key and after that i am going to assign two times of celeste and slash t and the value dot get okay i want books title and let me do some kind of formatting here once again this one and value dot get so do you know what does get so using the get we can get the keys value the keys is here i have defined which is status and a comma and we need to close this one and now let me intentionate the our class so we can have l equal to this one and now print l dot display books okay now let me run this okay some intent problem so guys you can see that so we have this one books id and their title and the status is available because as of now our book has not issued to anyone fine so we have covered our one module which is how we can display our available books from our database okay now the question is how we can issue our books so once again we need to create another module which is gef issue books and self so guys when you are going to issue any book so what we want we want the books id so based on the books id we can assign a book to someone fine so let me take a variable which is books id equal to input enter books id okay and i'm going to take a current date as well so how we can do that datetime.datetime dot now and we are using the strf time and here i am going to assign a specific format so i want century i want month i want that particular day and i want that particular time as well and second fine so first of all we need to check that particular id we are exist in our database or not okay so how we can check let's say if our books id is available in self dot books dictionary in keys fine because we have defined our id as a key right so that's why we are checking that particular id is available or not fine so guys in case that particular book id is exist in our dictionary then what will happen before issuing that book to someone we need to check that particular book status is available or not in case that status is not available it means that book is already issued to someone fine so how we can check if not self dot books dictionary and here we need to define books id and status this one if that status is equal to equal to available on let me do in double quotes now print i am using here affesting concept so let's say this book is already issued to self dot books dictionary this one and book id and here you can define the lender name lander name fine so guys once you define your lender name after that we need to also define here the that particular date on which date that particular book is assigned to someone so how we can check let me close this on here self dot books dictionary this one and here once again books id and issue date right issue date okay and here we can provide a slice and then we can hit enter and after that simple return self dot we need to close this one so self dot issue books in case that particular book is not available right so here we have defined not available or in case it is available then simple alif self dot books dictionary which is books id at here status equal to equal to available then what we want means that book will assign to someone okay so that's why we want name so input enter your name and self dot books dictionary against the book id i want lander name equal to your name and self dot books dictionary against the books id issue date which is equal to current date right this one and we need to change the status as well okay because in case that particular book is not assigned to someone else it means that book is available but in case you assigned to someone then we need to change the status so how we can change these status self dot books dictionary and here books id and status which is already issued okay and after that print book issued successfully fine and else it means that particular book id not found and any sensible message you can type here and return self dot issue books okay guys so we have done with issue book and first of all you need to check in your database that particular book ids exist or not in case it is exist then you need to check the status is available or not in case that particular book is not assigned then you need to check the status is available in case the status is available then you need to take the user name and change the information accordingly like username that current date status of that particular book fine in case these condition is not evaluating as true it means that particular book id not found in your current database let me define another module which is how we can add a book so add books and here we are i'm going to define the cell so simple how we can add a new book so i am taking a new book title let's say input enter books title so if new books equal to equal to is blank it means nothing so i will return self dot add books simple because you are not defining any title here okay and one more thing in case you want to restrict to the user for the that specific characters it means let's say you want to give the privilege to the user hey you can define only 20 character for the book title so how you can do that so alif length of new books is greater than which is 25 character now print books title length is too long fine title length should be 20 characters and then once again return self.books add books fine and else so we need to open our database let's say self dot list of books i want to append something right so i am using a as bk b dot write lines bk dot right lines this one and here i'm using once again after string new books let me close this and slice n fine and after that we need to assign our id as well okay so how we can assign the id so self dot books dictionary dot update once again i need to update so what can i do so str end i am taking and i am going to find the maximum id max id or you can say that which is self dot books which is dictionary and here plus 1 fine and then books title so books titles should be new books right and here lender name which is slander name should be assigned blank as of now because we are adding a book right and issue date which is also a blank add a status which is also available by default find these thing you need to remember and let me check the so which is book title let me copy this one paste so we have book title and lender name which is fine issue date and status and after that you can display a sensible message like this book new books has been added successfully okay so guys we have also complete how we can add books so when you are going for the add a book first of all you need to define the book titles if that book title is blank it means simple i am going to return that function and here i have restrict to the user the book title cannot be greater than 25 okay so in case you will enter the more character then you will have this particular message in case these condition is evaluating false it means i am going to open my database as a notepad then i am going to read the lines and i am going to update the id of that new book and the book title and the lender name issue date and the status fine and the last module is how we can return the book so def return book so guys when you are going for written a book so your book status will be tracked based on book id so first of all we want book id so input and books id and here if your books id is available in self dot books dictionary so books dictionary is just like a database so here in keys if it is available it means if self dot books dictionary which is book id and we are checking status right status equal to equal to available it means it means that particular book is exist in the library so this book is already available in library and here i'm going to want to the user like please check your book id okay and then i am going to return the function which is return return books in case that status is not available right so how we can check alif not self dot book dictionary which is books id and status equal to equal to available okay it means not available then what will happen self dot books dictionary which is books id so guys each and every information you need to track based on book id okay and now here lender name right equal to blank okay so when we are going to return the book so it means we need to change the status as well and lender name land and issue date and status as well so now how we can do that so self dot books once again dictionary and books id and now the issue date equal to blank and self dot book dictionary and books id and here the status will change to the available when you are returning a book and then print successfully updated or you can type successfully return anything you can type here and else once again print book id is not found fine so guys we have done with all four modules let me summarize once again so guys what i did simple i create a constructor where i define our file name and library name and apart from that we have defined our dictionary data structure this data structure will have all the information about the books and other details like lender name issue date and status and book title and book id so we assign the book id which is one zero one so by default our book id will start from one zero one and after that we are reading our database from the notepad and we are updating our dictionary based on book title and lender name and issue date and status okay and here we are displaying the information from the notepad files so guys here notepad file work as a database after that we have defined another module which is issue book so when you are going for issue any book so we want the book id okay so because our database has book id based on book id we are tracking each book so we are entering the book id and after that we have current date on which current date i am going to issue that particular book and i am checking that particular id is available in my dictionary data structure or not okay and here if not available it means that particular book is issued to someone else then after that i am going to return to the function in case that status is available it means i can issue that book right so i want that particular username and current date and i am changing the status from available to already issued okay and in case i am not finding that particular id then i am returning that book id is not found and another module is how we can add the books so we are adding the book based on book name book name cannot be blank and cannot be xc to 25 characters and in case we are evaluating these condition as a true then i am opening that file and i am changing the information it means i am going to take a maximum of id then plus one then book title whatever the book title you are going to assign and the lender name issue date and status i am changing accordingly fine and the last is i am going to return the books how you can return the books to the library based on the book id first of all you need to check that particular book ids exist in your dictionary data structure or not if it is available it means we have not issued that particular book to someone and here in case that is not available it means i am going to return that book so i need to change the lender name which is blank issue date should be blank and also the status should be available fine and after that i am going to update this successfully updated in case that book id is not found i am going to display the information fine now the question is how we can run this application okay so guys what i am doing i am going to create a try and catch and let's say i'm going to create my library equal to lms your class name and here you need to define the your database name which is list of books list of books dot txt and your library name is which is python's ready right and here i'm going to create a press key list okay so i'm giving you the option based on that option you can run that particular module so here let's say d which is display the book so let's say display books and which is i means issue book right issue books and aid represent as a ad book ad books and r represent as a written book right let's say let me change here return book and q represent as a quit operation fine and i am taking a flag variable which is key press and i am going to define as a false now while i am going to check the condition which is let me change this key press equal to equal to q it means i am going to quit the operation let me do small q so guys here i am checking not good right it means i am going to welcome our library so how can i do that print so let's say f which is f string right and slice n and once again i'm going to formatting something uh let's see welcome to and my lms dot library name right library management system and once again slash fight now i am going to define a loop over this particular list press key list okay so simple for key and value and press key list dot keys or you can say that items right and here i'm going to check print let me do here press and here i want key to and some sensible information which is value right okay so guys in case you are pressing any of the key then i am going to convert into the lower case okay so you can you can enter the upper case and lowercase as well so input press key and here i am going to convert into the lower right now i am checking the condition if your key press equal to equal to i so guys in case you are pressing the i it means you are going to issue book so you can define a message here let's say sls and current selection which is issue book okay now you can run that particular which is issue book fine alif key press in case you are pressing for a it means you are adding so print once again slice n current selection which is add book right and here slice n and here also we need to provide slice n then you can run your another module which is add books okay and once again alif let me provide some space here alif your key press equal to equal to d it means you are displaying so slash n current selection which is display books and once again slice n and my lms dot display books and alif key press if you are pressing like r it means you are written in the book right so print select n current selection will be written books okay now you can my lms dot written books fine and the last is alif if you are pressing key press equal to equal to q it means you want to quit the operation simple i will break my application else continue accept which is exception as e and print simple something want wrong please check your input okay so guys we have done with this particular project so we have defined a try and catch based on that i have defined a dictionary using the dictionary we will display the option and when you press any of the key then i am convert that particular key into lower and based on user selection i will display that particular module okay now let me run this so we are getting error here so this book is already issued maybe some syntax error line number is 33 so let me close this so guys we need to change to double quote to single quote and the same thing for this one and now let me run now we are getting on 56 let me cls and 56 okay the same thing we are doing here status now let me run once again so invalid syntax here so guys on 56 what we need to do is so we need to enclose using the curly braces this one fine now let me run once again okay now we are getting the error on 100 let's say 100 so let me check the try alignment so it has to be here so we are getting something wrong so let me check once again so let's say if i am doing d we are getting correct but we are not populating all the list of dictionary so here we need to pass self dot returns books okay so guys when we are like defining a loop over this items or over this list what we want we need to change the alignment of this key press now let me run once again let me see ls now we need to change the alignment of if and nested effects so how we can do that so simple we need to [Music] select this one and guys once you set this alignment it means it is perfectly fine now let me run again so guys we are getting the message welcome to python's library management systems and we are getting this particular option now we want to display our all the books then we can press d here and you can use small d and capital d so either you can press capital character or a small character so i'm going to press let's say d and here this is my the available book status fine now once i display this book let's say i want to issue this book so i need to press i so here the current selection is issue book so let's say i'm going to assign the book id which is one one one it means two states enter your name let's say daniel and here i'm getting book issued successfully in case if i am going to have d it means this is i'm changing the status it means we have changed the status which is already issued okay now once again issue book let's say i then if i'm going to press once again the book id which is one one one it means this book is already issued to daniel on this particular date so now once again you need to have the issue book so in case you want to issue the books let's say you can write here 102 then your name which is let's say john and this book is already issued but let's say guys here let's i want once again issue okay but in case i want to quit this operation so i cannot quit this operation right until and unless i need to enter the correct book id so once again one zero four and name which is let's say submit fine then i can quit this operation so what can i do i am going to the issue book let's say here i'm not returning anything right this one fine now let me run once again so let's say d and here i and here i am going to define which is one one one i enter your name once again daniel right so this book issue successfully when you display this one now when i press i then if i'm going to enter wrong information which is let's say 199 it means this book id is not formed okay okay now the question is how we can add the books so you can press a to add the books so you can define your title let's say you can win and you can win has been successfully added you can display this book okay now this book is two state which is already issue then how we can return then we need to press r then book id which is one one one so you can see that successfully updated then how you can check you can press d to check the information all the status is available okay and q for quit the operation okay so guys i hope you understood the concept of python library management system okay so simple we have used lots of things of the python stuff okay so we have seen how we can create a class and constructor and how we can reading a file and how we can use the method to display the books and another method how we can issue the books and here we are using date time and we are using the dictionary data structure as well okay so guys i hope you understood this concept of this project we have covered lots of stuff of the python which we have discussed already in case any question or suggestion please let me know in the comment below and do practice of this session as much as you can so that you can consolidate this concept of python programming so guys thanks for watching and have a great day
Info
Channel: Programming Is Fun
Views: 85,609
Rating: undefined out of 5
Keywords: library management system project in python, how to create python library management system, library management project in python, python project, library management system python project, library management system python code, python project on library management, python project with source code, library management system in python source code, library management system project in python source code, python projects for beginners, how to create python project, create pythonproject
Id: yZUL7IFA324
Channel Id: undefined
Length: 47min 28sec (2848 seconds)
Published: Sun Mar 07 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.