Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

Lisa_Kramarenko

  • 3 years ago

Exercise OPT.2 – Secret Messages (Homework 1) I don't really get the step 3. Why should the values remain in range (0,5)? Or rather why do we have to do the modulus? Somehow I don't see how do I do it after I managed to replace all the letters with "x"'s. Thanks!

  • This Question is Closed
  1. Screech
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    I think I expressed a similar question when our class hit this exercise. You can review the thread of the discussion here http://openstudy.com/study#/updates/508f05b9e4b043900ad89834 Hope that the discussion which ensued clarifies the exercise for you

  2. aznation
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I agree with Screech's thread. That step is just poorly worded and can be basically ignored. Just focus on creating a function that will take a user's string input and return an ascii shifted message back. That is the purpose of the exercise. Good luck.

  3. aznation
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Looked closer at Opt.2 Secret Messages exercise: first I simply shifted the ascii value over by the designated amount ('A' = 65, shift 4 over would be '69'). This works fine for all characters except the last 9 of the set (88-97) and (120-129). These outer cases are where they expect us to modify our ascii character using the modulus operator to keep the secret letter value within the range A-Z or a-z respectively. Handle each range using for loops and the 'ord' and 'chr' functions from the examples.

  4. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy