Skip to content

Instantly share code, notes, and snippets.

View AnnikaNoren's full-sized avatar

Annika Noren AnnikaNoren

View GitHub Profile
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)
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)
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)
firstStr = 'aeiou'
secondStr = '01223'
translation = string.maketrans(firstStr, secondStr)
string = "apple"
new_string=string[::-1]
print('translated string: ', new_string.translate(translation)+'aca')
def encrypt_trans(word):
return(word[::-1].translate(word[::-1].maketrans("aeiou","01223"))+"aca")
# 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))
firstString = "abc"
secondString = "ghi"
thirdString = "ab"
string = "abcdef"
translation = string.maketrans(firstString, secondString, thirdString)
print(translation)
print("Translated string:", string.translate(translation))
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'
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)
def disarm_short(num):
return (sum(int(j) ** (i+1) for i,j in enumerate(str(num))) == num)