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 verb_post(v): | |
irregular_verb = {"write": "wrote", "go": "went", "read": "read"} | |
for key, value in irregular_verb.items(): | |
if key == v: | |
return value | |
if v[-1] == "c": | |
return v + "ked" | |
elif v[-1] == "e": | |
return v + "d" | |
elif v[-1] == "y": |
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 sum7(list): | |
if len(list) < 1: | |
return -1 | |
else: | |
count = 0 | |
for x in list: | |
if x == 7: | |
try: | |
list[count + 1] *= 2 | |
count += 1 |
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 sys | |
import re | |
def count_word(lines): | |
words = {} | |
sum = 0 | |
for line in lines: | |
line = re.sub(r'\r\n|\n|\.|,|-|\"|\'|\[|\]|_|\*|:|\;|\(|\)|\/|\&|!|\?', ' ', line).lower() | |
n = line.split() | |
sum += len(n) |
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 sys | |
def nl(lines): | |
i = 1 | |
for line in lines: | |
if line == '\n': | |
print("{0}".format(line), end="") | |
else: | |
print(" {0} {1}".format(i, line), end="") | |
i += 1 |
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 re | |
def fb(x): | |
return re.sub(r'[0-9]+', '', str((['Fizz'] + list(range((x % 3))))[x % 3]) + str((['Buzz'] + list(range((x % 5))))[x % 5])) | |
i = 1 | |
while i <= 200: | |
print(i, fb(i)) | |
i = i + 1 |
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 fb(n): | |
if n % 15 == 0: | |
return "FizzBuzz" | |
elif n % 3 == 0: | |
return "Fizz" | |
elif n % 5 == 0: | |
return "Buzz" | |
else: | |
return "" |