- 博客(6)
- 收藏
- 关注
原创 Python学习之random模块2022.4.7
1.random模块是与生成随机数相关的模块,这个模块里包含一个函数为randint(),它会返回一个随机的整数。remark:使用一个外部模块之前需导入。(import this 就是将random模块导入到当前文件中。)>>> import random>>> random.randint(1,10)2.查找Python官方自带的文档(Python Docs):IDLE的右上角Help...
2022-04-07 16:42:28
992
原创 Python学习之while循环语法2022.4.2
1.while 条件:如果条件为真(True)执行这里的语句>>> counts = 3>>> while counts > 0: print("小雨晴想吃火锅") counts = counts - 1 小雨晴想吃火锅小雨晴想吃火锅小雨晴想吃火锅2.counts = counts + 1与最外层中的else中的语句并列时,那么用户输入任何数字都会循环三次;counts = counts + 1多一个缩进,那么用户只有输入小于3的数字才会循
2022-04-02 21:01:07
1062
原创 Python学习之条件分支2022.4.1
1.int需用户配合输入数字。>>> temp = input("你是谁?")你是谁?>>> temp = input("你是谁:")你是谁:小雨晴>>> print(temp)小雨晴>>> int(temp)Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> int(temp)Va
2022-04-01 22:08:47
757
原创 Python学习之字符串2022.3.31
1.字符串指文本,是引号内(包含单引号和双引号)的一切东西。>>> print("Let's go!")Let's go!>>> print('Let's go!') SyntaxError: invalid syntax>>> print('\"Let\'s go!\"')"Let's go!">>> print('"Life is short,you need Python."')"Life is
2022-03-31 21:56:59
728
原创 Python学习之变量2022.3.30
1.使用变量之前,需要对其先赋值。>>> print("小雨晴")小雨晴>>> 小雨晴=24>>> print(小雨晴)242.变量的值取决于最后一次赋值操作。>>> x=3>>> x=6>>> print(x)63.变量名可以包括字母、数字、下划线,但不能以数字开头。>>> z=1>>> print(z)1>
2022-03-30 16:44:00
724
原创 python学习2022.3.29
1.大数运算 123144234234*3425555345452.字符串和数字做乘法,结果是重复显示N个字符串(\n表示换行)print("我要吃饭\n"*3)我要吃饭我要吃饭我要吃饭3. 小彩蛋(输入import this) import thisThe Zen of Python, by Tim PetersBeautiful is better than ugly.Explicit is better than implicit.Simple is bett
2022-03-29 14:40:48
340
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人