Introduction to Python

chapter 1 Data Types

#用Tab or 空白鍵*4 表示indentation

data types

  1. integer: int ⇒ 5
  2. float: float ⇒ 5.53
  3. string: str ⇒ “Hi”
  4. boolean: bool ⇒ True/ False
  5. list: list ⇒ [1,’ggg’,True]
  6. dictionaries: dict ⇒ {”name”: “Jane”, “age”: 24}
  7. tuples: tup ⇒ (10,”yes”,True)
  8. sets: set {’a’,’b’}
#Numbers
print(10 + 2)
print(10 - 2)
print(10 * 2)
print(10 / 2)
print(10 // 3) #整數
#remainder(mod)
print(10 % 2) #0
print(10 % 3) #1
#power
print(2**3) #8
print(3**2) #9

built-in functions (* for typecasting)

  1. abs()
  2. str()*
  3. pow()
  4. max()
  5. min()