Write a function, subtract, that takes two lists of words, list1 and list2, and it returns a list that contains the words from list1 that are not in list2.
Define a function that takes one list of numbers and an integer, lst and num, and modifies it by multiplying by num each number of lst.
Write a function that takes a dictionary and prints all of its items (key-value pair),
one per line, in the following format:
value1 key1
value2 key2
...
Example:
>>> print_dict({'one': 1, 'two': 2}
1 'one'
2 'two'
Write a function that takes two lists, t1 and t2 and extends t2 to t1.
>>> a, b = [1, 'ani'], [2]
>>> extend_list(t1=a, t2=b)
>>> a
[1, 'ani', 2]
>>> extend_list(t1=a, t2=['pse', 'po'])
>>> a
[1 'ani', 2, 'pse', 'po'],
Define a function that takes one list and a value, t and v, and changes its second to last (the one before the last) element to v.
Create two lists and assign them to a and b respectively.
Concatenate a and b and assign it to c.
Repeat c 3 times and reassign.
Print c.
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 = {'o': 'n', 'one': 22}
b = dosmth1(values, 'two')
c = dosmth(values, {'pse': 'perqef'})
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: |
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 capitalize(s): return s[0].capitalize() + s[1:] a = capitalize('ani') b = capitalize('Pse') print(a, b)
Complete execution flow of the following program
def dosmth(s, i): index = 0 while index < len(s): if index == i: return s[i] index = index + 1 dosmth('pst', 1)