Write a function which takes a dictionary and two other arguments, d, k and v, and adds an item to d with key k and value v, if it doesnt exist such key in d.
Write a function which takes no arguments and returns your name and age. Example:
>>> get_name_and_age()
"Dudije", 27
Call the function and assign each value of its return value to a variable, name and age.
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.
Write a function which takes one dictionary and another argument, d and a, it removes item with key a and returns it. If a is not in d 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, unrelated_words(words, target),
which returns a list of words that have no letters in common with a given word. Example:
>>> unrelated_words(['sun', 'moon', 'star', 'sky'], 'cloud')
['star', 'sky']
def ani(t):
return t[2][1]
Given the above script, what are the results of the following calls
| ani([[1, 2], 3, [3, 4], 3]): | ||
| ani([[1, 2], [3, 3, 4], [1, 'pse', 'jo']]): | ||
| ani([['pse'], 'ani' ['ani', 'pse'], 3]): |
d = {'one': 1}
a = 1 in d
b = 'one' in d
d['pse'] = 3
v = d['pse']
Given the above script?
| What is the final value of d: | ||
| What is the final value of a: | ||
| What is the final value of b: | ||
| What is the final length of d: | ||
| What is the final value of v: |
Complete execution flow of the following program
t = ['pse', 'po', 'ani'] a = t.remove('po') print(a)
Complete execution flow of the following program