Define a function, is_of_length(word, length), that returns True if length of word is equal to length, or False otherwise.
Write a function, are_equal, that takes two values and returns True if they are equal, or False otherwise.
Write a function, is_less, that takes two values and returns True if the first is less than the second, or False otherwise.
Write a function, add, that takes two numbers and returns their sum.
Write a function, get_length, that takes a string and returns its length.
Write a function, char_after_target, that takes a word and a character,
word and target, and returns the character after target. If target is last, return
the first letter. If target is not found in word return None. Example:
>>> char_after_target("kastravec", "s")
"t"
>>> char_after_target("kastravec", "c")
"k"
>>> char_after_target("kastravec", "d")
None
Restrictions:
- You cannot use any relational operator(==, <, ...)
- You cannot use len
- You cannot use + or -
Write a function that takes two strings and returns the smallest (one which comes before). Return the string even if they are equal.
Write a function, add, that takes two numbers and returns their sum.
Write a function, sub, that takes two numbers and returns the first minus the second.
Write a function, that takes a word and an integer,
word and n, and returns characters of word from n - 2 to n + 2 (including both).
Example:
>>> middle('baushtelle', 2)
baush
>>> middle('baushtelle', 4)
ushte
Restrictions:
- You cannot use + or -
- The body of of the function should have only one line
Define a function contains_letter(word, letter) that returns True if the given letter appears in the word, False otherwise.
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 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'): |
def is_char(word, ch, i):
return word[i] == ch
Given the above script, what are the results of the following expressions:
| is_char("llukar", "u", 3): | ||
| is_char("xerxe", "x", 0): | ||
| is_char("carralluke", "c", 1): |
Complete execution flow of the following program
def print_numbers(s): for item in s: if item in '0123456789': print(item) print_numbers('a1e2')
Complete execution flow of the following program
def return_char(s, n): return s[n] return_char('owling', -2) return_char('bowling', -4)