Ad
Code
Diff
  • factorial = lambda n: 1 if n <= 1 else n * factorial(n-1)
    • factorial = lambda n: n if n == 1 else n * factorial(n-1)
    • factorial = lambda n: 1 if n <= 1 else n * factorial(n-1)
Code
Diff
  • factorial = lambda n: n if n == 1 else n * factorial(n-1)
    • def factorial(n):
    • if n == 1:
    • return 1
    • else:
    • return n * factorial(n-1)
    • factorial = lambda n: n if n == 1 else n * factorial(n-1)
Code
Diff
  • digit_sum = lambda num: sum(int(x) for x in str(abs(num)))
    
    • def digit_sum(number: int) -> int:
    • return sum([int(num) for num in str(number) if num.isdigit()])
    • digit_sum = lambda num: sum(int(x) for x in str(abs(num)))
Code
Diff
  • Hello_Python = lambda: "Hello Python!"
    • def Hello_Python():
    • return "Hello" + " " + "Python!"
    • Hello_Python = lambda: "Hello Python!"
Fundamentals
Numbers
Data Types
Integers
Code
Diff
  • is_odd = lambda x: x&1
    • def is_odd(input):
    • return input & 1
    • is_odd = lambda x: x&1