#1.变量 name="张三" #变量名=变量值 age=18 hobby="打球" #print(hobby) #2.数据类型 a=66 #整形 int b=3.14 #浮点型 float c="hello" #字符串 str 凡是用引号包裹的文本都是字符串 d=True #布尔型 bool 判断真假 d2=False e=None #表示空 listt=[2,3,4,"a","bb","ccc"] #列表 list 在一个变量中存放多个数据 #3.选择结构 通过判断某一个表达式来决定执行什么代码 score=95 if score>90: print("优秀!") elif score>80: print("良好") elif score>60: print("及格") else: #相当于否则 print("差") #4.循环结构 #for循环 for i in range(3): print("for循环第",i+1,"次执行了!") #while循环 x=1 while x<=10: print("while循环第",x,"次执行了!") x=x+1 |
|
来自: 桃花源士 > 《python语言》