【正文】
條件式敘述 (Conditional Statements) Part I ? ifelse if a b: z = b else: z = a ? pass 敘述 – 不做任何事時使用 if a b: pass else: z = a 條件式敘述 (Conditional Statements) Part II ? elif敘述 if a == ?+?: op = PLUS elif a == ??: op = MINUS else: op = UNKNOWN ? 沒有像 C語言一樣,有 switch的語法 ? 布林表示式 – and, or, not if b = a and b = c: print ?b is between a and c? if not (b a or c c): print ?b is still between a and c? 基本型態(tài) (Numbers and String) ? Numbers (數(shù) ) a = 3 Integer (整數(shù) ) b = Float point (浮點數(shù) ) c = 51728888333L Long Integer (精準(zhǔn)度無限 ) d = 4 + 3j Complex number (複數(shù) ) ? Strings (字串 ) a = ?Hello? Single quotes b = “World” Double quotes c = “Bob said ?hey there.?” A mix of both d = ???A triple qouted string can span multiple lines like this??? e = “””Also works for double quotes””” 基本型態(tài) – 串列 (Lists) ? 任意物件的串列 a = [2, 3, 4] A list of integer b = [2, 7, , “Hello”] A mixed list c = [] An empty list d = [2, [a, b]] A list containing a list e = a +