본문 바로가기

분류 전체보기246

Python 실습_After Index After Index You can return a portion of a string from some index onwards by using the bracket operator and and the expression index:. For example: if color = 'blue' then color[1:] = 'lue' since the result is all of the characters in color from the index onwards. Create a function called after_index() that accepts a string and a number n as parameters and returns a string consisting of the charac.. 2012. 4. 10.
Python 실습_Character Replacement Character Replacement Create a method called replace() that takes a character and a string as parameters and returns a string with every instance of the character replaced with an asterisk (*). Ignore is characters are upper or lower case. Results Call Expected Received Correct replace('b','bigboy') *ig*oy *ig*oy true replace('c','CAT') *AT *AT true replace('b','cat') cat cat true 2012. 4. 10.
Python 실습_Alphabet count Alphabet count Create a function called getAlphaCount() that accepts a letter and a string. The function should return the number of times that the letter appears in the string. >>> getAlphaCount('a', 'aAaAaAbbb') 6 >>> getAlphaCount('b','bigboy') 2 >>> getAlphaCount('c','cat') 1 >>> getAlphaCount('b','cat') 0 Results Call Expected Received Correct getAlphaCount('a', 'aAaAaAbbb') 6 6 true getAlp.. 2012. 4. 10.
Python 실습_Capitalize Even Items Capitalize Even Items Create a function that when passed a list of strings, changes all even indexed strings to be upper case while odd ones remain the same. Results Call Expected Received Correct capitalize_even(['Apple','Banana','Chiku','Durian','Elderberry','Fig','Grape','Honeydew']) [APPLE, Banana, CHIKU, Durian, ELDERBERRY, Fig, GRAPE, Honeydew] ['APPLE', 'Banana', 'CHIKU', 'Durian', 'ELDER.. 2012. 4. 10.