2019年4月23日
摘要: 列表的介绍 列表是python的基础数据类型之⼀ ,其他编程语⾔也有类似的数据类型. 比如JS中的数 组, java中的数组等等. 它是以[ ]括起来, 每个元素用' , '隔开而且可以存放各种数据类型 列表的索引和切片 和字符串的一样 列表的增删改查 s = ['asd','wer','rer', 阅读全文
posted @ 2019-04-23 19:58 Little_Raccoon 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 把字符连成串. 在python中用', ", ''', """引起来的内容被称为字符串. 字符串是不可变的类型,不论你执行任何操作,原来的字符串都不会变的 字符串的索引和切片 索引 索引就是下标. 切记, 下标从0开始 切片 切片语法: str[start:end:step] start: 起始位置 阅读全文
posted @ 2019-04-23 15:56 Little_Raccoon 阅读(242) 评论(0) 推荐(0) 编辑
摘要: n = int(input("请输入一个数:")) count = 1 while True: if n // (10**count) != 0: count += 1 else: print("这个数是%s位数"%count) break 阅读全文
posted @ 2019-04-23 11:21 Little_Raccoon 阅读(1140) 评论(0) 推荐(0) 编辑
摘要: n = int(input("请输入一个数:")) if n == 1: print("不是质数") else: count = 2 while count <= n-1: if n % count == 0: print("不是质数") break count += 1 else: ... 阅读全文
posted @ 2019-04-23 11:20 Little_Raccoon 阅读(242) 评论(0) 推荐(0) 编辑
摘要: ad = input("请输入广告标语:") if "最" in ad or "第一" in ad or "国家级" in ad or "稀缺" in ad: print("广告不合法. 把设计人拉出去毙了") else: print("OK的") 阅读全文
posted @ 2019-04-23 11:00 Little_Raccoon 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 给3次机会输出用户名和密码,显示每次输入后还剩几次机会 count = 1 while count <= 3: user_name = input("请输入用户名:") user_password = input("请输入密码:") if user_name == "Raccoon" and user_password == "123" : print(... 阅读全文
posted @ 2019-04-23 10:55 Little_Raccoon 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 1-100内求和 count = 1 sum = 0 while count <= 100: sum = sum + count count +=1 print(sum) 1-100内的所有奇数 count = 1 while count < 100: if count % 2 != 0: print(count) count += 1 ... 阅读全文
posted @ 2019-04-23 10:24 Little_Raccoon 阅读(1692) 评论(0) 推荐(0) 编辑
摘要: 用while语句写猜大小游戏 普通版 n =80 user_input = int(input("请输入一个数:") while True: if user_input < n: print("猜小了") elif user_input > n: print("猜大了") else: print(" 阅读全文
posted @ 2019-04-23 10:09 Little_Raccoon 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 1.算数运算 + - * / %(取模)返回余数 a = b * q + r q(为商) r(为余数) 例如 7/3 商为2 余数为7-3*2=1;-7/3商为-3(取比结果的小的最大整数),余数为-7+3*3=2 **(幂) //(整除)放回商 2.比较运算 ==(等于) !=(不等于) <>(不 阅读全文
posted @ 2019-04-23 07:47 Little_Raccoon 阅读(173) 评论(0) 推荐(0) 编辑