Ace school

with brainly

  • Get help from millions of students
  • Learn from experts with step-by-step explanations
  • Level-up by helping others

A community for students.

I managed to get the cipher script working in optional exercise 2 in http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-189-a-gentle-introduction-to-programming-using-python-january-iap-2011/assignments/MIT6_189IAP11_hw1.pdf https://gist.github.com/3802851 But it seems like I'm repeated myself a lot in the code. Any suggestions for simplifying?

MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer

SEE EXPERT ANSWER

To see the expert answer you'll need to create a free account at Brainly

There are two ways I've written this: http://pastebin.com/Bt0FkzGw With the first, I rewrote it completely myself with the goal of writing it with no other function dependencies than ord and chr, while still being readable With the second, I used your code and moved the repeated code into a function. Read over each and see which style you like best.
Wow, thatnks, there's a lot of food for though there. I was a little hamstrung because I haven't gotten to the part of the course on functions yet. I actually really like the fist version you did, because I think the code is much more readable. The if... In construct seems really useful, and probably would have made some of my earlier programs easier to read. I've never seen %= before. Is that a common operator?
Is this the point at which I fess up that I skipped the optionals? ; )

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

I don't know any languages that have += that don't have %=, if that's what you mean. Either way, %= isn't something I use often. Usually when you want to mod something, you can put the mod somewhere else (just add it to the end of another line).

Not the answer you are looking for?

Search for more explanations.

Ask your own question