Ex3 - Strings and Slices:

Objective: Learn how to problem solve with strings by using the length function and slicing.

Description: Similar to the problem outlined in the course notebook, let’s imagine we know a woman who can only say the beginning of words. When she attempts to say, franklin roosevelt, what is said is, fran ro. Create a script to predict what she is going to say.


  1. Name the file: Ex3_StringsAndSlices.py.
  2. Using comments, list the four coding steps in the file.
  3. Create and list in the second coding step two variables: word1 and word2.
  4. In the third coding step, use the length function and integer division to calculate the halfway index of the word assigned to the variable, word1. Similarly, for the word assigned to the variable, word2, calculate the quarter index of the word.
  5. Using the string slice shortcut, print the calculated halfway value, in addition to the calculated quarter value.
  6. The fourth coding step should have the following line:
python
1print(beginning1, beginning2)

Solution terminal output for the words, franklin roosevelt: fran ro