Examen

  1. b
  2. c
  3. a
  4. c
  5. c
  6. b
  7. c
  8. a

In [180]:
# Ejercicio 9
tabla = [(x, x*7) for x in range(1,11)]
for x, y in tabla:
    print(x,"x 7 = ",y)


1 x 7 =  7
2 x 7 =  14
3 x 7 =  21
4 x 7 =  28
5 x 7 =  35
6 x 7 =  42
7 x 7 =  49
8 x 7 =  56
9 x 7 =  63
10 x 7 =  70

In [186]:
# Ejercicio 10
tabla = [x*7 for x in range(1,11)]
def multiplo_de_siete_v1(n):
    if n in tabla:
        print(str(n)+': SI es múltiplo')
    else:
        print(str(n)+': NO es múltiplo')
    return
multiplo_de_siete_v1(7)
tabla


7: SI es múltiplo
Out[186]:
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70]

In [177]:
# Ejercicio 11
def multiplo_de_siete_v2(n):
    if n % 7 == 0:
        print(str(n)+': SI es múltiplo')
    else:
        print(str(n)+': NO es múltiplo')
    return
multiplo_de_siete_v2(875)


875: SI es múltiplo

In [ ]: