This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def accum(s): | |
| final = "" | |
| n = 0 | |
| length = len(s) | |
| for letter in s: | |
| final += letter.upper() + letter.lower() * n | |
| if length > 1: | |
| final += "-" | |
| n += 1 | |
| length -= 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def nb_year(p0, percent, aug, p, n=0): | |
| while p0 < p: | |
| n += 1 | |
| total = p0 + int(p0*(percent/100)) + aug | |
| p0 = total | |
| else: | |
| return n | |
| print(nb_year(1000, 2, 50, 1200)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| secret_num = 4 | |
| vidas = 0 #Contador | |
| intentos = 3 | |
| while vidas<intentos: | |
| intento = int(input("Adivina: ")) | |
| vidas += 1 | |
| if intento == secret_num: | |
| print("Has acertado") | |
| break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fizz_buzz(n): | |
| if n % 5 == 0 and n % 3 == 0: | |
| print("Fizz Buzz") | |
| elif n % 3 == 0: | |
| print("Fizz") | |
| elif n % 5 == 0: | |
| print("Buzz") | |
| else: | |
| print(n) |