day001-s0【课堂笔记】

1,计算机基础。
2,python历史。

宏观上:python2 与 python3 区别:
python2 源码不标准,混乱,重复代码太多,
python3 统一 标准,去除重复代码。
3,python的环境。

编译型:一次性将所有程序编译成二进制文件。
缺点:开发效率低,不能跨平台。
优点:运行速度快。
:C,C++等等。

解释型:当程序执行时,一行一行的解释。
优点:开发效率高,可以跨平台。
缺点:运行速度慢。
:python ,php,等等。

4,python的发展。
5,python种类。

运行第一个py文件:
python3x :python 文件路径 回车
python2x :python2 文件路径 回车
python2 python3 区别:python2默认编码方式是ascii码
解决方式:在文件的首行:#-*- encoding:utf-8 -*-
python3 默认编码方式utf-8


6,变量。
变量:就是将一些运算的中间结果暂存到内存中,以便后续代码调用。
1,必须由数字,字母,下划线任意组合,且不能数字开头。
2,不能是python中的关键字。
['and', 'as', 'assert', 'break', 'class', 'continue',
'def', 'del', 'elif', 'else', 'except', 'exec',
'finally', 'for', 'from', 'global', 'if', 'import',
'in', 'is', 'lambda', 'not', 'or', 'pass', 'print',
'raise', 'return', 'try', 'while', 'with', 'yield']
3,变量具有可描述性。
4,不能是中文。
7,常量。
一直不变的量。 π
BIR_OF_CHINA = 1949


8,注释。
方便自己方便他人理解代码。
单行注释:#
多行注释:'''被注释内容''' """被注释内容"""


9,用户交互。input
1,等待输入,
2,将你输入的内容赋值给了前面变量。
3,input出来的数据类型全部是str

10,基础数据类型初始。
数字:int 12,3,45
+ - * / **
% 取余数
ps:type()
字符串转化成数字:int(str) 条件:str必须是数字组成的。
数字转化成字符串:str(int)
字符串:str,python当中凡是用引号引起来的都是字符串。
可相加:字符串的拼接。
可相乘:str * int
bool:布尔值。 True False。


11,if。

if 条件:
结果

12,while。

while 条件:
循环体
无限循环。
终止循环:1,改变条件,使其不成立。
2,break

continue

计算机基础。
cpu:相当于人的大脑,用于计算。

内存:储存数据,4G,8G,16G,32G,成本高,断电即消失。
硬盘:1T,固态硬盘,机械硬盘,储存数据,应该长久保持数据,重要文件,小电影等等。
操作系统:
应用程序。

  1 #-*- encoding:utf-8 -*-
  2 #print('我爱中国')
  3 '''
  4 x = 1+2+3+4
  5 print(x)
  6 print(x*5)
  7 y = x*5
  8 print(y+100-45+2)
  9 
 10 print('泰哥泰哥,我是小弟')
 11 print('泰哥泰哥,我是三弟小妹')
 12 
 13 
 14 t-t = 2
 15 3t_t = 23
 16 *r = 4
 17 _ = 'fdsa'
 18 ___ = 4
 19 %- = 'fdsa'
 20 2w = 5
 21 qwe-r = 'wer'
 22 
 23 kfdsdlafhsdakfhdsakdfjkhsdakf = '太白'
 24 print(名字)
 25 AgeOfOldboy = 56
 26 
 27 NumberOfStudents = 80
 28 
 29 #下划线
 30 
 31 age_of_oldboy = 56
 32 
 33 number_of_students = 80
 34 
 35 
 36 age1 = 12 
 37 age2 = age1
 38 age3 = age2
 39 age2 = 100
 40 age3 = 5
 41 print(age1,age2,age3) #12, 100 ,100
 42                       #12,12,12,
 43                       #12,100,12
 44                       #100,100,100,
 45 
 46 print(100,type(100))
 47 print('100',type('100'))
 48 
 49 print(1)
 50 print("jsdfdsfsadl;fjdsal;j")
 51 print("I'm a teacher")
 52 
 53 
 54 a = '泰哥'
 55 b = '小二'
 56 c = a + b
 57 print(c)
 58 print('泰哥' + '小二' +'货')
 59 
 60 print('坚强'*8)
 61 
 62 
 63 msg = """
 64 今天我想写首小诗,
 65 歌颂我的同桌,
 66 你看他那乌黑的短发,
 67 好像一只炸毛鸡。
 68 """
 69 #print(msg)
 70 print(True,type(True))
 71 print('True',type('True'))
 72 
 73 name = input('请输入你的名字:')
 74 age = input('请输入你的年龄:')
 75 print('我的名字是'+name,'我的年龄'+age+'岁')
 76 '''
 77 #第一种:
 78 '''
 79 if 4 > 5 :
 80     print('我请你喝酒')
 81 print('喝什么酒')
 82 
 83 #第二种:
 84 if 4 > 5:
 85     print('我请你喝酒')
 86 else:
 87     print('喝什么酒')
 88 '''
 89 
 90 '''
 91 #多选:
 92 num = input('请输入您猜的数字:')
 93 
 94 if num == '1':
 95     print('一起抽烟')
 96 elif num == '2':
 97     print('一起喝酒')
 98 elif num == '3':
 99     print('新开了一家,走看看')
100 else:
101     print('你猜错了.....')
102 
103 
104 score = int(input("输入分数:"))
105 
106 if score > 100:
107     print("我擦,最高分才100...")
108 elif score >= 90:
109     print("A")
110 elif score >= 60:
111     print("C")
112 elif score >= 80:
113     print("B")
114 elif score >= 40:
115     print("D")
116 else:
117     print("太笨了...E")
118 
119 name = input('请输入名字:')
120 age = input('请输入年龄:')
121 
122 if name == '小二':
123     if age == '18':
124         print(666)
125     else:
126         print(333)
127 else:
128     print('错了....')
129 '''
130 
131 
132 #while
133 '''
134 print('111')
135 while True:
136     print('我们不一样')
137     print('在人间')
138     print('痒')
139 print('222')
140 '''
141 #从1--100 
142 '''
143 count = 1
144 flag = True
145 #标志位
146 while flag:
147     print(count)
148     count = count + 1
149     if count > 100 :
150         flag = False
151 
152 
153 count = 1
154 while count <= 100:
155     print(count)
156     count = count + 1
157 
158 
159 count = 1
160 sum = 0
161 
162 while count <= 100:
163     sum = sum + count 
164     count = count + 1
165     
166 print(sum)
167 '''
168 
169 #break
170 '''
171 print('11')
172 while True:
173     print('222')
174     print(333)
175     break
176     print(444)
177 print('abc')
178 
179 count = 1
180 while True:
181     print(count)
182     count = count + 1
183     if count > 100:break
184 
185 
186 
187 
188 print(111)
189 count = 1
190 while count < 20 :
191     print(count)
192     continue
193     count = count + 1
194 '''
195     
196 count = 0
197 while count <= 100 : 
198     count += 1
199     if count > 5 and count < 95: 
200         continue 
201     print("loop ", count)
202 
203 print("-----out of while loop ------")
204     
dear every one: 我从小就有IT梦,长大我更想有个IT之家! by:henry_oulen.
原文地址:https://www.cnblogs.com/meticuloustodo/p/9695759.html