users = {
"Alice": {
"Inception": {"rating": 9, "review": "Mind-bending!"},
"Titanic": {"rating": 7, "review": "Too long, but emotional"}
},
"Bob": {
"Inception": {"rating": 8, "review": "Loved the visuals"},
"Interstellar": {"rating": 10, "review": "Masterpiece"}
}
}
Write a function, get_user_average_rating(user: str, users: dict),
that returns the average rating a user has given.
If the user has no ratings, return None. Example:
>>> get_user_average_rating("Alice", users)
8.0
Define a function, shared_letter_string(word1, word2), that returns a new string of characters from word1 that are also in word2, without duplicates, in the order that they appear in word1.
Write a function that a list of strings and returns a string which is concatenation of all
list items with space in between of each.
Example:
>>> add_strings(["it's", "a", "fugazi"])
"it's a fugazi"
Write a function which takes one dictionary, d, it removes item with key 'wrong' and returns it. If 'wrong' is not in d as key it throws KeyError.
Write a function, get_most_common_words, that takes a histogram
(dictionary of words and their frequencies) and returns a list of
(count, word) tuples, sorted from the most frequent to least.
Example:
>>> get_most_common_words({'again': 1, 'hello': 2, 'world': 1})
[(2, 'hello'), (1, 'world'), (1, 'again')]
Write a function which takes a string, s, as argument, and prints its characters with odd index (1, 3, 5, ...) each in a new line.
def dosmth(s):
return s.split('^')
a, b, c = dosmth('ani^pse^2')
Given the above script, what are the values of the following variables?
| a: | ||
| b: | ||
| c: |
def dosmth(d, a):
return d.pop(a)
questions = {'ku': 'qaty', 'pse': 'sdi', 'jo be': 2}
a = dosmth(questions, 'ku')
b = dosmth(questions, 'pse')
What is the value of the following variables at the end of the execution of the above script?
| a: | ||
| b: | ||
| questions: |
Complete execution flow of the following program
Complete execution flow of the following program
t = ['pse', 'po', 'ani'] a = t.remove('po') print(a)