当前位置: 首页 > news >正文

c 建设网站iis软文新闻发布平台

c 建设网站iis,软文新闻发布平台,浙江省建设信息港特种查询,江苏廉政建设网站Python入门之最基础 IDLE有两种模式,一种是交互模式,通俗讲就是写一个代码,会得到相应的反馈,另一种为编辑模式. 注意事项: 标点符号一定要用英文符号 要注意缩进 dir(builtins)可以看到python所有的内置函数&#…

Python入门之最基础

IDLE有两种模式,一种是交互模式,通俗讲就是写一个代码,会得到相应的反馈,另一种为编辑模式.

注意事项:

标点符号一定要用英文符号
要注意缩进
dir(builtins)可以看到python所有的内置函数;

基本语法

变量相当于一个名字
这个数值呼唤惊到我了,太牛了。

x = 3
y = 5
x,y = y,x
print(x,y)
5 3

字符串(string)
‘’ “” 涉及到单引号双引号的时候,会用到转义字符 \

原始字符 row string
前面加 r 代表输出原始字符串

print(r"D:\three\two\one\now")
D:\three\two\one\now

若想字符换行,可在后加 \ ,可跨行

print("   *   \n\***  \n\*****")*   ***  *****

长字符串 Triple quoted,也叫三引号字符串,‘’‘前后呼应’‘’,“”“成双成对”“”。

字符串加法与数字加法截然不同

'520'+'1314''5201314'520+13141834

我每天爱你3000遍

print("我每天爱你3000遍\n" * 30)我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000遍
我每天爱你3000

if else语句与while语句

random随机数使用,生成1-10里的随机数

import random
random.randint(1,10)

random生成的随机数可以重现

x = random.getstate()
random.randint(1,10)
1
random.randint(1,10)
4
random.randint(1,10)
6
random.randint(1,10)
7
random.setstate(x)
random.randint(1,10)
1
random.randint(1,10)
4
random.randint(1,10)
6
random.randint(1,10)
7

数字类型

python数字类型分三种:整数、浮点数、复数

python的整数长度是不受限制的,可以随时随地进行大数运算

python的浮点数 ,是不是很惊讶,我也表示有点惊讶,原来我的口算能力还可以hhhhhh。

0.1+0.2
0.30000000000000004i = 0
while i < 1:i = i + 0.1print(i)0.1
0.2
0.30000000000000004
0.4
0.5
0.6
0.7
0.7999999999999999
0.8999999999999999
0.9999999999999999
1.0999999999999999

python的浮点数是采用IEEE754的标准来存储浮点数的,会产生一定精度的误差。

复数 包含实部和虚部

1+2j
(1+2j)
x = 1 + 2j
x.real
1.0
x.imag
2.0

地板除 //,向下取整

在这里插入图片描述

3/2
1.5
3//2
1
1//2
0
-3 // 2
-2

x == (x // y) * y + (x % y)

divmod(-3,2)
(-2, 1)
-2 * 2 + 1
-3

在这里插入图片描述

x = -520
abs(x)
520
y = -3.14
abs(y)
3.14
z = 1 + 2j
abs(z)
2.23606797749979
int('520')
520
int(3.14)
3
int(520)
520
int(9.99)
9
float(3.14)
3.14
float('3.14')
3.14
float(520)
520.0
complex("1+2j")
(1+2j)
complex("1 + 2j")
Traceback (most recent call last):File "<pyshell#243>", line 1, in <module>complex("1 + 2j")
ValueError: complex() arg is a malformed string pow(2,3)
8
pow(2,3,5)
3
2 ** 3 % 5
3

在这里插入图片描述
fraction(0,1)表示分子为0,分母为1。

bool(None)
False
bool(False)
False
bool(0)
False
bool(0.0)
False
bool(0j)
False
bool(decimal.Decimal(0))
Falseimport fractions
bool(fractions.Fraction(0,1))
False

bool运算

1 == True
True
0 == False
True
True + False
1
True - False
1
True * False
0
True / False
Traceback (most recent call last):File "<pyshell#25>", line 1, in <module>True / False
ZeroDivisionError: division by zero

逻辑运算符

在这里插入图片描述

3 < 4 and 4 < 5
True
3 > 4 and 4 < 5
False
3 < 4 and 4 > 5
False
3 > 4 and 4 > 5
False3 < 4 or 4 < 5
True
3 > 4 or 4 < 5
True
3 < 4 or 4 > 5
True
3 > 4 or 4 > 5
Falsenot True
False
not False
True
not 250
False
not 0
True
250
250

短路逻辑的核心思想

从左往右,只有当第一个操作数的值无法确定逻辑运算的结果时,才对第二个操作数进行求值。

(not 1) or (0 and 1) or (3 and 4) or (5 and 6) or (7 and 8 and 9)
4False or 0 or 4 or 6 or 9
43 and 4
4
3 or 4
3
0 and 3
0
0 or 4
4

运算符优先级

注意:优先级 1 比 2 小。
在这里插入图片描述

1 + 2 > 3 - 4
True
not 1 < 2
False
not 1
False
0 or 1 and not 2
Falsenot 1 or 0 and 1 or 3 and 4 or 5 and 6 or 7 and 8 and 9
4
False or 0 or 4 or 6 or 9
4

好棒好棒,了解了这么多知识点,初入python,加鸡腿加脑子,继续努力。

http://www.dt0577.cn/news/30377.html

相关文章:

  • 精美 企业网站模板韶关网站seo
  • 浙江融兴建设有限公司网站关键词排名查询工具有什么作用?
  • 做视频类型的网站关键词优化排名费用
  • 贺州 网站建设公司有哪些今日新闻播报
  • 互联网10大厂seo基础培训教程
  • 做网站怎么这么贵百度搜索引擎api
  • ASP做网站源代码网络营销案例实例
  • 重庆网站建设哪家公司那家好杭州seo排名收费
  • 网站开发系统绿色版网站做优化好还是推广好
  • 做愛黄色视频网站福利西地那非片多少钱一盒
  • 城乡建设委员会网站房产栏目网页设计制作网站图片
  • joomla做类似赶集网的网站下载百度网盘app最新版
  • 如何推广小程序福州seo网站推广优化
  • 哪里可做网站营销推广软件有哪些
  • 网页制作免费网站建设成都网站快速排名
  • 做网站之前的工作最近发生的新闻
  • 制作app软件工具免费高端网站优化公司
  • 做机械设计兼职的网站怎么做网站宣传
  • 网站seo优化报告网络推广方案书模板
  • 哈尔滨营销网站建设公司seo排名快速
  • 网站后台功能需求文档北京seo优化多少钱
  • 福清建设银行网站地推拉新app推广平台
  • 公众号网站制作天津短视频seo
  • 外贸饰品网站快速排名怎么做
  • wordpress链接重建厦门百度整站优化服务
  • 浙0577 icp网站建设推广竞价
  • 重庆平台网站推广怎么免费自己做推广
  • 建公司网站需要自己有系统吗关键词查询网站的工具
  • 常州做网站包括哪些广州网站建设系统
  • 68设计网站长春网站快速优化排名