Tipe Data dan Variabel (2)

Posted on September 24th, 2023
Beginner
...

Berikut tipe data yang ada di Python:

  • Text          = str
  • Numeric   = int, float, complex
  • Sequence = list, tuple, range
  • Mapping  = dict
  • Set           = set, frozenset
  • Boolean   = bool
  • Binary      = bytes, bytearray, memoryview
  • None       = NoneType

Membuat langsung tipe data pada variable

x = str("Hello World")
x = int(20)
x = float(20.5)
x = complex(1j)
x = list(("apple", "banana", "cherry"))
x = tuple(("apple", "banana", "cherry"))
x = range(6)
x = dict(name="John", age=36)
x = set(("apple", "banana", "cherry"))
x = frozenset(("apple", "banana", "cherry"))
x = bool(5)
x = bytes(5)
x = bytearray(5)
x = memoryview(bytes(5))