Example #1
0
inputs_composantes_a = [
    Args(15,10,20,15),Args(12,5,22,10),Args(5,5,10,10),Args(5,5,5,10),Args(15,10,23,10),Args(15,15,10,12),Args(20,10,15,15)
]

inputs_soustraction_a_b = [
    Args(15,10,20,15),Args(12,5,22,10),Args(5,5,10,10),Args(5,5,5,10),Args(15,10,23,10),Args(15,15,10,12),Args(20,10,15,15)
]


exo_composantes_a = ExerciseFunction(
    composantes_a,
    inputs_composantes_a,
    # show function name in leftmost column
    call_renderer=CallRenderer(show_function=True),
    # use pprint to format results
    result_renderer=PPrintRenderer(width=20),
    font_size="90%",
    header_font_size="120%",
)

exo_soustraction_a_b = ExerciseFunction(
    soustraction_a_b,
    inputs_soustraction_a_b,
    # show function name in leftmost column
    call_renderer=CallRenderer(show_function=True),
    # use pprint to format results
    result_renderer=PPrintRenderer(width=20),
    font_size="90%",
    header_font_size="120%",
)
Example #2
0

# @END@

wc_inputs = (
    Args('''Python is a programming language
that lets you work quickly
and integrate systems more effectively.'''),
    Args(''),
    Args('abc'),
    Args('abc \t'),
    Args('a  bc \t'),
    Args(' \tabc \n'),
    Args(" ".join("abcdefg") + "\n"),
    Args('''The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
...'''),
)

exo_wc = ExerciseFunction(wc,
                          wc_inputs,
                          call_renderer=PPrintCallRenderer(max_width=40,
                                                           show_function=True),
                          result_renderer=PPrintRenderer(width=15))
Example #3
0
  {'n': 'Forbes', 'p': 'Bob'},
  {'n': 'Martin', 'p': 'Jeanneot'},
  {'n': 'Martin', 'p': 'Jean', 'p2': 'Paul'},
  {'n': 'Forbes', 'p': 'Charlie'},
  {'n': 'Martin', 'p': 'Jean', 'p2': 'Pierre'},
  {'n': 'Dupont', 'p': 'Alexandre'},
  {'n': 'Dupont', 'p': 'Laura', 'p2': 'Marie'},
  {'n': 'Forbes', 'p': 'John'},
  {'n': 'Martin', 'p': 'Jean'},
  {'n': 'Dupont', 'p': 'Alex', 'p2': 'Pierre'}]]





inputs_tri_custom = [
    Args(input) for input in inputs
]

exo_tri_custom = ExerciseFunction(
    tri_custom, inputs_tri_custom,
    call_renderer=PPrintCallRenderer(width=24),
    result_renderer=PPrintRenderer(width=30),
    font_size='small',
)


def tri_custom_ko(liste):
    sort(liste)
    return liste
Example #4
0
    scalaire = 0
    # sachez reconnaitre ce vilain idiome:
    for i in range(len(vec1)):
        scalaire += vec1[i] * vec2[i]
    return scalaire


# @END@

from fractions import Fraction

inputs_produit_scalaire = [
    Args((1, 2), (3, 4)),
    Args(range(3, 9), range(5, 11)),
    Args([-2, 10], [20, 4]),
    Args([Fraction(2, 15), Fraction(3, 4)],
         [Fraction(-7, 19), Fraction(4, 13)]),
    Args([], []),
]

exo_produit_scalaire = ExerciseFunction(
    produit_scalaire,
    inputs_produit_scalaire,
    call_renderer=PPrintCallRenderer(width=25),
    result_renderer=PPrintRenderer(width=25),
)


def produit_scalaire_ko(vec1, vec2):
    return [x * y for x, y in zip(vec1, vec2)]