Write a function, uses_all(word, required), that returns True if word uses all characters from the required string.
ⓘ
Define a function has_common_letters(word1, word2) that returns True if the two words share at least one common letter, False otherwise.
ⓘ
Write a function that takes a list and sorts it.
>>> a = [4, 3, 1, 2]
>>> sort_list(a)
>>> a
[1, 2, 3, 4]
ⓘ
Write a function which takes one dictionary and removes the item with key 'age' from it.
Example:
>>> person = {'name': 'Arta', 'age': 23, 'city': 'Prishtina'}
>>> remove_age(person)
>>> person
{'name': 'Arta', 'city': 'Prishtina'}
ⓘ
Write a function that takes a list of (product, price) tuples
and returns the total price of all products. Example:
>>> total_price([('buka', 0.5), ('specat', 2), ('kosi', 3.4)])
5.9
ⓘ
Create a dictionary, cities, with Prishtine and Shkup mapping to 10000 and 1000 respectively.
Print cities dictionary.
Print length of cities.
Print value 1000 of cities.
ⓘ
words = ['a', 'h', 'b'] words.extend(['c']) line = words.sort() words.append([2])
What is the value of words and line at the end of execution of the above program?
words: | |
line: |
def create_dict(a, b): return {1: a, 2: b} def get_value(d, k): return d[k] d = create_dict('pse', 'ani') v = get_value(d, 2)
What is the value of v at the end of execution of the above program?
Complete execution flow of the following program
def ends_with_the_same_letter(s1, s2): return s1[-1] == s2[-1]
>>> ends_with_the_same_letter('ani', 'pse') >>> res = ends_with_the_same_letter('pristine', 'pse') >>> print(res) True >>>
Complete execution flow of the following program
>>> t = [1, 2] >>> d = t.append(2) >>> print(d) None >>> t [1, 2, 2] >>> d = t + [2] >>> d[:2] [1, 2] >>>