1、變量的賦值
字母被引號標注起來就是字符串,未被標注就是變量名
name = "jbzhang" name2 = name print (name,name2) name ="jbz" print(name2)
內存回收:創建的內存空間,當沒有變量指向的時候,內存空間就會被清空或者直接刪除。
比如:
1.直接刪除
age=21
del age
2.取消指向
age=22
age=23
2.if語句實現猜年齡
age_of_princal = 56 guess_age = int(input(">>:")) if guess_age == age_of_princal: print("yes,you got it..") else: print("no,it's wrong..")
3.多分支if語句
score = int(input("score:")) if score > 90: print("A") elif score > 80: print("B") elif score > 70: print("C") elif score > 50: print("D") else: print("滾")