Write a function the takes one string and returns the character before the last. You should use negative indices.
Write a function that takes one string and, using slices, returns the first three characters of it.
Define a function, all_vowels_in(word), that returns True if the word contains all 5 vowels (a, e, i, o, u), False otherwise.
Define a function that takes a string and returns True if its first character is 'b'.
Write a function that takes one string with more than 10 characters, and returns
its fifth to eighth (not including eighth) characters. Example:
>>> middle('programming')
'ram'
Define a function, less_than_n(word, n), that returns True if word has less than n letters, False otherwise.
def slices(word, x, y):
return word[x:y]
Given the above script, what are the results of the following expressions:
| slices("Butch...", 0, 5): | ||
| slices("Butch...", 4, 6): | ||
| slices("Butch...", -4, -1): |
def dosmth(word):
s = ""
for i in range(len(word)):
if i % 2 == 1:
s = s + word[i]
return s
Given the above script, what are the results of the following expressions:
| dosmth('quza'): | ||
| dosmth('skuza'): |
Complete execution flow of the following program
def dosmth(s, char): c = 0 for i in range(len(s)): if s[i] == char: c = c + i return c c = dosmth('aba', 'b')
Complete execution flow of the following program
def in_first(word1, word2): for letter in word1: if letter not in word2: print(letter)