From d0a6b515f2dce0ef2e47e807f8cbb7456f9e0b27 Mon Sep 17 00:00:00 2001 From: bertilein Date: Mon, 30 Oct 2023 20:53:25 +0100 Subject: [PATCH 1/4] Create bertilein.py Reto #4 - Python --- .../python/bertilein.py | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Retos/Reto #4 - PRIMO, FIBONACCI Y PAR [Media]/python/bertilein.py diff --git a/Retos/Reto #4 - PRIMO, FIBONACCI Y PAR [Media]/python/bertilein.py b/Retos/Reto #4 - PRIMO, FIBONACCI Y PAR [Media]/python/bertilein.py new file mode 100644 index 0000000000..4265937f97 --- /dev/null +++ b/Retos/Reto #4 - PRIMO, FIBONACCI Y PAR [Media]/python/bertilein.py @@ -0,0 +1,49 @@ +""" +/* + * Escribe un programa que, dado un número, compruebe y muestre si es primo, fibonacci y par. + * Ejemplos: + * - Con el número 2, nos dirá: "2 es primo, fibonacci y es par" + * - Con el número 7, nos dirá: "7 es primo, no es fibonacci y es impar" + */ +""" +import math as m + +def is_even(number)->bool: + return ((number%2)==0) + +def is_prime(number)->bool: + + upperbound = m.sqrt(number) + i = 2 + while ( number % i != 0 ) and (i <= upperbound): + i=i+1 + + return i>upperbound + + +def is_perfect_square(number)->bool: + square = int(m.sqrt(number)) + return ((square*square) == number ) + + +def is_fibonacci(number)->bool: + return is_perfect_square(5*number*number+4) or is_perfect_square(5*number*number-4) + + +def is_prime_fib_even(number)->str: + es_primo = (' no', '')[is_prime(number)] + ' es primo, ' + es_fibonacci = (' no', '')[is_fibonacci(number)] + ' es fibonacci, ' + es_par = (' es impar ', ' es par')[is_even(number)] + + return es_primo+es_fibonacci+es_par + +num1 = 2 +num2 = 7 + +print(num1 , is_prime_fib_even(num1)) +print(num2 , is_prime_fib_even(num2)) + +# Más Tests :P - del 2 al 19 +for i in range(1,20): + print(i , is_prime_fib_even(i)) + \ No newline at end of file From 8d9083c90bf4511992a10ab763b55cc581064926 Mon Sep 17 00:00:00 2001 From: Juan David Duque Date: Fri, 3 Nov 2023 12:22:55 -0500 Subject: [PATCH 2/4] Reto#27 - jduque1989 - Python --- .../python/jduque1989.py" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "Retos/Reto #27 - CUENTA ATR\303\201S [Media]/python/jduque1989.py" diff --git "a/Retos/Reto #27 - CUENTA ATR\303\201S [Media]/python/jduque1989.py" "b/Retos/Reto #27 - CUENTA ATR\303\201S [Media]/python/jduque1989.py" new file mode 100644 index 0000000000..3c119e406d --- /dev/null +++ "b/Retos/Reto #27 - CUENTA ATR\303\201S [Media]/python/jduque1989.py" @@ -0,0 +1,36 @@ +import time + +# Funcion para solicitar al usuario los parametros y validación + +def data_input(): + while True: + try: + count_init = int(input("Enter a number to start countdown: ")) + step = int(input("Enter a step size: ")) + checker(count_init, step) + except ValueError: + print("Error, please enter a number") + + +# Funcion para revisar que cumpla la condición de enteros positivos + +def checker(count_init, step): + if count_init < 0 or step < 0: + print("Error, please enter a positive number") + data_input() + else: + count_down(count_init, step) + +# Funcion de la cuenta regresiva + +def count_down(count_init, step): + while count_init >= 0: + print(count_init) + time.sleep(step) + count_init -= 1 + if count_init == 0: + print("Blast off!") + break + + +data_input() From 75c4a14bb1c643f65c6c8857ec29bbac84b1a2c8 Mon Sep 17 00:00:00 2001 From: Patricio Date: Fri, 3 Nov 2023 16:49:29 -0300 Subject: [PATCH 3/4] reto#1 - python --- .../python/patotal.py" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/patotal.py" diff --git "a/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/patotal.py" "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/patotal.py" new file mode 100644 index 0000000000..4c28460534 --- /dev/null +++ "b/Retos/Reto #1 - EL LENGUAJE HACKER [F\303\241cil]/python/patotal.py" @@ -0,0 +1,36 @@ +letras = { + "a" : "4", + "b" : "I3", + "c" : "[", + "d" : ")", + "e" : "3", + "f" : "|=", + "g" : "&", + "h" : "#", + "i" : "1", + "j" : ",_|", + "k" : ">|", + "l" : "1", + "m" : "/\/\\", + "n" : "^/", + "o" : "0", + "p" : "|*", + "q" : "(_,)", + "r" : "I2", + "s" : "5", + "t" : "7", + "u" : "(_)", + "v" : "\/", + "w" : "\/\/", + "x" : "><", + "y" : "j", + "z" : "2", + " " : " ", + } + +frase = input("Frase a convertir: ") +resultado = "" +for i in frase.lower(): + resultado += letras.get(i, i) + +print(resultado) \ No newline at end of file From 4477fca70ca62f563051005d4549abcb6130d98d Mon Sep 17 00:00:00 2001 From: bertilein <149420545+bertilein@users.noreply.github.com> Date: Sun, 5 Nov 2023 19:25:05 +0100 Subject: [PATCH 4/4] reto #0 - python reto #0 - python --- .../python/bertilein.py" | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 "Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/bertilein.py" diff --git "a/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/bertilein.py" "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/bertilein.py" new file mode 100644 index 0000000000..32659324e8 --- /dev/null +++ "b/Retos/Reto #0 - EL FAMOSO FIZZ BUZZ [F\303\241cil]/python/bertilein.py" @@ -0,0 +1,31 @@ +""" + * Escribe un programa que muestre por consola (con un print) los + * números de 1 a 100 (ambos incluidos y con un salto de línea entre + * cada impresión), sustituyendo los siguientes: + * - Múltiplos de 3 por la palabra "fizz". + * - Múltiplos de 5 por la palabra "buzz". + * - Múltiplos de 3 y de 5 a la vez por la palabra "fizzbuzz". +""" + + +def print_fixx_buzz(): + + cadena = "" + + for i in range(100): + if ((i+1)%3 == 0) and ((i+1)%5 == 0): + cadena="fizzbuzz" + elif ((i+1)%3 == 0) : + cadena="fizz" + elif ((i+1)%5 == 0) : + cadena="buzz" + + + else : + cadena=i+1 + + print(cadena) + + + +print_fixx_buzz()