1. 程式人生 > >day 1 python全棧學習筆記(不完全版)

day 1 python全棧學習筆記(不完全版)

1.變數 :1 數字字母 下劃線任意組合,且不能以數字開頭。
2 不能是關鍵字
3 儘量使用有意義的名字
4 不要用中文


age_of_laomaohai = 15

2.常量:習慣用大寫

3.註釋: 單#
多''' '''


4.列印多個
print(1,2,3)

5.資料型別:

6.數字 int 12,3,34,
+-*/%
ps:type()

print(100,type(100))

7.字串: string 用引號引起來的是字串.
可相加 print("xiao"+"er") 拼接
可相乘 print("xiao"*8)

8.布林值:bool:只有True False

9.使用者互動:等待輸入
將輸入賦給變數
input 出來的都是str 型別

10.格式化輸出:%s (str) %d (digital) 也稱之為佔位符

如果想在輸出中單純的表示% 則需要%%表示。

x or y x為True ,則返回x

print (1 or 2) = 1
print (0 or 3) = 0

x and y x為True ,則返回y

print (1 and 2) = 2