Python String Exercises

From WLCS
Revision as of 09:19, 7 April 2010 by Admin (talk | contribs) (New page: Directions: Create a python file named ch7_YOURLASTNAME.py # Create a string "The quick brown fox jumped over the lazy dog." in a variable s #* Print out the first letter in s using the b...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Directions: Create a python file named ch7_YOURLASTNAME.py

  1. Create a string "The quick brown fox jumped over the lazy dog." in a variable s
    • Print out the first letter in s using the brackets (e.g. s[NUM])
    • Print out the letter "q" using s and the index 4
    • Print out the letter "x" using s and the corresponding index
    • Using string slicing, print out the word "brown"
    • Using string slicing, print out the word "lazy"
    • Using string slicing, print out starting at the word "jumped" through the end of the string
  1. Use the string variable s from Question 1. Create a loop that prints out every letter in the variable s
  1. Use the string variable s from Question 1. Create a loop that prints out every letter in s backwards starting from the end.
  1. Use the string variable s from Question 1. Create a loop that prints out every other letter in s starting from the beginning