Lecture 1 Finger Exercise

The questions below are due on Friday May 08, 2026; 11:59:00 PM.
 
You are not logged in.

Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.

Question 1. Assume the variable erised is accessible to you, and that it's bound to a positive int (i.e., greater than zero). Print the digits of that int in reverse order, consecutively on a single line, but without any leading zeros.

For example:

  • When erised = 6, your code should print 6.
  • When erised = 742, your code should print 247.
  • When erised = 1800, your code should print 81.
  • When erised = 15006, your code should print 60051.

Hint: Consider using type conversions between int and str, and also using str slicing.

Question 2. Assume the variables text and clip are accessible to you, each bound to a separate str. Determine the starting index location of the third appearance of clip within text, and print a message of the form shown in these examples:
  • When text = "cat cat dog cat dog", and clip = "cat", your code should print:
    The third appearance of cat is at index 12.
    
  • When text = "gogogadget goggles", and clip = "og", your code should print:
    The third appearance of og is at index 12.
    

You may assume clip contains only letters, and that there are at least three non-overlapping appearances ofclip within text.

Hint: Consider using the find() method of str objects. This method is documented in this section of the Python docs.