Define a function that takes a list of numbers, and modifies it by adding 10 to each number.
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 that takes a list and a value (of whatever type), t and v, and appends
v to t.
>>> t = [1, 'ani']
>>> append_to_list(t=t, v=3)
>>> t
[1, 'ani', 3]
>>> append_to_list(t=t, v=[1, 2])
>>> t
[1, 'ani', 3, [1, 2]]
Write a function that takes a dictionary and prints all of its items (key-value pair),
one per line, in the following format:
key1 value1
key2 value2
...
Example:
>>> print_dict({'one': 1, 'two': 2}
'one' 1
'two' 2
Define a function count_shared_letters(word1, word2) that returns the number of letters from word1 that are found in word2.
Define a function has_common_letters(word1, word2) that returns True if the two words share at least one common letter, False otherwise.
def sub_list(lst, i, offset):
return lst[i-offset:i]
def element(lst, i, offset):
return lst[i-offset]
t = [1, 2, 3, 4, 5, 6]
t1 = sub_list(t, 4, 1)
t2 = element(t, 4, 1)
What is the value of t1 and t2 at the end of execution of the above script?
| t1: | ||
| t2: |
def change(lst, index, value):
lst[index] = value
t = ['po', 'jo', 'pse', 'ani', 54]
change(t, -2, 5)
print(t)
change(t, 3, 'jo')
print(t)
change(t, 1, 10)
print(t)
Given the above script, write the printed values in the order that they appear.
| 1: | ||
| 2: | ||
| 3: |
Complete execution flow of the following program
Complete execution flow of the following program
def print_numbers(s): for item in s: if item in '0123456789': print(item) print_numbers('a1e2')