Exemplo n.º 1
0
def main():
    n = helpers.input_int("n=", helpers.natural_only)
    m = helpers.input_int("m=", helpers.natural_only)

    matrix = []
    array_of_neg = [0.0] * m
    i = 0
    while i < n:
        num_of_neg = 0.0
        matrix.append([])
        j = 0
        while j < m:
            el = helpers.cycled_input("({};{})=".format(i, j), float)
            if el < 0:
                num_of_neg += 1
                array_of_neg[j] += 1

            matrix[i].append(el)
            j += 1

        matrix[i].append(num_of_neg)
        i += 1

    array_of_neg.append(0)
    matrix.append(array_of_neg)

    print_matrix(matrix)
Exemplo n.º 2
0
def get_user_input():
    raw_input = helpers.cycled_input(
        "Let's see what you got(product - price):\n", str, validate_user_input)
    name, price = parse_user_input(raw_input)
    if name in products:
        products[name] += price
    else:
        products[name] = price
Exemplo n.º 3
0
def main():
    text = helpers.cycled_input("Enter text:", str, lambda v: len(v) > 0)
    word_length = helpers.input_int("Enter word length:", helpers.natural_only)

    words = text.split(SEPARATOR)
    for i in range(0, len(words)):
        if len(words[i]) == word_length:
            for char in CHARS_TO_REMOVE:
                words[i] = words[i].replace(char, "")

    print("Res:", SEPARATOR.join(words))
Exemplo n.º 4
0
 def recursive_array_input(self, n: int):
     self.append(helpers.cycled_input("{}:".format(len(self)), float))
     if n != 1:
         self.recursive_array_input(n - 1)
Exemplo n.º 5
0
def main():
    n = helpers.cycled_input("input n:", int, lambda v: v > 0)
    arr = MyList()
    arr.recursive_array_input(n)
    arr.remove_all_zero_elements()
    print("res: {}", arr)
Exemplo n.º 6
0
from python_helpers import helpers


def right(t: str, i: int):
    if len(t) == i:
        return t
    else:
        return right("." + t, i)


text = helpers.cycled_input("input string:\n", str, lambda v: len(v) > 0)
mod_length = helpers.cycled_input("input modification length:\n", int,
                                  lambda v: v >= len(text))

print("Res:\n{}".format(right(text, mod_length)))