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 that takes a string, a character and an integer, word, char and i, and returns True if character of word with index i is equal to char.
Write a function that takes one string and returns
its third to sixth (not including sixth) characters. Example:
>>> middle('strings')
'rin'
Write a function which takes a string, s, as argument, and prints only its characters with index less than 5 (not including 5).
Write a function that takes one string and, using slices, prints the last 2 characters of it.
Define a function, shared_letter_string(word1, word2), that returns a new string of characters from word1 that are also in word2, without duplicates, in the order that they appear in word1.
def return_char(s, n): return s[n]
Given the above script, what are the results of the following expressions:
return_char('llukar', 2): | ||
return_char('xerxe', 0): | ||
return_char('carralluke', 3): |
def dosmth(s, chars): res = "" for letter in s: if letter in chars: res = res + letter return len(res)
Given the above script, what are the results of the following expressions:
dosmth('python programming', 'pom'): | ||
dosmth('python programming', 'arr'): |
Complete execution flow of the following program
def lower(s): return s.lower() s1, s2 = 'python', 'Python' print(lower(s1)) s2 = lower(s2) print(s2)
Complete execution flow of the following program
fruit = 'fig' index = 0 while index < len(fruit): letter = fruit[index] print(letter) index = index + 1