Ad

version for Python 3.4.3

Code
Diff
  • import codecs
    
    def caesar(s):
        return codecs.encode(s, 'rot_13')
    
    • # caesar cipher shifted of 13 characters with maketrans for python 2.7
    • from string import maketrans
    • import string
    • import codecs
    • def caesar(s):
    • print(s)
    • s=s.translate(maketrans(string.ascii_uppercase, string.ascii_uppercase[13:]+string.ascii_uppercase[:13]))
    • return s
    • return codecs.encode(s, 'rot_13')
Algorithms
Logic
Mathematics
Numbers
Code
Diff
  • def factorial(x):
        return 0**x or x*factorial(x-1)
    • def factorial(x):
    • return 1 if x == 1 else x*factorial(x-1)
    • return 0**x or x*factorial(x-1)