Lecture Notes on 2 August 2013 def encrypt_lowercase (ch, n): n = n % 26 return (chr (ord('a') + (ord(ch) - ord ('a') + n) % 26)) def decrypt_lowercase (ch, n): n = n % 26 return (chr (ord('z') - (ord('z') - ord(ch) + n) % 26)) def main(): s = input ("Enter string: ") n = eval (input ("Enter shift: ")) new_s = '' for ch in s: if ((ch < 'a') or (ch > 'z')): new_s = new_s + ch else: new_ch = encrypt_lowercase (ch, n) new_s = new_s + new_ch print (new_s) old_s = '' for ch in new_s: if ((ch < 'a') or (ch > 'z')): old_s = old_s + ch else: new_ch = decrypt_lowercase (ch, n) old_s = old_s + new_ch print (old_s) main() def main(): print ('Think of a number between 1 and 100') lo = 1 hi = 100 while (lo <= hi): mid = (lo + hi) // 2 response = eval (input ('You thought of ' + str(mid) + ': ')) if (response > 0): hi = mid - 1 elif (response < 0): lo = mid + 1 else: print ('Thank you for playing the guessing game') return print ('Sorry I could not figure out') main() def merge (a, b): c = [] idxA = 0 idxB = 0 while ((idxA < len(a)) and (idxB < len(b))): if (a[idxA] < b[idxB]): c.append (a[idxA]) idxA = idxA + 1 else: c.append (b[idxB]) idxB = idxB + 1 while (idxA < len(a)): c.append (a[idxA]) idxA = idxA + 1 while (idxB < len(b)): c.append (b[idxB]) idxB = idxB + 1 return c