Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions palindrome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#! /usr/bin/env python3
# -*- coding:utf-8 -*-
def is_palindrome(word):
return word == word[::-1]

if __name__ == '__main__':
s = 'racecar'
print(is_palindrome(s))
10 changes: 10 additions & 0 deletions pig_latin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import re

def pig_latin(word):
return re.match('(.)(?!=[aeiou])(.*)', word).expand(r'\2-\1ay')

if __name__ == '__main__':
s = 'banana'
print(pig_latin(s))
8 changes: 8 additions & 0 deletions reversed_string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#! /usr/bin/env python3
# *_* coding:utf-8 *_*
def reversed_string(string):
return string[::-1]

if __name__ == '__main__':
s = 'Hello World'
print(reversed_string(s))
16 changes: 16 additions & 0 deletions vowel_counter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /usr/bin/env python3
# -*- coding:utf-8 -*-
from collections import Counter

def vowel_counter(string):
c = Counter(string.lower())
vowel = 'aeiou'
count = 0
for ch in vowel:
print(ch, c[ch])
count += c[ch]
print('Total vowel:', count)

if __name__ == '__main__':
s = 'Hello World'
vowel_counter(s)