Python Challenge 1


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #1
  2. import string
  3.  
  4. frm = "abcdefghijklmnopqrstuvwxyz"
  5. to = "cdefghijklmnopqrstuvwxyzab"
  6.  
  7. data = """g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp.
  8. bmgle gr gl zw fylbgq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle.
  9. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."""
  10.  
  11. print string.translate(data, string.maketrans(frm,to))
  12.  
  13.  
  14. #2
  15. import string
  16.  
  17. frm = "abcdefghijklmnopqrstuvwxyz"
  18. to = "cdefghijklmnopqrstuvwxyzab"
  19.  
  20. data = """g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp.
  21. bmgle gr gl zw fylbgq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle.
  22. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."""
  23.  
  24. result = ''
  25.  
  26. for c in data:
  27. if c in frm:
  28. result += to[frm.index(c)]
  29. else:
  30. result += c
  31.  
  32. print result
  33.  
  34.  
  35. #3
  36. import string
  37. s = " "
  38. for c in t :
  39. if c in string.letters :
  40. s += chr((ord(c) + 2 - 97) % 26 + 97)
  41. else :
  42. s += c
  43. print s
  44. </code>

URL: http://www.pythonchallenge.com/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.