add l3,l4,l5
+64 · 3 files changed
-
easy/03-lognest-word.py+18 −0 -
easy/04-letter-changes.py+32 −0 -
easy/05-simple-adding.py+14 −0
@@ -0,0 +1,18 @@ +def LongestWord(sen): + si = sen.split() + return max(si, key=len) + + +# keep this function call here +# to see how to enter arguments in Python scroll down +print LongestWord(raw_input()) + + +""" +Have the function LongestWord(sen) take the sen parameter being passed and return the +largest word in the string. If there are two or more words that are the same length, return the +first word from the string with that length. Ignore punctuation and assume sen will not be empty. + +Use the Parameter Testing feature in the box below to test your code with different arguments. +""" +# needs work @@ -0,0 +1,32 @@ +def LetterChanges(str): + nstr = list(str) + indx = ['a', 'e', 'i', 'o', 'u'] + ns = list() + + for y in nstr: + if y.isalpha(): + y = chr(ord(y) + 1) + if y in indx: + s = y.upper() + ns.append(s) + else: + ns.append(y) + else: + ns.append(y) + + xs = ''.join(ns) + + return xs + +print LetterChanges(raw_input()) +""" +Have the function LetterChanges(str) take the str parameter being +passed and modify it using the following algorithm. Replace every +letter in the string with the letter following it in the alphabet +(ie. c becomes d, z becomes a). Then capitalize every vowel in +this new string (a, e, i, o, u) and finally return this modified string. + +Use the Parameter Testing feature in the +box below to test your code with different arguments. + +""" @@ -0,0 +1,14 @@ +""" +Have the function SimpleAdding(num) +add up all the numbers from 1 to num. +For the test cases, the parameter num will be any number from 1 to 1000. +""" +def SimpleAdding(num): + sumall = sum(range(1, num + 1)) + + return sumall + +# keep this function call here +# to see how to enter arguments in Python scroll down +print SimpleAdding(raw_input()) +