Skip to content
Portfolio

Python core concepts

var1 = "hello"
item = "Code 101"
print(type(item))
# Example of a single-line comment

When comparing floats directly, we may run into precision issues:

0.1 * 3 == 0.3 # False

To tackle this, we can use the math.isclose() function:

import math
math.isclose(0.1 * 3, 0.3) # True
  • +, -, *, /
  • / true division -> float
  • // floor division -> integer or float
  • % modulo -> remainder
  • ** -> power
  • Concatenation (+): Joins strings.
  • Length (len()): Gets the number of characters.
  • Indexing ([]): Access a character by position (0-based).
  • Slicing ([:]): Extract substrings.
  • .lower() / .upper()
  • .strip() / .lstrip() / .rstrip()
  • .startswith() / .endswith()
  • .split() / .join()
  • .replace()