Define a function has_common_letters(word1, word2) that returns True if the two words share at least one common letter, False otherwise.
Define a function that takes one list of numbers and one integer, t and i,
and adds 10 to the element of t with index i. Example:
>>> t = [1, 2, 3]
>>> add_ten(t, 1)
>>> t
[1, 12, 3]
Define a function that takes one list, an integer and a value, t, i and v, and changes the element of t with index i to v.
Write a function, words_with_all(words, required),
which returns a list of words that contain all the required letters. Example:
>>> words_with_all(['plane', 'panel', 'pen', 'lean'], 'pen')
['plane', 'panel', 'pen']
floats = [1.0, 3.0, 4.0]
Modify floats by adding 1 to each element of it using for.
Write a function that takes a dictionary and returns the value of it mapped to 'third' key.
Example:
>>> get_value({'third': 3, 'pse': 'ani'})
3
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 dosmth(d, d1):
d.update(d1)
def dosmth1(d, k):
return d.setdefault(k, 'ani')
def dosmth2(d):
return d.get('pse', 'jo')
values = {1: 2}
b = dosmth1(values, 1)
c = dosmth(values, {1: 4})
d = dosmth2(values)
What is the value of the following variables at the end of the execution of the above script?
| values: | ||
| b: | ||
| c: | ||
| d: |
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 capitalize_all(t): res = [] for s in t: res.append(s.capitalize()) return res