Skip to content

Latest commit

 

History

History
25 lines (23 loc) · 668 Bytes

python.md

File metadata and controls

25 lines (23 loc) · 668 Bytes

Python

  • Function Declaration
challenge = lambda x, y, z: x + y + z

def challenge(x, y, z):
  ...
  return x + y + z
  • Logging
def challenge(x, y, z):
  print(x*y, y*z)
  return x + y + z
  • Python 2 vs Python 3 - / = integer division in Python 2 if both of operands are integers, // required for integer division in Python 3, `n` converts numbers to strings in Python 2, str(n) must be used in Python 3
5 / 2  # `2` in Python 2, `2.5` in Python 3
5 / 2. # `2.5` in Python 2 and Python 3
5 // 2 # `2` in Python 2 and Python 3
`4`    # `"4"` in Python 2, error in Python 3
str(4) # `"4"` in Python 2 and Python 3