Beispiel #1
0
def create_matrix_init():
    """ Collects needed data. """
    matrix_types = {
        'Null': 'null',
        'Identity': 'identity',
        'Known': 'known',
        'Random': 'random',
    }

    type_ = matrix_types[tools.get_option(matrix_types)]
    rows = tools.get_integer('Number of rows: ')
    columns = rows if type_ != 'identity' else tools.get_integer('Number of columns: ')

    return create_matrix(rows, columns, type_)
Beispiel #2
0
def series_constructor_init():
    """Collects needed data."""
    return series_constructor(
        tools.get_option(attributes_available),
        tools.get_integer('Number of elements: '),
    )
Beispiel #3
0
}

attributes_available = {
    'Prime': is_prime,
    'Square': is_square,
    'Cube': is_cube,
    'Perfect': is_perfect,
    'Abundant': is_abundant,
    'Happy': is_happy,
    'Powerful': is_powerful,
    'Palindromic': is_palindromic,
    'Magic': is_magic,
    'Harmonic': is_harmonic,
    'Sphenic': is_sphenic,
    'Smith': is_smith,
    'Harshad': is_harshad,
    'Antiprime': is_antiprime,
}
# 'Practical': is_practical,

if __name__ == '__main__':
    option = tools.get_option(options_available)
    result, prompt = options_available[option]()
    tools.display(result, prompt)

    # series = tools.get_option(attributes_available)
    # elements = tools.get_integer('Number of elements: ')
    # result = attributes_available[series](elements)
    # prompt = '{} sequence with the {} first elements: '.format(series, elements)
    # tools.display(result, prompt)
Beispiel #4
0
def main():
    option = tools.get_option(options_available)
    result, prompt = options_available[option]()
    display(result, prompt)
Beispiel #5
0

def fibonacci_series(elements=0) -> list:
    """ n = n-1 + n-2"""
    seq = [0, 1]
    for i in range(elements - len(seq)):
        seq.append(seq[i] + seq[i + 1])
    return seq


def padovan_series(elements=0) -> list:
    """ n = n-2 + n-3 """
    seq = [0, 1, 1]
    for i in range(elements - len(seq)):
        seq.append(seq[i] + seq[i + 1])
    return seq


series_available = {
    'Fibonacci': fibonacci_series,
    'Padovan': padovan_series,
}

if __name__ == '__main__':
    series = tools.get_option(series_available)
    elements = tools.get_integer('Number of elements: ')
    result = series_available[series](elements)
    prompt = '{} sequence with the {} first elements: '.format(
        series, elements)
    tools.display(result, prompt)