def calculate_ages(people):
new_list = []
for name, year in people:
new_list.append((name, 2025 - year))
return new_list
ppls = [("Muslia", 1890), ("Avdia", 1888)]
new = calculate_ages(ppls)
Given the above script:
| What is the value of new: | ||
| What is the value of name during the first iteration of the loop: | ||
| What is the value of year during the second iteration of the loop: |
Write a function which takes a string and prints all its letters and their indices,
in the order that they appear, each in a new line. Example:
>>> traverse_string('ani')
0 a
1 n
2 i
Write a function, allowed_names(names, allowed),
which returns names made up only of characters from the allowed string. Example:
>>> allowed_names(['Anna', 'Bob', 'Eve', 'John'], 'abnejoh')
['Anna', 'Bob', 'John']
Define a function that takes a list and returns a new list containing its first three elements.
Write a function that takes one string and returns True if it is greater (comes after) than "Pse". It returns False otherwise.
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.
def ani(s1, s2):
return s1[0] > s2[0]
Given the above script, what are the results of the following expressions:
| ani('Ani', 'ani'): | ||
| ani('azzzzz', 'baaaaaaa'): |
def change(lst, index, value):
lst[index] = value
t = [1, 2, 3]
change(t, 0, 5)
print(t)
change(t, -2, 3)
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 is_greater(s1, s2): if s1 > s2: return "s1 is greater than s2" else: return "s1 is smaller or equal to s2"