Guest User

Untitled

a guest
Jan 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. shift = raw_input ("Enter a value to shift the alphabet by... ")
  2.  
  3. alphaDict = {}
  4.  
  5. alphaList = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
  6.  
  7. for shift in alphaList:
  8.  
  9. alphaList.append (alphaDict)
  10.  
  11. alphaDict = 'a'
  12.  
  13. alphaDict = chr(ord( What value would go here? + 1)
  14.  
  15. letter = "A"
  16. letter = chr(ord(letter) + 1)
  17. # letter is now "B"
  18.  
  19. def caesar(s, k, decode = False):
  20. if decode: k = 26 - k
  21. return "".join([chr((ord(i) - 65 + k) % 26 + 65)
  22. for i in s.upper()
  23. if ord(i) >= 65 and ord(i) <= 90 ])
  24.  
  25. msg = "The quick brown fox jumped over the lazy dogs"
  26. print msg
  27. enc = caesar(msg, 11)
  28. print enc
  29. print caesar(enc, 11, decode = True)
  30.  
  31. print "Enter senctence: "
  32. sentence = raw_input()
  33. print "Enter shift: "
  34. shift = raw_input()
  35. result = ""
  36. for letter in sentence:
  37. ascii = (ord(letter) + int(shift))%123
  38. if ascii < 97:
  39. ascii = ascii + 97
  40. result = result + chr(ascii)
  41.  
  42. print result
  43.  
  44. import string # import library
  45.  
  46. try:
  47. shift = int(raw_input ('Enter a value to shift the alphabet by... ')) # set amount of shift
  48. except ValueError: # if an integer is not entered
  49. print 'You must enter an integer!'
  50. table = string.maketrans(string.lowercase, string.lowercase[shift:]+string.lowercase[:shift]) # make a translation table from abc...xyz shifted letters
  51. text = raw_input('Enter Text: ') # get input
  52. print text.translate(table); # print translation
  53.  
  54. import string # import library
  55.  
  56. try:
  57. shift = int(raw_input ('Enter a value to shift the alphabet by... ')) # set amount of shift
  58. except ValueError: # if an integer is not entered
  59. print 'You must enter an integer!'
  60. table = string.maketrans(string.lowercase, string.lowercase[shift:]+string.lowercase[:shift]) # make a translation table from abc...xyz shifted letters
  61. print text.translate(string.lowercase); # print translation
Add Comment
Please, Sign In to add comment