pdpinch
  • pdpinch
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)
jamiebookeater
  • jamiebookeater
See more answers at brainly.com
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.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

anonymous
  • anonymous
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.
pdpinch
  • pdpinch
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?
anonymous
  • anonymous
Is this the point at which I fess up that I skipped the optionals? ; )

Looking for something else?

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

More answers

anonymous
  • anonymous
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).

Looking for something else?

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