## book example – a dictionary with keys "name", "pages", "read" – don't use this block in the code
# {
#    'name': 'Programming with Python 3',
#    'pages': 157,
#    'read': True
# }

bookshelf = [False] * 10 # = [False, False, False, False, False, False, False, False, False, False]

## (0) – This function will find out wether there is a free space in "bookshelf" at a given "position". If there is not a book, return True (True → there is no book, the space is free, therefore there is a False value at "position"). If there is a book at "position", return False. This function is not graded, but is used in other functions.

def isFree(position):
    # FILL IN

print isFree(0) # True
print isFree(4) # False

## (1) – This function adds a book with "name", number of pages "pages" and a boolean "read" value (the same structure as the book example on line 1..6) to a given "position". If there is already a book at the "position", this function does nothing. Use the "isFree" function.

# def addBook(position, name, pages, read = False):
#     # FILL IN
# 
# addBook(0, 'A Byte of python', 120, read = True)
# addBook(1, 'Automate the boring stuff with Python', 420)
# addBook(2, 'Python for Informatics', 500, read = True)
# addBook(3, 'Learning Geospatial Analysis with Python', 155)
# addBook(4, 'Python Geospatial Development', 211)
# addBook(5, 'Python for Data Analysis', 362, read = True)
# addBook(5, 'Programming Java', 874)
# 
# print bookshelf # [{'read': True, 'name': 'A Byte of python', 'pages': 120}, {'read': False, 'name': 'Automate the boring stuff with Python', 'pages': 420}, {'read': True, 'name': 'Python for Informatics', 'pages': 500}, {'read': False, 'name': 'Learning Geospatial Analysis with Python', 'pages': 155}, {'read': False, 'name': 'Python Geospatial Development', 'pages': 211}, {'read': True, 'name': 'Python for Data Analysis', 'pages': 362}, False, False, False, False]

## (2) – Returns the index of a book with given "name". Use a for cycle.

# def findBook(name):
#     # FILL IN
#     
# print findBook('A Byte of python') # 0
# print findBook('Python Geospatial Development') # 4
# print findBook('Programming Java') # False
    
## (3) – This function uses the "findBook" function and if there is a book with a given "name" in the "bookshelf", it changes the book's "read" value to True.

# def readBook(name):
#     # FILL IN
#         
# readBook('A Byte of python')
# readBook('Automate the boring stuff with Python')
# readBook('Programming Java')
# print bookshelf # [{'read': True, 'name': 'A Byte of python', 'pages': 120}, {'read': True, 'name': 'Automate the boring stuff with Python', 'pages': 420}, {'read': True, 'name': 'Python for Informatics', 'pages': 500}, {'read': False, 'name': 'Learning Geospatial Analysis with Python', 'pages': 155}, {'read': False, 'name': 'Python Geospatial Development', 'pages': 211}, {'read': True, 'name': 'Python for Data Analysis', 'pages': 362}, False, False, False, False]
    
## (4) – This function removes all books that were read from the "bookshelf" (read == True) (replaces them with False).

# def removeReadBooks():
#     # FILL IN
# 
# removeReadBooks()
# print isFree(1) # True
# print isFree(3) # False

## (5) – Returns a list with names of books in the "bookshelf".

# def namesOfBooks():
#     # FILL IN
# 
# print namesOfBooks() # ['Learning Geospatial Analysis with Python', 'Python Geospatial Development']

## BONUS: Returns the average number of pages of books in the "bookshelf".

# def averageNumberOfPages():
#     # FILL IN
#     
# print averageNumberOfPages() # 183