Define a function contains_letter(word, letter) that returns True if the given letter appears in the word, False otherwise.
def to_set(v):
return set(v)
s1 = {1, 2, 3, 3, 3}
s2 = to_set('aan')
Given the above script, what are the values of the following variables?
| s1: | ||
| s2: |
Define a function that takes one list as argument and returns its second to last element (the element before the last).
Define a function, third_from_end(word), that returns word's third character from the end.
Define a function, more_than_n(word, n), that returns True if word has more than n letters.
Define a function that takes a list and sorts it.
Define a function that takes one list as argument and returns its last element.
lst = [1, 13, 111, ["a", "b", 3]]
Given the above script:
| How many elements does lst have: | ||
| What is the second element of lst: | ||
| What is type of the second element of lst: | ||
| What is the last element of lst: |
Complete execution flow of the following program
print("Ani".isupper()) a = "ANI" res = a.isupper() print(res)
Complete execution flow of the following program
fruit = 'fig' index = 0 while index < len(fruit): letter = fruit[index] print(letter) index = index + 1