2017-02-16 HW

posted Feb 16, 2017, 6:46 AM by Samuel Konstantinovich   [ updated Feb 16, 2017, 6:57 AM ]
DO NOW:
Log in, then lock screen.

HW: Complete the required codingbat problems. (All of the custom problems should be done)

On paper:

1.
Given a string of even length, return a string made of the middle two chars, so the string "string" yields "ri". The string length will be at least 2.

middleTwo("string") → "ri"
middleTwo("code") → "od"
middleTwo("Practice") → "ct"
2.
Given a string, if the first or last chars are 'x', return the string without those 'x' chars, and otherwise return the string unchanged.

withoutX("xHix") → "Hi"
withoutX("xHi") → "Hi"
withoutX("Hxix") → "Hxi"

3. Requies a loop! - This is on paper for now, but you must complete on codingbat as homework.
Given a string, return the string without the vowels.
*is there a part of this code that you would like to break off into a separate function? If so, then assume it was written*

noVowels("fish") → "fsh"
noVowels("spymaster") → "spymstr"
noVowels("Advent") → "dvnt"




NOTES:

Regarding None: When a function does not have a return statement, then it returns a special value: None. When you see a None you may have forgotten to return, OR you printed instead of returning. Another possibility is you put your return statements inside of conditional statements, and they never triggered.


Comments