Write a function, borrow_book(user: str, book: str, books: list[str], borrowed: dict[str, str]),
that removes the book from the available books
and adds it to the user's borrowed list if the book is available.
Return a message about the action. Example:
>>> books = ["1984", "The Hobbit"]
>>> borrowed = {}
>>> print(borrow_book("Alice", "1984", books, borrowed))
Book '1984' borrowed by Alice.
>>> borrowed
{'Alice': ['1984']}
>>> books
["The Hobbit"]
Sorry, Of Mice And Men is not available.
Write a function that takes a dictionary and another argument, d and k,
and returns the value of d mapped to k. Example:
>>> get_value({'one': 1, 'pse': 'ani'}, 'pse')
'ani'
Write a function, unique_words(words) that takes a list of words and returns a set of the words with duplicates removed.
Write a function, uses_all(word, required), that returns True if word uses all characters from the required string.
Write a function that takes one string and returns True if it is greater (comes after) than "Pse". It returns False otherwise.
Define a function count_shared_letters(word1, word2) that returns the number of letters from word1 that are found in word2.
def ani(t):
return t[1][0]
Given the above script, what are the results of the following calls
| ani([[1, 2], [3, 4], 3]): | ||
| ani([[1, 2], [3, 3, 4], 3]): | ||
| ani([['pse'], ['ani'], 3]): |
items = [1, 2, ['ani', 3], 4] del items[1] items.remove(4) x = items.pop(1) x = x.pop(0)
What is the value of items and x at the end of execution of the above program?
| items: | ||
| x: |
Complete execution flow of the following program
def is_char(word, ch, i): return word[i] == ch is_char('poroj', 'o', 1) is_char('mujdin', 'd', 3)
Complete execution flow of the following program
def dosmth(line): count = 0 i = 1 while i < len(line): if line[i - 1] == line[i]: count = count + 1 i = i + 1 return count dosmth('add')