摘要: and or not 优先级,()> not > and > or print(3>4 or 4<3 and 1==1) # F print(1 < 2 and 3 < 4 or 1>2) # T print(2 > 1 and 3 < 4 or 4 > 5 and 2 < 1) # T print 阅读全文
posted @ 2020-06-06 20:44 烟斗和沙漏 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 当while循环被break打断,就不会执行else结果。 count = 0 while count < 5: count += 1 if count == 3 : break print('loop',count) else: print('循环正常执行完成了') print(' out of 阅读全文
posted @ 2020-06-06 08:59 烟斗和沙漏 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 当取一个格式,按照格式填写数字时,我们通常用%占位符来显示。 s 字符串变量 d(digit)数字。 name = input('请输入您的名字:') age = int(input('请输入您的年龄:')) job = input('请输入您的职业:') hobbie= input('请输入您的爱 阅读全文
posted @ 2020-06-05 22:57 烟斗和沙漏 阅读(560) 评论(0) 推荐(0) 编辑
摘要: 1、使用while循环输入1 2 3 4 5 6 8 9 10 count = 0 while count < 10: count =count + 1 if count < 7 or count > 7 : print(count) else: continue; 2、求1-100所有的和 cou 阅读全文
posted @ 2020-05-26 22:58 烟斗和沙漏 阅读(149) 评论(0) 推荐(0) 编辑
摘要: while条件: 循环体 无限循环 while True: print('吃饭') print('睡觉') print('打豆豆') 终止循环:1、改变条件。使其不成立 count = 1 while count <=100: print(count) count = count+1 2、break 阅读全文
posted @ 2020-05-24 17:31 烟斗和沙漏 阅读(182) 评论(0) 推荐(0) 编辑
摘要: if 条件: 结果 a = 1 b = 2 if a < b: print('今天会下雨') if+交互 score = int (input'请输入您的分数:') if score > 100: print('我擦,最高才100分......') elif score > 90: print('A 阅读全文
posted @ 2020-05-19 13:29 烟斗和沙漏 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 数字int:1、2、3、4、5。 + - * / ** % 取余数 ps:type(数字或'字符串') 字符串转化成数字:int(str) 条件:str必须是数字组成的。 数字转化成字符串:str(int) print(100,type(100)) print('100',type('100')) 阅读全文
posted @ 2020-05-18 16:52 烟斗和沙漏 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 用户交互 input 1,等待输入 2,将你输入的内容赋值给了前面变量。 3,input出来的数据类型全部是str name = input('请输入你的名字:') age = input('请输入你的年龄:') print('我的名字是'+name,'我的年龄'+age+'岁') 阅读全文
posted @ 2020-05-18 16:48 烟斗和沙漏 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 常量一直不变的量,如生活中的π。 通常python大写的变量指为常量。 BIR_OF_CHINA = 1949 阅读全文
posted @ 2020-05-18 16:23 烟斗和沙漏 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 什么是变量? 变量就是将一些运算的结果暂存在内存中,以便后续代码调用。 1、必须是数字,字母、下划线任意组合,且不能数字开头。 2、不是python中的关键字。 ['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', ' 阅读全文
posted @ 2020-05-18 16:21 烟斗和沙漏 阅读(114) 评论(0) 推荐(0) 编辑