예제 #1
0
def main():
    llargada = easyinput.read(float)
    assert llargada > 0
    nivells = easyinput.read(int)
    assert nivells >= 0
    turtle.speed(10)  # accelera l'animació
    triangle_koch(llargada, nivells)
    easyinput.read(chr)  # espera abans de tancar la finestra
예제 #2
0
def main():
    turtle.hideturtle()
    turtle.speed(10)
    for i in range(20):
        r = random.random()
        g = random.random()
        b = random.random()
        turtle.pencolor(r, g, b)
        quadrat(100)
        turtle.right(18)
    easyinput.read(chr)
예제 #3
0
def get_args_from_terminal():
    print("Enter values for parameters:")
    print("K: ", end="")
    k = read(int)
    print("NROUNDS: ", end="")
    n = read(int)
    print("R: ", end="")
    R = read(int)
    print("alpha: ", end="")
    a = read(int)
    print("beta: ", end="")
    b = read(int)
    return k, n, R, a, b
예제 #4
0
def read_list():
    l = []
    print('Enter filmID and rating (or -1 to finish):')
    a = read(str)
    if (a == '-1'):
        return l
    b = read(float)
    while True:
        l.append((a, b))
        print('Enter filmID and rating (or -1 to finish):')
        a = read(str)
        if (a == '-1'):
            return l
        b = read(float)
    return l
예제 #5
0
def main():
    """programa principal"""
    n = read(int)
    if es_primer(n):
        print(n, "és primer")
    else:
        print(n, "no és primer")
예제 #6
0
def main():
    print("Iterative(1) or one run(2)? ", end="")
    it = read(int)
    if it == 2:
        print("Enter the dumping factor: ", end="")
        df = read(float)
        print("simple graph (1) or airports (2)? ", end = "")
        type = read(int)
        if type == 1:
            rank_simple_graph(df)
        else:
            print("Do you want the rank as output? ",end="")
            o = read(int)
            rank_airports(df, o)
    else:
        n = 20
        damps = np.array(range(1,n))/(n)
        print(damps)
        iterations = rank_airports_iterative_DP(damps)
        plt.plot(damps, iterations)
        plt.show()
예제 #7
0
def avaluar():
    """llegeix i avalua una expressió prefixada"""
    c = read(chr)
    if es_digit(c):
        return caracter_a_enter(c)
    else:
        assert c == '+' or c == '-' or c == '*'
        op1 = avaluar()
        op2 = avaluar()
        if c == '+':
            return op1 + op2
        elif c == '-':
            return op1 - op2
        else:
            return op1 * op2
예제 #8
0
# programa que llegeix tres enters i n'escriu el seu màxim

import easyinput


def max2(x, y):
    if x >= y:
        return x
    else:
        return y


def max3(x, y, z):
    return max2(x, max2(y, z))


#a = easyinput.read(int)
#b = easyinput.read(int)
#c = easyinput.read(int)
a, b, c = easyinput.read(int, int, int)
print(max3(a, b, c))
예제 #9
0
def main():
    n = easyinput.read(int)
    print(factorial(n))
예제 #10
0
def main():
    n = read(int)
    hanoi(n, 'a', 'c', 'b')