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
| import turtle | |
| t = turtle.Turtle() | |
| s = turtle.getscreen() | |
| def feather(r, angle, color): | |
| for i in range(2): | |
| turtle.fillcolor(color) | |
| turtle.begin_fill() | |
| turtle.circle(r,angle) | |
| turtle.left(180-angle) |
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
| from collections import Counter | |
| def lcm_of_factors(list): | |
| # empty dictionary | |
| unique = {} | |
| for i in range(0,len(list)): | |
| number = list[i] | |
| numbers = factors(number) |
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 factors(num): | |
| i = 2 | |
| factors = [] | |
| while i <= num: | |
| if (num % i) == 0: | |
| factors.append(i) | |
| num = num / i | |
| else: | |
| i = i + 1 | |
| return(factors) |
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
| firstStr = 'aeiou' | |
| secondStr = '01223' | |
| translation = string.maketrans(firstStr, secondStr) | |
| string = "apple" | |
| new_string=string[::-1] | |
| print('translated string: ', new_string.translate(translation)+'aca') |
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 encrypt_trans(word): | |
| return(word[::-1].translate(word[::-1].maketrans("aeiou","01223"))+"aca") |
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
| # translation table - a dictionary | |
| translation = {97: None, 98: None, 99: 105} | |
| string = "abcdef" | |
| print("Original string:", string) | |
| # translate string | |
| print("Translated string:", string.translate(translation)) |
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
| firstString = "abc" | |
| secondString = "ghi" | |
| thirdString = "ab" | |
| string = "abcdef" | |
| translation = string.maketrans(firstString, secondString, thirdString) | |
| print(translation) | |
| print("Translated string:", string.translate(translation)) |
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 encrypt(word): | |
| replacers = {'a':0, 'e' :1, 'i':2, 'o':2,'u':3} | |
| word_as_list = list(word[::-1]) | |
| replaced_list = [replacers.get(item,item) for item in word_as_list] | |
| list_to_string = ''.join([str(elem) for elem in replaced_list]) | |
| list_to_string += 'aca' | |
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 encrypt(word): | |
| replacers = {'a':0, 'e' :1, 'i':2, 'o':2,'u':3} | |
| word_as_list = list(word[::-1]) | |
| def replace(list, dictionary): | |
| return [replacers.get(item, item) for item in list] | |
| replaced_list = replace(word_as_list,replacers) | |
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 disarm_short(num): | |
| return (sum(int(j) ** (i+1) for i,j in enumerate(str(num))) == num) |
NewerOlder