added 09-15
+100 · 7 files changed
-
easy/09-time-convert.py+13 −0 -
easy/10-alphabet-soup.py+12 −0 -
easy/11-ab-check.py+19 −0 -
easy/12-vowel-count.py+13 −0 -
easy/13-word-count.py+11 −0 -
easy/14-ex-oh.py+18 −0 -
easy/15-palindrome.py+14 −0
@@ -0,0 +1,13 @@ +def TimeConvert(num): + + return str(num/60) + ':'+str( num % 60) + + +# keep this function call here +# to see how to enter arguments in Python scroll down +print TimeConvert(raw_input()) +""" +Have the function TimeConvert(num) take the num parameter being passed and return the number of hours and minutes +the parameter converts to (ie. if num = 63 then the output should be 1:3). +Separate the number of hours and minutes with a colon. +""" @@ -0,0 +1,12 @@ +def AlphabetSoup(str): + li = list(str) + li.sort() + return ''.join(li).strip(" ") + +# keep this function call here +# to see how to enter arguments in Python scroll down +print AlphabetSoup(raw_input()) +""" +Have the function AlphabetSoup(str) take the str string parameter being passed and return the string with the letters in alphabetical order (ie. hello becomes ehllo). Assume numbers and punctuation symbols will not be included in the string. + +""" @@ -0,0 +1,19 @@ +def ABCheck(str): + for i in range(0, len(str) - 4): + if (str[i] == 'a'): + if (str[i + 4] == 'b'): + return 'true' + if (str[i] == 'b'): + if (str[i + 4] == 'a'): + return 'true' + + return 'false' + + +# keep this function call here +# to see how to enter arguments in Python scroll down +print ABCheck(raw_input()) + +""" +Have the function ABCheck(str) take the str parameter being passed and return the string true if the characters a and b are separated by exactly 3 places anywhere in the string at least once (ie. "lane borrowed" would result in true because there is exactly three characters between a and b). Otherwise return the string false. +""" @@ -0,0 +1,13 @@ +def VowelCount(str): + o = 0 + for i in "aeiou": + o += str.count(i) + + return o + +# keep this function call here +# to see how to enter arguments in Python scroll down +print VowelCount(raw_input()) +""" +Have the function VowelCount(str) take the str string parameter being passed and return the number of vowels the string contains (ie. "All cows eat grass" would return 5). Do not count y as a vowel for this challenge. +""" @@ -0,0 +1,11 @@ +def WordCount(str): + o = 1 + o += str.count(" ") + + return o +# keep this function call here +# to see how to enter arguments in Python scroll down +print WordCount(raw_input()) +""" +Have the function WordCount(str) take the str string parameter being passed and return the number of words the string contains (ie. "Never eat shredded wheat" would return 4). Words will be separated by single spaces. +""" @@ -0,0 +1,18 @@ +def ExOh(str): + + o = str.count('o') + x = str.count('x') + + if x == o: + return 'true' + else: + return 'false' + + +# keep this function call here +# to see how to enter arguments in Python scroll down +print ExOh(raw_input()) +""" +Have the function ExOh(str) take the str parameter being passed and return the string true if there is an equal number of x's and o's, otherwise return the string false. Only these two letters will be entered in the string, no punctuation or numbers. For example: if str is "xooxxxxooxo" then the output should return false because there are 6 x's and 5 o's. +""" + @@ -0,0 +1,14 @@ +def Palindrome(str): + o = str.replace(" ","") + + if o == o[::-1]: + return 'true' + else: + return 'false' + +# keep this function call here +# to see how to enter arguments in Python scroll down +print Palindrome(raw_input()) +""" +Have the function Palindrome(str) take the str parameter being passed and return the string true if the parameter is a palindrome, (the string is the same forward as it is backward) otherwise return the string false. For example: "racecar" is also "racecar" backwards. Punctuation and numbers will not be part of the string. +"""