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 correcto(string): | |
| result = "" | |
| for i in string: | |
| if i == " ": | |
| if result[-1:] != " ": | |
| result += i | |
| elif result[-1:] == ".": | |
| if i == " ": | |
| result += i | |
| else: |
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
| key = 'abcdefghijklmnopqrstuvwxyz' | |
| def encrypt(n, plaintext): | |
| result = '' | |
| for l in plaintext.lower(): | |
| try: | |
| i = (key.index(l) + n) % 26 | |
| result += key[i] | |
| except ValueError: | |
| result += l | |
| return result.lower() |
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 gcd(a, b): | |
| while b: | |
| a, b = b, a%b | |
| return a | |
| string1 = int(input("Give me a number for the gratest common denominator: ")) | |
| string2 = int(input("Give me the second for the gratest common denominator: ")) | |
| y = gcd(string1, string2) | |
| print(y) |
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 banana_string(n): | |
| return n.lower().count("banana") | |
| string = input("Give me a string? ") | |
| y = banana_string(string) | |
| print(y) |
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 square_test(n): | |
| summ = 0 | |
| add = 0 | |
| for i in n: | |
| summ = i**2 | |
| add += summ | |
| return add | |
| a_list = [] | |
| num_nums = int(input("How many numbers? ")) |
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 smallest_of(nummerals): | |
| smallest = nummerals[0] | |
| for i in nummerals: | |
| if i < smallest: | |
| smallest = i | |
| return smallest | |
| a_list = [] |
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 mean(liston): | |
| a = 0 | |
| b = 0 | |
| for i in liston: | |
| a += i | |
| b += 1 | |
| return a/b | |
| a_list = [] |
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 facto(a): | |
| if a == 0: | |
| return 1 | |
| else: | |
| return a * facto(a-1) | |
| a=int(input("Dame el numero para factorializar: ")) | |
| c = facto(a) | |
| print(c) |
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 triangulo(a): | |
| b = 0 | |
| while b != a: | |
| b += 1 | |
| print ("T"*b) | |
| while b != 0: | |
| b -= 1 | |
| print("T"*b) | |
| a=int(input("Dame el tamaño del triangulo: ")) |
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 char_freq(string): | |
| import collections | |
| letters = collections.Counter(string) | |
| return letters | |
| string = input("GIVE ME THE STRING: ") | |
| y = char_freq(string) | |
| print(y) |