View turkey_turtle.py
This file contains 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) |
View gist:35024aef4dcb2dbede01a333476126d5
This file contains 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) |
View primes.py
This file contains 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) |
View translate_v1.py
This file contains 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') |
View final_translate.py
This file contains 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") |
View translation.py
This file contains 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)) |
View maketrans.py
This file contains 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)) |
View encryption_v2.py
This file contains 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' | |
View encryption_v1.py
This file contains 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) | |
View disarm_v3.py
This file contains 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