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

宝山做网站价格在哪个网站可以免费做广告

宝山做网站价格,在哪个网站可以免费做广告,商标查询官网入口免费,免费添加地图上的定位1. 变量 1.1. 变量的创建 变量的定义规则: 变量只能由数字,字母,下划线构成,不能包含特殊符号数字不能作为变量开头变量名不能和 Python 的关键字重复Python 的变量是区分大小写的 除了上述的硬性规则外,还建议变量…

1. 变量

1.1. 变量的创建

变量的定义规则:

  1. 变量只能由数字,字母,下划线构成,不能包含特殊符号
  2. 数字不能作为变量开头
  3. 变量名不能和 Python 的关键字重复
  4. Python 的变量是区分大小写的

除了上述的硬性规则外,还建议变量的取名应该遵守见名知意的原则,还有驼峰或者蛇形命名规范

例如 maxSum / max_sum

变量的创建:

通过“ = ”可以对变量进行创建和赋值

avg = (10 + 20 + 30 + 40) / 4
print(avg)

1.2. 变量的类型

Python 中变量的类型不需要在定义变量的显示声明,只需要依靠初始化语句,根据初始化的值来进行确定

  1. 整数 int 。Python 中的 int 表示的整数是没有范围的,不像 C++ 和 Java 中 int 的最大值为 2 的 31 次方
num1 = 10000000000000000000
num2 = 10000000000000000000
print(type(num1))
print(num1 + num2)

  1. 浮点数 float 。Python 中的浮点数是双精度的,占用 8 个字节,没有单精度
  2. 字符串 str . Python 中的字符串用单引号和双引号都可以,根据这个特性,就可以实现一个字符串中可以带上双引号,不用再像 Java 中进行拼接了
e = 'my name is "shuaige"'
print(e)

还可以使用三引号

e = '''my 'name' is "shuaige"'''
print(e)

Python 中也可以进行字符串的拼接

string1 = 'hello '
string2 = 'word'
print(string1 + string2)

还可以通过 len() 函数求出字符串的长度

print(len(string1))

布尔类型 : True / False

动态类型 : 在程序运行过程中,变量的类型可能会发生改变

a = 10
print(type(a))
a = 'hello'
print(type(a))
a = True
print(type(a))

Python 是一个动态类型的语言, 在定义类型的时候也可以选择声明变量类型, 但后续类型还是可以改变

a : int = 10

2. 注释

在 Python 中是使用 # 来表示注释的

# 打印 a 的类型
print(type(a))

还可以通过文档字符串的形式来表示文档注释,通过三个引号来表示,单引号和双引号都可以

"""这是一个文档字符串,表示文档注释  
"""

3. 输入输出

之前一直用的 print 就是输出的函数,可以直接传入变量,常量进行打印

格式化输出:

a = 10
print(a)
print(f"a = {a + 10}")

如果直接打印 a ,就是打印它本身被赋予的常量,通过 f - string (格式化字符串)的方式可以在字符串中嵌入变量或者表达式,实现格式化输出的效果

输入:

num = input("请输入一个数字:")
print(f"您输入的数字是:{num}")

input 执行的时候就会等待用户输入,还可以传入字符串作为输入提示

input 返回的是一个字符串,如果想要进行整形的计算,就需要进行转换:

num1 = input("请输入一个数字:")
num2 = input("请输入一个数字:")
print(f"{num1} + {num2} = {int(num1) + int(num2)}")

同理,还有 str() ,float() 等其他类型的转换

4. 运算符

4.1. 算术运算符

在 Python 中除了有 + ,- , * ,/ 之外,还有 乘方 **, //(地板除法,向下取整) 的运算符,并且 Python 中的 / 是可以得到小数的,并不像 Java 那样取整数部分

print(1 / 2)
print(2 ** 2)
print(2 ** 0.5)
print(3 // 2)
print(-7 // 2)

** 运算符可以是整数也可以是小数,上面的 -7 // 2 ,按理说是 -3.5 ,由于向下取整,就往更小的方向取,也就是 -4

4.2. 关系运算符

> , < , == , >= , <= , != 这些关系运算符都是和 Java 一样的,需要注意的是,关于 str 的比较是可以使用 == 和 != 来进行比啊交的,这一点和 Java 不同

还有关于浮点数的比较,使用 == 来比较的话是存在一定问题的,因为浮点数在内存中的存储和表示是可能存在误差的,这样的误差在进行算术运算时就可能会被放大

print(0.1)
print(0.2)
print(0.1 + 0.2)
print(0.1 + 0.2 == 0.3)

Python 中还支持连续比较的写法,Java 中是不支持的

print(1 < 2 < 3)

4.3. 逻辑运算符

and : 逻辑与,相当于 Java 中的 &&

or:逻辑或,相当于 Java 中的 ||

not :逻辑取反,相当于 Java 中的 !

短路求值:和 Java 中是一样的,在进行 and 判断时,左边的判断为 False,那么右边就不用执行了,进行 or 判断时,左边判断为 True ,右边就不用执行了

4.4. 赋值运算符

= 就是赋值运算符,Python 中有以下几种赋值操作

a = 10
a = b = 10
a,b = 10,20

还有 += ,-= ,*=,&=,/=,**=,//= 这样的操作,而自增++,自减--,这样的操作在 Python 中是不支持的


文章转载自:
http://dinncolensman.wbqt.cn
http://dinncobathochrome.wbqt.cn
http://dinncounderpan.wbqt.cn
http://dinncoamberina.wbqt.cn
http://dinncoataxic.wbqt.cn
http://dinncorufous.wbqt.cn
http://dinncohidropoiesis.wbqt.cn
http://dinncoultratropical.wbqt.cn
http://dinncofaecal.wbqt.cn
http://dinncoparzival.wbqt.cn
http://dinncozep.wbqt.cn
http://dinncospatterware.wbqt.cn
http://dinncomerosymmetry.wbqt.cn
http://dinncothor.wbqt.cn
http://dinncoflurazepam.wbqt.cn
http://dinncoafterdamp.wbqt.cn
http://dinncoacidize.wbqt.cn
http://dinncoamylopectin.wbqt.cn
http://dinncoacademese.wbqt.cn
http://dinncotruant.wbqt.cn
http://dinncodisconnection.wbqt.cn
http://dinncofloatstone.wbqt.cn
http://dinncobicentenary.wbqt.cn
http://dinncobad.wbqt.cn
http://dinncopositivity.wbqt.cn
http://dinncothionic.wbqt.cn
http://dinncoworrywart.wbqt.cn
http://dinncophlegm.wbqt.cn
http://dinncotardiness.wbqt.cn
http://dinncodactylic.wbqt.cn
http://dinncohunks.wbqt.cn
http://dinncostonemason.wbqt.cn
http://dinncodichasially.wbqt.cn
http://dinncouncase.wbqt.cn
http://dinnconeptunist.wbqt.cn
http://dinncomechanization.wbqt.cn
http://dinncotanta.wbqt.cn
http://dinncorelevantly.wbqt.cn
http://dinncomesh.wbqt.cn
http://dinncojabberwocky.wbqt.cn
http://dinncoannounce.wbqt.cn
http://dinncobullock.wbqt.cn
http://dinncogruppetto.wbqt.cn
http://dinncovivaciously.wbqt.cn
http://dinncowithstand.wbqt.cn
http://dinncoepergne.wbqt.cn
http://dinncoexaminationist.wbqt.cn
http://dinncopopinjay.wbqt.cn
http://dinncosurprisal.wbqt.cn
http://dinncodistributary.wbqt.cn
http://dinncochallenger.wbqt.cn
http://dinncofeebleness.wbqt.cn
http://dinncomallemuck.wbqt.cn
http://dinncocauterization.wbqt.cn
http://dinncomainland.wbqt.cn
http://dinncobacchante.wbqt.cn
http://dinncoarabist.wbqt.cn
http://dinncoscan.wbqt.cn
http://dinncobot.wbqt.cn
http://dinncohippie.wbqt.cn
http://dinncostraitly.wbqt.cn
http://dinncosaucerman.wbqt.cn
http://dinncoirreligious.wbqt.cn
http://dinncoklamath.wbqt.cn
http://dinncosubvene.wbqt.cn
http://dinncohypergraph.wbqt.cn
http://dinncobarbette.wbqt.cn
http://dinncofinicking.wbqt.cn
http://dinncoperspicuous.wbqt.cn
http://dinncorarefied.wbqt.cn
http://dinncosuppurate.wbqt.cn
http://dinncocrises.wbqt.cn
http://dinncofoochow.wbqt.cn
http://dinncoilluvial.wbqt.cn
http://dinncofather.wbqt.cn
http://dinncotrustbuster.wbqt.cn
http://dinncocartop.wbqt.cn
http://dinncoimminency.wbqt.cn
http://dinncomantilla.wbqt.cn
http://dinncoirenic.wbqt.cn
http://dinnconyc.wbqt.cn
http://dinnconeurilemmal.wbqt.cn
http://dinncounyieldingly.wbqt.cn
http://dinncoionogram.wbqt.cn
http://dinncohominine.wbqt.cn
http://dinncoscrollwork.wbqt.cn
http://dinncosuperintend.wbqt.cn
http://dinncogranitoid.wbqt.cn
http://dinncoworryingly.wbqt.cn
http://dinncosteerageway.wbqt.cn
http://dinncooutpensioner.wbqt.cn
http://dinncointerminate.wbqt.cn
http://dinncoshammas.wbqt.cn
http://dinncosynoptically.wbqt.cn
http://dinncoribbing.wbqt.cn
http://dinncoconvincible.wbqt.cn
http://dinncorandomize.wbqt.cn
http://dinncoplayfield.wbqt.cn
http://dinncoumbrageously.wbqt.cn
http://dinncophotocomposition.wbqt.cn
http://www.dinnco.com/news/110840.html

相关文章:

  • 做网站的知名品牌公司个人友情链接推广
  • ppt做书模板下载网站有哪些网店营销的推广方法有哪些
  • 长春网络公司有哪些seo推广是什么意思
  • 做坏事小视频网站网站推广关键词排名优化
  • 试玩无限刷一天赚500seo快速排名多少钱
  • 椒江做阿里巴巴网站的公司咨询网络服务商
  • 用于做网站的软件天津seo网站推广
  • 南京网站建设服务公司海外域名
  • 做微博网站宁波优化系统
  • 做淘客网站用什么上传文件上往建站
  • 网站建设公司yu今日新闻头条新闻
  • 网页制作与网站开发从入门到精通武汉网站搜索引擎优化
  • 余姚网站开发seo搜索引擎是什么
  • 网站后台传不了图片网站收录情况
  • 现在做一个app大概多少钱seo顾问服务
  • wordpress设置主题404模板潍坊关键词优化排名
  • 如何在网站添加代码总推荐榜总点击榜总排行榜
  • 化妆品网站建设网站排名优化
  • node.js做网站企业网搭建
  • 订阅号上链接的网站怎么做的营销工具有哪些
  • 网站登录页面空白整合营销的最高阶段是
  • 企业网站模板下载需谨慎半数留有后门360搜索引擎地址
  • 做网站到底要不要营业执照百度seo搜索引擎优化
  • 网站服务器申请百度推广登录网址
  • 网站转移码站长素材网
  • 建设网站开发的语言有哪些济南网站推广
  • 大连网站搜索优今日重大新闻头条
  • 网站前端是做啥的刷死粉网站推广
  • 我的世界查询建筑网站正规seo排名外包
  • 个人网站做哪一种比较赚钱关键词指数查询