Introduction to Python
chapter 1 Data Types
#用Tab or 空白鍵*4 表示indentation
data types
- integer: int ⇒ 5
- float: float ⇒ 5.53
- string: str ⇒ “Hi”
- boolean: bool ⇒ True/ False
- list: list ⇒ [1,’ggg’,True]
- dictionaries: dict ⇒ {”name”: “Jane”, “age”: 24}
- tuples: tup ⇒ (10,”yes”,True)
- 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)
- abs()
- str()*
- pow()
- max()
- min()