# IAL-501 (Prof. Dr. Silvio do Lago Pereira)

#-----------------------------------------------------------
# Exercicio 12
#-----------------------------------------------------------

def dist(x1,y1,x2,y2):
    return ((x2-x1)**2 + (y2-y1)**2)**0.5


#-----------------------------------------------------------
# Exercicio 13
#-----------------------------------------------------------

def média(L):
    return sum(L)/len(L)


#-----------------------------------------------------------
# Exercicio 14
#-----------------------------------------------------------

def imc():
    p = float(input('Peso? '))
    a = float(input('Altura? '))
    i = p/(a**2)
    print('IMC: %.2f' % i)


#-----------------------------------------------------------
# Exercicio 15
#-----------------------------------------------------------

def troca(v,i,j):
    x = v[i]
    v[i] = v[j]
    v[j] = x


#-----------------------------------------------------------
# Exercicio 16
#-----------------------------------------------------------

def diagnostico(p,a):
    i = p/(a**2)
    if i<18.5: print('magra')
    elif i>30: print('obesa')
    else: print('normal')


#-----------------------------------------------------------
# Exercicio 17
#-----------------------------------------------------------

def máximo(a,b):
    if a>b: return a
    else: return b


#-----------------------------------------------------------
# Exercicio 18
#-----------------------------------------------------------

from random import randrange

def adivinha():
    n = randrange(1,8)
    c = 0
    while c != n:
        c = int(input('Chute entre 1 e 7: '))
        if c>n: print('Muito alto!')
        elif c<n: print('Muito baixo!')
        else: print('Você acertou!') 

#-----------------------------------------------------------
# Exercicio 19
#-----------------------------------------------------------

def quadrado(n):
    s = 0
    i = 1
    while n>0:
        s += i
        i += 2
        n -= 1
    return s


#-----------------------------------------------------------
# Exercicio 20
#-----------------------------------------------------------

def barras(s):
    for n in s:
        print(n,n*chr(9607))


#-----------------------------------------------------------
# Exercicio 21
#-----------------------------------------------------------

def fatorial(n):
    f = 1
    for i in range(1,n+1): f *= i
    return f


#-----------------------------------------------------------
# Exercicio 22
#-----------------------------------------------------------

def termial(n):
    t = 0
    for i in range(1,n+1): t += i
    return t


#-----------------------------------------------------------
# Exercicio 23
#-----------------------------------------------------------

def xadrez(n):
    for i in range(n):
        for j in range(n):
            if (i+j) % 2 == 0: print(chr(9608)*2,end='')
            else: print(' '*2,end='')
        print()

