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?đ
9 Answers
0
You could just take a variable and increase or decrease it... How should the program be controlled? via console?
0
yes
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"?
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.
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?
0
thnks bro i understood ir
0
ok, but it will only run in the Python console, if it should run in cmd, you have to work with input...
0
i am using python idle
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)