Define a function that takes a string and returns True if its third character is 'q'.
Write a function that takes two strings, s1, and s2, and
- if s1 is smaller than s2, it returns "s1 comes before s2"
- if s1 is greater than s2, it returns "s1 comes after s2"
- if s1 is is equal s2, it returns "s1 is equal to s2"
Write a function, are_equal, that takes two values and returns True if they are equal, or False otherwise.
Write a function, add, that takes two numbers and returns their sum.
Write a function that takes a string and returns sum of indices of spaces found in the string.
Example:
>>> count_spaces("ku po shkon?")
7
>>> count_spaces("a po vjen?")
5
Restrictions:
- You cannot use any relational operator(==, <, ...)
- You cannot use + or -
Write a function which takes two strings, s1 and s2, and it concatenates the first 3
characters of s1 with the last 2 characters of s2 and returns it.
Example:
>>> concatenate_strings("power", "owl")
'powwl'
Define a function, less_than_10(word), that returns True if word has less than 10 letters, False otherwise.
Define a function that takes a string and returns its first character.
def return_char(s, n):
index = len(s) - n
return s[index]
Given the above script, what are the results of the following expressions:
| return_char("python", 1): | ||
| return_char("python", 3): |
def dosmth(s, char):
c = 0
for i in range(len(s)):
if s[i] == char:
c = c + i
return c
Given the above script, what are the results of the following expressions:
| dosmth('baba', 'b'): | ||
| dosmth('nana', 'a'): |
Complete execution flow of the following program
def dosmth(s, i): index = 0 while index < len(s): if index == i: return s[i] index = index + 1 dosmth('pst', 1)
Complete execution flow of the following program
>>>