0

Python

If the library had 10 books then if one of the books is borrowed the numner must be changed to 9 in the case of returning the book it should be increased by 1 and the note should be generated for the person returning the book How could we do it?😊

5th Jan 2019, 3:07 AM
Pranish Katwal
Pranish Katwal - avatar
9 Answers
0
You could just take a variable and increase or decrease it... How should the program be controlled? via console?
5th Jan 2019, 1:41 PM
Niwo
Niwo - avatar
0
yes
5th Jan 2019, 3:07 PM
Pranish Katwal
Pranish Katwal - avatar
0
In the python console you could just make something like this: books = 10 def add_book: books += 1 def rem_book: books -= 1 By calling the functions you can add or remove a book... What du you mean with "note should be generated"?
5th Jan 2019, 3:32 PM
Niwo
Niwo - avatar
0
it means that when the book is taken by some one in the file a borrowed text should be generated and must decrease the quantity or the number of the book.. supose if there is 23 python book then if take one book then it must be decreased by 1 and become 22.
5th Jan 2019, 3:40 PM
Pranish Katwal
Pranish Katwal - avatar
0
books = 10 def add_book: books += 1 print("Book received") def rem_book: books -= 1 print("Book taken") Like this? How should the program get its input?
5th Jan 2019, 4:25 PM
Niwo
Niwo - avatar
0
thnks bro i understood ir
5th Jan 2019, 4:26 PM
Pranish Katwal
Pranish Katwal - avatar
0
ok, but it will only run in the Python console, if it should run in cmd, you have to work with input...
5th Jan 2019, 4:35 PM
Niwo
Niwo - avatar
0
i am using python idle
5th Jan 2019, 4:44 PM
Pranish Katwal
Pranish Katwal - avatar
0
An other possibillity would be (it would work in cmd etc. too...): books = 10 print("Started") inp = input while (inp!="end"): if (inp=="add"): books += 1 print("Book received. Count: "+books) if (inp=="rem"): books -= 1 print("Book taken. Count: "+books)
5th Jan 2019, 5:06 PM
Niwo
Niwo - avatar