From 41ad3cf37fb1f781397f7f085fa6648cb0421d57 Mon Sep 17 00:00:00 2001 From: bkesh-1 <87112183+bkesh-1@users.noreply.github.com> Date: Sun, 16 Oct 2022 15:51:44 +0545 Subject: [PATCH] Add files via upload --- .../__pycache__/Bill.cpython-39.pyc | Bin 0 -> 1224 bytes .../__pycache__/Book.cpython-39.pyc | Bin 0 -> 1919 bytes .../__pycache__/Return.cpython-39.pyc | Bin 0 -> 2066 bytes .../__pycache__/borrow.cpython-39.pyc | Bin 0 -> 1877 bytes .../__pycache__/main.cpython-39.pyc | Bin 0 -> 1434 bytes Library management system/Bill.py | 36 ++++++++ Library management system/Book.py | 54 +++++++++++ Library management system/Return.py | 69 ++++++++++++++ Library management system/books.txt | 5 ++ Library management system/borrow.py | 84 ++++++++++++++++++ Library management system/main.py | 44 +++++++++ 11 files changed, 292 insertions(+) create mode 100644 Library management system /__pycache__/Bill.cpython-39.pyc create mode 100644 Library management system /__pycache__/Book.cpython-39.pyc create mode 100644 Library management system /__pycache__/Return.cpython-39.pyc create mode 100644 Library management system /__pycache__/borrow.cpython-39.pyc create mode 100644 Library management system /__pycache__/main.cpython-39.pyc create mode 100644 Library management system/Bill.py create mode 100644 Library management system/Book.py create mode 100644 Library management system/Return.py create mode 100644 Library management system/books.txt create mode 100644 Library management system/borrow.py create mode 100644 Library management system/main.py diff --git a/Library management system /__pycache__/Bill.cpython-39.pyc b/Library management system /__pycache__/Bill.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2455863f6399b36683ba0ebff0f2048b81c9483a GIT binary patch literal 1224 zcmbtU%}(1u5Z?7)9Fw$Z3Iw%OG7^^v38@@i`XiDaDpdgq+DcI>WU?F8#qoyqMu2Op zs?rDOBP7SZ(q4Pw6*zU)i780EvDSLN{buIdnf1zkwdx=k-#1_QKMaKasKxD}!Qu_f zco|*<5gei}A{xyx~nf*~sksZ)STmor=Gr*@(83!gmzraVLQn5nZsOLIgJob+lZvA%iR zJA*8F>1^F&B(>H!7HmklyBCDv#>U3g4tyzzon-eOvRg^L;}5CJ25zD6xru!^9=bv7 zZYJw(Ur^VNh>Ruhw^rotF?Jfea~CC^dyPGbx}`aBoEY2ULL{&6Q>WuN z5}zlv#rAC~{2+`yC#e-R98ey!2&!5=V!{vI10MAA#`5BT|JRH7PcJKXdvJYDJ=bYg zq&eb2B&2ncH!iDlOGzFttpVdhAKZN!3Cd-O(^2U6snlb^rNKrtlIA%N1eIn#WN~h& z&!to7ylXehAafkScYv(%P?~}f|58@^W6nYKSd}YrAn}E?2SG?x$I?)!Yo4f+|Bd)l zxD40NTVC%&4Cl~$|F*OLalhB5@u^^=-od5#!XmfD#yqB<7(eZ)OSC<@l!gN8KMUb5`;co)lKGstRc+y;~5ypmh5b#O>~cgV;%q_5z= Kf@1Z9vh}~U7b%|r literal 0 HcmV?d00001 diff --git a/Library management system /__pycache__/Book.cpython-39.pyc b/Library management system /__pycache__/Book.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e4330438fc8884bcba37d02a534ed898fbb3aa09 GIT binary patch literal 1919 zcmcgs-EJF26rR~XuQzrAq9jeBu!#U+rHw?zRfs~{q*5bQZV-in6)v`(O|$W4*O?io z*mAC11iXcP*;n9_2jBtbmMcp zxHIO$oxlgU4<3M5CVYj7aJB-e3Mrzwkz@DF_Bvug)JDz)8?v!GVZXCq*%23YvG_c^ z;6pxQoL0OExL~;1Qge{q{J*|IgJg?etyzZ+PHaI z7{4pC0#i!MtZQ77gD0hwK`hvGA?Xu8mpZ z-Yt7lrH@P5IV9X{cKarpA6cZThM?3n5XM6uVJz|*zXFQiS?9N*4X)aK+j-eea<#Mh z-{yud2{w{YX}q$F1XN|3h&+R5JsIn5cCe`G>C1TT*xgzc~a4*YBa2GERz8AA`>TlL`oBXDc4; zL>q7MMT7N&JWW&@cV&5=i8M~)^CZtiOv%Ti60fbTO>ZHY(moa2Z*kU!Z6#TUv%&JC zV>%K~P+T6_P~uD>n$PYhDt>gFsrUe(1wilG{y?~Q=JC_Lz8-wOe-!sq6(c1@toz+G z{xQCh9mO!Bx&Caf*g`Y*8#PHyD_1~FkaU4WA>Sv(&x&qOTbP=ljgCpBsh*ZHr9+f) zRqxb9mkCGf)i34Qx}TTNQrYmyhFX)_R9>Z{=%r`{HojYCVSaVmG{d+BI$>OHfRLcp zL73yA%WAylgaG+99y&F?Y`cy08gy&laA)yQ1K5ezoWAmG!tK*i^zw9vo-Rdw5xU_A F{{qu)ys!WO literal 0 HcmV?d00001 diff --git a/Library management system /__pycache__/Return.cpython-39.pyc b/Library management system /__pycache__/Return.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..31ce873c37ae2875f05a674af9e8e135498d2a2d GIT binary patch literal 2066 zcmbtU&u`pB6rQoY8?WPRlFcS*+EON=k%$_qQVx}ts;%0zqEbjB3RGDIRqoDg<7Q)T z$Foh>*jyGkA<;9Z&5{3szk`FXaLK=r6W`1x3lwpxt@-iZym{|?-+Oj2HRTaJ%a=b5 zeykAkhZg?%SP<@DBUCx3DKoV)k~&YFgakrSD18=JsQy?E%fps)C&}px94j6B&I)Wu`n{8o&x`c{s@@jwp8*39n#a zH7EW6nHYN_f721Ni6z3lC6c>iX%bRpEKx|_Sn?rFs!HY#DEAj}D^{l)|5XBnMMUqV+!+F@vs9H9|7Y0^7o6QdA_@d^_?9OR> z&B9o-batDc|62mj+;w>K+$7kT|t+V&wYg(f_^M81OT5|TZG#6r&0nT65d{FZm+9Ud=T+3tuS5v(iYS0NWHV6TD>0_pJV;Rah?UOv7K z*ah{{o9__m%CY{h9NT&_G_Z#WQ+r~R*(htKe-})=?uJtE+v%lkDUyWkuy!ojj!0M# zakgcot+>HXXrlnEopk+fpY6qm>>!BxaM4fLVelW{V6+48x6|^sjjPw&c{=fhVfv%g zxvE~Pf*z)`BMsXSDhNACgL&!9S%tPug~0d44UJJF(f>7Fyi@EUE}T%7)-`hpGrk1O z0x59K+m>NVFm04p9)!{9cIwMm1s!%b>~tFJa_SmU?<%_BiAHu@24yF7{n){pTI+0W zUTP|fl8TY6)QlE(6dx9DqGVg6D$37dDWR!qFB@S?g>e+feo+p(U0^CoVbtxZ!VV)< zl)6$c<(ANmR`{cIo|^bYsojYK7{YTgAw{I% zud(}8f~xLr-rsuk^`qSlk?gCuyZfLQaa@aZT~OUtd;qG#==tt;A2B0#FYd`iJc;H0 z?xnEyl@E=!@+=4A9QE+l z=mN$?ybE-O*6amX=$qP~N6*8mN=?)?$8>;c30X&Qqcu7HWBLRKg?sZL=Dm)%rN6&K Kx0SEsT7LmK!V2sF literal 0 HcmV?d00001 diff --git a/Library management system /__pycache__/borrow.cpython-39.pyc b/Library management system /__pycache__/borrow.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d1cd75486ee042592a224a4cf472c296361c88d9 GIT binary patch literal 1877 zcmbtU&u`;I6rLG7uHz+Wa% zFW~*77q=e*i!Wd#+Azd$hE|MOrQ$dz{+O6mO+p2cXZ_DnFYs%u>&Jvz=7cm9it3O)I#6aGLqsPr(_H~ z&MJ~fi;)o?;mk^{6klNRowS)Xf+);(USg#&W=;dKDHt%Dh%*A_CLdi9@q?Vop?Yeq z0M-i9m8A<9mhp;xcLim3YBPLF#Ge|0m5bU%)!Wq>W?oqCm9r8?S2)T|_VoW{1OE!J zcdqfPfHMVe)Y7RD0UlmHJw}-;D|r>>a$3%7Y-Wrz4|3|Mn|jO{*^qb5vV@?A*-w#$ zwvn7+b8LP@e*G<*mUTAE7DfaV9A=etI-iwuDd6f3^@=T;Uh8aWgdt})tEN>}JtbFI z{9a@OLS+S|z^`~KTKeyOQ>~$^UEwofR?hWm{~6pI8-61TqiF5{WF&vzhm+91=P;nB zWph6B`TV$8ub8#P?tn(Mw3aW75qk@G5kcjAzG$*sVEj=w0}N-Nd#zwS)%~KMiB>a3 zatYML4V1xYpS>p=c_VdFq}3aPb_~Joe0yJDxNyVON0H=$zKr8j8ZatjaD|93%}$dJ zAA0xR;PHm<9)#RaIPHu0B4C{Q^uiAT=qnAl*P?4{Ym<+Gh{E1*`wfupP4w40TsC!s zghsKX{)Hce{>zX9i2e?Heh>{8ZZd91hns~A@`TfUzsG6ZrF|}vIHH#)H4}4=plUlO*%2km-Q>jmV6}@ zzMMEv@-^O^*t#^?q{GF>K>{sw_38K^mp&Az{{F6?(8Ckx@SxyVM1b3u(DDf+>;66; zez@1A1D;UWil`j)IektygRap9_6EgX)T9azHkMUQlW7GV8N`t<2FmgKeI7Ao1(8&x zAnKpP1kJ+A>2Q5zlvi974X3Jw&zW8&HzCgUT4D+s68daZNoqNS7Ef7Ge5u?-imv`c zRCWw#swDjAn5)vI2qae)M3rsIm%{iG5X-$-@B*RK4P#$II0(ayS;#%_Y1H_1ucdWU zHupOx$|-h~dv@+eGLQqqrtNfJL~zKap$-?zn&AqVcBOMJ1a$YpkiuPs1BHK7)7R1( zF8Gzg{XdYn4==p_WT$!bO#%mT^!U;KlW(6KwRmzWTl3mT!%r~m)} literal 0 HcmV?d00001 diff --git a/Library management system /__pycache__/main.cpython-39.pyc b/Library management system /__pycache__/main.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4c6b9915bd99d1112e7418258bca96e5ccb1cb1e GIT binary patch literal 1434 zcmcgsPfrs;6rb7MF3Zw_LSl?whLfo%p(XJ^2r)tvNeB@CKxmqnEjz-d+u1rZ3wEPk z-~;##EJweBA7!s5CiUP4@Z@{bt$~9lBC~n#&CKuj{>;3|29=6WV0_6}f^&zE@3^=; zELc1RQFTxu32984BTJjqtgWVHtlhLjE40r^)8Wn;p}>7fs?HGn$o3)X@t`pAK-NLj zFHjn|XOyC~1~jxU#w*9{S_A6>;sIJJSZ-k_&}N^st)0+21Fw(3!rUK7IN7n}3HbPi zTN=0~#ss4KPSGDu8?gWV*;SbEPh`i%~#`L$u%jLBZ41 zc&qTZUD#Q)2f$kb2?^ZE+;$c%+|Y#?;D~p* z&`kA}=G|ck4aqt;Ro;T{XLlPybIEF0*Rw>*rqHQz-yxBQi7cSw^Js zKGNBp-Ixc8GdKyv3fM^yr+kGC@v&w14w96eMsdsp1aFUXV5A|w@a+B-g5+tD3#%B~ z$Y?(PZzEgs*{kC~bXXtCe49v?sz@BMt$+2%&sML~pX|Y=fa{4uwkdk4o}c&GmCLI= zVs!>pEN5%iN#py~sl3#aknc%iwCTcrq-=kBN*xj(W7ce+6&a(C46yev)U z-(a^??(bn^8}LeGmFAPF;?kVrE0MF%r{A^pmDX$6RIRPX_Rii;YlEwfPI|4~zCKO_ zTTfD{_&puGxghEZC}MeZntFdfi 25: + title = title[0:22].ljust(25, '.') + author = splitList[2].ljust(25) + quantity = splitList[3].ljust(15) + price = splitList[4].ljust(15) + + print(bookID.ljust(15) + title + " " * 5 + author + quantity + price) + borrow.bookDictionary[int(splitList[0])] = [splitList[1].strip(), splitList[2].strip(), int(splitList[3].strip()), splitList[4].strip()] + print("\n",borrow.bookDictionary) + print("\n") + splitLines() + file.close() + +#Creating moreBooks functon +def moreBooks(): + + bookIDList = [] + for each in borrow.bookDictionary: + bookIDList.append(each) + bookID = int(input("Enter another borrowed book: ")) + + if bookID not in bookIDList: + print("\n" + "++" * 30 + "\n") + print("Please provide a valid Book ID !!!".center(50) + "\n" + "++" * 30 + "\n") + moreBooks(sum) + + borrow.borrowedID.append(bookID) + borrow.borrowedBooks.append(borrow.bookDictionary[bookID][0]) + price2 = borrow.bookDictionary[bookID][3] + print("The price of book is: ",price2 + "\n") + print("Has This Person Borrowed Another Book?") + AnotherBook = input("If yes then type Y ,if not they type n: " ) + if AnotherBook.lower() == "y": + moreBooks() + else: + return + + diff --git a/Library management system/Return.py b/Library management system/Return.py new file mode 100644 index 0000000..7acf455 --- /dev/null +++ b/Library management system/Return.py @@ -0,0 +1,69 @@ +from datetime import date +from datetime import datetime +import borrow +# Creating return_books function +def return_books(): + total = 0 + bookIDList = [] + + today = date.today() + now = datetime.now() + current_time = now.strftime("%H:%M:%S") + + #Asking user details + for each in borrow.bookDictionary: + bookIDList.append(each) + f_name = input("Name of person who returned Book: ") + bookID = int(input("Enter book id to return book: ")) + + #Checking user input + if bookID not in bookIDList: + print("\n" + "++" * 30 + "\n") + print("Please provide a valid Book ID !!!".center(50) + "\n" + "++" * 30 + "\n") + return_books() + if bookID in bookIDList: + quantity = borrow.bookDictionary[bookID][2] + price = borrow.bookDictionary[bookID][3] + book_name = borrow.bookDictionary[bookID][0] + author_name = borrow.bookDictionary[bookID][1] + + quantity =int(quantity)+1 + total+=float(price[1:]) + print(str(total)) + # checking for fine + print("Is the book return date expired?") + Expire = input("Press Y for Yes and N for No: ") + x=current_time.replace(":","") + if(Expire.upper()=="Y"): + day = int(input("By how many days was the book returned late?")) + fine=3*day + total=total+fine + else: + fine = 0 + total = "{:.2f}".format(total) + + fileName="Return-"+f_name+str(today)+ x+".txt" + file = open(fileName,'w') + file.write("Return Details: \n") + file.write("Name of Person: "+ f_name+"\n") + file.write("Date and time of return is: "+str(today)+ " " ) + file.write(str(current_time) +"\n") + file.write("Books Returend are: "+ borrow.bookDictionary[bookID][0]+"\n") + file.write("Price is: " +borrow.bookDictionary[bookID][3]+ "\n") + file.write("Fine is: "+ str(fine)+"\n") + print("Total Bill: "+ "$"+str(total)) + file.write("Total: $"+ str(total)) + + # Writing in file + borrow.bookDictionary[bookID][2]+= 1 + with open('books.txt', 'w') as f: + for i in range(1, 6): + f.write(str(i)) + f.write(",") + for j in range(4): + if(j == 3): + f.write(str(borrow.bookDictionary[i][j])) + else: + f.write(str(borrow.bookDictionary[i][j])) + f.write(", ") + f.write("\n") diff --git a/Library management system/books.txt b/Library management system/books.txt new file mode 100644 index 0000000..329ff36 --- /dev/null +++ b/Library management system/books.txt @@ -0,0 +1,5 @@ +1,The Alchemist, Paulo Coelho, 82, $4.99, +2,Harry Potter, J.K Rowling, 8, $9.99, +3,vampire Diaries, L.J Smith, 1, $12.00, +4,Don Quixote, Miguel de Cervantes, 96, $15.00, +5,Beloved, Toni Morrison, 93, $20, diff --git a/Library management system/borrow.py b/Library management system/borrow.py new file mode 100644 index 0000000..fc4e570 --- /dev/null +++ b/Library management system/borrow.py @@ -0,0 +1,84 @@ +from datetime import date +from datetime import datetime +import Book +import Bill + + +#definingempty dictionary and list +bookDictionary = {} +borrowedBooks = [] +borrowedID = [] + +#Creating borrowBook Function +def borrowBook(): + sum = 0 + bookIDList = [] + #checking user input + for each in bookDictionary: + bookIDList.append(each) + bookID = int(input("Enter book id to borrow book: ")) + + if bookID not in bookIDList: + print("\n" + "++" * 30 + "\n") + print("Please provide a valid Book ID !!!".center(50) + "\n" + "++" * 30 + "\n") + borrowBook() + + if bookID in bookIDList: + + borrowedBooks.append(bookDictionary[bookID][0]) + borrowedID.append(bookID) + quantity = bookDictionary[bookID][2] + if quantity == 0: + print("\n" + "++" * 30 + "\n" + "Book is not available!!!".center(50) + "\n" + "++" * 30 + "\n") + from main import main + + else: + print("\n" + "++" * 30 + "\n" + "Book is available!!!".center(50) + "\n" + "++" * 30 + "\n") + + f_name = input("Enter the Name of person who borrowed book: ") + price = bookDictionary[bookID][3] + print("The price of book is: ",price) + + #adding date and time + today = date.today() + now = datetime.now() + current_time = now.strftime("%H:%M:%S") + + print("Today's date and Time: ", today,current_time, "\n") + + #writing in file + bookDictionary[bookID][2]-= 1 + + with open('books.txt', 'w') as f: + for i in range(1, 6): + f.write(str(i)) + f.write(",") + for j in range(4): + if(j == 3): + + f.write(str(bookDictionary[i][j])) + else: + f.write(str(bookDictionary[i][j])) + f.write(", ") + f.write("\n") + + + print("List after a Borrow: ") + Book.Book() + print("Has This Person Borrowed Another Book?") + AnotherBook = input("If yes then type Y ,if not they type n: ") + if AnotherBook.lower() == "y": + Book.moreBooks() + + + for x in(borrowedID): + p = bookDictionary[x][3] + price = p[1:] + sum = sum + float(price) + #printing bill + Bill.Bill(f_name,sum,today,current_time) + + + + + diff --git a/Library management system/main.py b/Library management system/main.py new file mode 100644 index 0000000..b129aa5 --- /dev/null +++ b/Library management system/main.py @@ -0,0 +1,44 @@ +import borrow +import Book +import Return +import Bill + +#Defining main function +def main(): + # using while loop + while(True): + print("+++" * 35) + print("Hello and Welcome to library management system".center(100)) + print("+++" * 35+ "\n\n") + Book.Book() + print("Enter 1 to Borrow a Book") + print("Enter 2 to Return a book") + print("Enter 3 to Exit") + + #Using try and catch for exception Handling + try: + userInput = int(input("Please enter a value: ")) + print() + # Taking input from user + if(userInput==1): + print("You will now borrow a book") + borrow.borrowBook() + main() + break + elif(userInput==2): + print("You will now reuturn a Book") + Return.return_books() + + elif(userInput==3): + print("---"* 30) + print("\n Thank you for using Library management system\n".center(100)) + print("---"* 30) + break + except ValueError: + print("++" *30) + print("Invalid Input!!\n Please enter 1, 2 or 3") + print("++" *30+ "\n\n") + +# calling main function +main() +