Courses‎ > ‎Intro to CS - Full Year‎ > ‎Spring‎ > ‎Dyrland-Weaver‎ > ‎Work‎ > ‎

Work 21: 3/27

posted Mar 27, 2019, 1:04 AM by JonAlf Dyrland-Weaver
Write the following python functions:

  • is_palindrome
    • Takes a single string as a parameter.
    • Returns True if the string is a palindrome and False otherwise.
    • Examples
      • is_palindrome('racecar') ==> True
      • is_palindrome('ferrari') ==> False
  • third_char
    • Takes a single string parameter
    • Returns a new string made up of every third character from the original string, starting with the third.
    • Example:
      • third_char( 'abcdefghij' ) ==> 'cfi'
      • third_char('jeIgh ina7Hm9u w9t.uhr0e 8 dhDvwo 2c') ==> <you figure it out>
  • bold_string
    • Takes two strings as parameters. The first is a regular string (s) and the second is a substring to look for (key).
    • Returns a new string that is a copy of s except that every instance of key should be surrounded by HTML h1 tags.
    • Example:
      • boldString( 'do, or do not, there is not try.' , 'do' ) ==> '<h1>do</h1> or <h1>do</h1> not, there is no try.'

submit this as test3-review

Comments