← coderbyte_practice

add l3,l4,l5

5224b9ca3b0af3c71007fd3eeb28bd22ab4122e1 · ovidiucs · May 4, 2015 11:14

+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
diff --git a/easy/03-lognest-word.py b/easy/03-lognest-word.py
index e69de29..d8d2cb1 100644
--- a/easy/03-lognest-word.py
+++ b/easy/03-lognest-word.py
@@ -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
diff --git a/easy/04-letter-changes.py b/easy/04-letter-changes.py
index e69de29..ba0ae02 100644
--- a/easy/04-letter-changes.py
+++ b/easy/04-letter-changes.py
@@ -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.
+
+"""
diff --git a/easy/05-simple-adding.py b/easy/05-simple-adding.py
index e69de29..09eee78 100644
--- a/easy/05-simple-adding.py
+++ b/easy/05-simple-adding.py
@@ -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())           
+