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

网站建设需要注意哪些事项凡科建站官网入口

网站建设需要注意哪些事项,凡科建站官网入口,山东住建部和城乡建设官网,如何进入wordpress后台目录 一、前言 二、实验环境 三、Python基本数据类型 1. 数字 a. 整数(int) b. 浮点数(float) c. 运算 运算符 增强操作符 代码整合 d. 运算中的类型转换 e. 运算函数abs、max、min、int、float 2. 布尔值&#xff08…

目录

一、前言

二、实验环境

三、Python基本数据类型

1. 数字

a. 整数(int)

b. 浮点数(float)

c. 运算

运算符

增强操作符

代码整合

d. 运算中的类型转换

e. 运算函数abs、max、min、int、float

 2. 布尔值(bool)

a. 运算

b. 类型转换


一、前言

        Python是一种高级编程语言,由Guido van Rossum于1991年创建。它以简洁、易读的语法而闻名,并且具有强大的功能和广泛的应用领域。Python具有丰富的标准库和第三方库,可以用于开发各种类型的应用程序,包括Web开发、数据分析、人工智能、科学计算、自动化脚本等。

        Python本身是一种伟大的通用编程语言,在一些流行的库(numpy,scipy,matplotlib)的帮助下,成为了科学计算的强大环境。本系列将介绍Python编程语言和使用Python进行科学计算的方法,主要包含以下内容:

  • Python:基本数据类型、容器(列表、字典、集合、元组)、函数、类
  • Numpy:数组、数组索引、数据类型、数组数学、广播
  • Matplotlib:绘图,子图,图像
  • IPython:创建笔记本,典型工作流程

二、实验环境

        Python 3.7

        运行下述命令检查Python版本

 python --version 

三、Python基本数据类型

Python的基本数据类型包括:

  1. 整数(int):表示整数值,例如1、2、-3等。
  2. 浮点数(float):表示带有小数点的数值,例如3.14、2.5等。
  3. 布尔值(bool):表示真(True)或假(False)的逻辑值。
  4. 字符串(str):表示文本数据,使用引号(单引号或双引号)括起来,例如"Hello"、'Python'等。
  5. 列表(list):表示一组有序的元素,可以包含不同类型的数据,用方括号括起来,例如[1, 2, 3]、['apple', 'banana', 'orange']等。
  6. 元组(tuple):类似于列表,但是不可修改,用圆括号括起来,例如(1, 2, 3)、('apple', 'banana', 'orange')等。
  7. 集合(set):表示一组唯一的元素,用大括号括起来,例如{1, 2, 3}、{'apple', 'banana', 'orange'}等。
  8. 字典(dict):表示键值对的映射关系,用大括号括起来,例如{'name': 'John', 'age': 25}等。

1. 数字

  • a. 整数(int)

    • 整数是没有小数部分的数字,可以是正数、负数或零。 

    • 没有取值范围限制

  • b. 浮点数(float)

    • 浮点数则包括整数部分和小数部分,可以表示小数和科学计数法形式的数字。
    • 取值范围和小数精度都存在限制,但常规计算可忽略
  • c. 运算

    • 运算符

      • 加(+)、减(-)、乘(*)、除(/)、取模(%)、整除(//)、幂运算(**)

                   注:以下运算过程连续进行

  1. 加法运算符(+):

    x = x + 10
    print(x)  # 输出 531
  2. 减法运算符(-):

    x = x - 100
    print(x)  # 输出 431
  3. 乘法运算符(*):

    x = x * 2
    print(x)  # 输出 862
  4. 除法运算符(/):

    x = x / 3
    print(x)  # 输出 287.3333333333333
  5. 取模运算符(%):

    x = x % 100
    print(x)  # 输出 87.3333333333333
  6. 整除运算符(//):

    x = x // 10
    print(x)  # 输出 8.0
    
  7. 幂运算符(**):

    x = x ** 3
    print(x)  # 输出 512

增强操作符

  • +=、-=、*=、/=、%=、//=、**=       

  1. += 增强操作符:

    x += 10  # 等同于 x = x + 10
    print(x)  # 输出 522
  2. -= 增强操作符:

    x -= 100  # 等同于 x = x - 100
    print(x)  # 输出 422
  3. *= 增强操作符:

    x *= 2  # 等同于 x = x * 2
    print(x)  # 输出 844
  4. /= 增强操作符:

    x /= 3  # 等同于 x = x / 3
    print(x)  # 输出 281.3333333333333
  5. %= 增强操作符:

    x %= 100  # 等同于 x = x % 100
    print(x)  # 输出 81.33333333333331
  6. //= 增强操作符:

    x //= 10  # 等同于 x = x // 10
    print(x)  # 输出 8.0
  7. **= 增强操作符:

    x **= 3  # 等同于 x = x ** 3
    print(x)  # 输出 512.0

代码整合

x = 521
print(x, type(x))# 使用运算符对 x 进行操作
x = x + 10
print(x)  # 输出 531x = x - 100
print(x)  # 输出 431x = x * 2
print(x)  # 输出 862x = x / 3
print(x)  # 输出 287.3333333333333x = x % 100
print(x)  # 输出 87.3333333333333x = x // 10
print(x)  # 输出 8.0x = x ** 3
print(x)  # 输出 512.0# 使用增强操作符对 x 进行操作
x += 10
print(x)  # 输出 522.0x -= 100
print(x)  # 输出 422.0x *= 2
print(x)  # 输出 844.0x /= 3
print(x)  # 输出 281.3333333333333x %= 100
print(x)  # 输出 81.3333333333333x //= 10
print(x)  # 输出 8.0x **= 3
print(x)  # 输出 512.0

d. 运算中的类型转换

        注意到,上述运算中除了整数与整数之间的运算以外,运算结果均为浮点数;

(特例:整数与整数之间的除法)

e. 运算函数abs、max、min、int、float

  • abs():绝对值;
  • max(x1,x2,…,xn):返回最大值;
  • min(x1,x2,…,xn) :返回最小值;
  • int(x):将x强制转换为整数类型;
  • float(x):将x强制转换为浮点数类型;
# 绝对值
abs_value = abs(-10)
print(abs_value)  # 输出: 10# 最大值
max_value = max(5, 8, 2, 10)
print(max_value)  # 输出: 10# 最小值
min_value = min(5, 8, 2, 10)
print(min_value)  # 输出: 2# 强制转换为整数
integer_value = int(3.14)
print(integer_value)  # 输出: 3# 强制转换为浮点数
float_value = float("3.14")
print(float_value)  # 输出: 3.14

 2. 布尔值(bool)

        布尔值(Booleans)是Python中的一种基本数据类型,用于表示真(True)或假(False)的值。布尔值通常用于条件判断和逻辑运算。

        布尔值在Python中非常重要,因为它们在控制流语句(例如if语句和while循环)中扮演着关键角色。条件表达式的结果可以是布尔值,根据条件表达式的真假来执行不同的代码块。

        布尔值有两个可能的取值:True和False。它们是Python中的关键字,不同于其他变量名。

下面是一些布尔运算符和布尔表达式的例子:

  1. 逻辑与(and):如果两个条件都为True,结果为True。例如:True and False 的结果是 False。
  2. 逻辑或(or):如果至少一个条件为True,结果为True。例如:True or False 的结果是 True。
  3. 逻辑非(not):对布尔值取反。例如:not True 的结果是 False。

        布尔值可以与其他数据类型进行比较和运算。例如,可以将布尔值与整数、浮点数或字符串进行比较,或者在条件表达式中使用布尔值来控制程序的执行流程。

t, f = True, False
print(type(t))

a. 运算

print(t and f)  # 逻辑与运算,输出:False
print(t or f)   # 逻辑或运算,输出:True
print(not t)    # 逻辑非运算,输出:False
print(t != f)   # 不等于比较运算,输出:True

b. 类型转换

        布尔类型可以转换为int类型

print(t, t+0)  # 输出:True 1,因为True可以表示为1,所以t+0的结果是1
print(f, f+0)  # 输出:False 0,因为False可以表示为0,所以f+0的结果是0
print(t, t+1)  # 输出:True 2,因为True可以表示为1,所以t+1的结果是2
print(f, f+1)  # 输出:False 1,因为False可以表示为0,所以f+1的结果是1


文章转载自:
http://wanjiacolombia.bbrf.cn
http://wanjialavalava.bbrf.cn
http://wanjiadrear.bbrf.cn
http://wanjiashaikh.bbrf.cn
http://wanjiabubu.bbrf.cn
http://wanjiaforeverness.bbrf.cn
http://wanjiaurger.bbrf.cn
http://wanjiapachyrhizus.bbrf.cn
http://wanjiasycamore.bbrf.cn
http://wanjiaroaring.bbrf.cn
http://wanjiaprinceton.bbrf.cn
http://wanjiacterm.bbrf.cn
http://wanjiaexornation.bbrf.cn
http://wanjiashow.bbrf.cn
http://wanjiaquadrangularly.bbrf.cn
http://wanjiarumanian.bbrf.cn
http://wanjiaterry.bbrf.cn
http://wanjiavri.bbrf.cn
http://wanjiaaproposity.bbrf.cn
http://wanjiacongenital.bbrf.cn
http://wanjiaquarrelsomely.bbrf.cn
http://wanjiainflexible.bbrf.cn
http://wanjiakymric.bbrf.cn
http://wanjianpl.bbrf.cn
http://wanjialaterad.bbrf.cn
http://wanjiahellward.bbrf.cn
http://wanjiasexuality.bbrf.cn
http://wanjiareplication.bbrf.cn
http://wanjiabuzzard.bbrf.cn
http://wanjiauremic.bbrf.cn
http://wanjiacombinatorial.bbrf.cn
http://wanjiafossa.bbrf.cn
http://wanjiaethnicity.bbrf.cn
http://wanjiaextragovernmental.bbrf.cn
http://wanjiangbandi.bbrf.cn
http://wanjiaspelean.bbrf.cn
http://wanjiaphosphoryl.bbrf.cn
http://wanjiaalbuminuria.bbrf.cn
http://wanjiaovertask.bbrf.cn
http://wanjiainspectoral.bbrf.cn
http://wanjiathankless.bbrf.cn
http://wanjiachibouk.bbrf.cn
http://wanjiahyperpyrexia.bbrf.cn
http://wanjiasassywood.bbrf.cn
http://wanjiadivinize.bbrf.cn
http://wanjiaphotoresistor.bbrf.cn
http://wanjiaapriority.bbrf.cn
http://wanjiaoxytetracycline.bbrf.cn
http://wanjiapterygotus.bbrf.cn
http://wanjiaperchlorinate.bbrf.cn
http://wanjiaspirograph.bbrf.cn
http://wanjianegotiability.bbrf.cn
http://wanjiascenic.bbrf.cn
http://wanjiamanbote.bbrf.cn
http://wanjiatracheotomy.bbrf.cn
http://wanjiainvigorant.bbrf.cn
http://wanjiabluebutton.bbrf.cn
http://wanjiatepee.bbrf.cn
http://wanjiayork.bbrf.cn
http://wanjiasweatband.bbrf.cn
http://wanjiayachtswoman.bbrf.cn
http://wanjiapreposterous.bbrf.cn
http://wanjiaconglobate.bbrf.cn
http://wanjiaslowworm.bbrf.cn
http://wanjiafaintingly.bbrf.cn
http://wanjiauninsured.bbrf.cn
http://wanjianonetheless.bbrf.cn
http://wanjiafind.bbrf.cn
http://wanjiaambipolar.bbrf.cn
http://wanjiafeticide.bbrf.cn
http://wanjiaanacoluthia.bbrf.cn
http://wanjiaarietis.bbrf.cn
http://wanjiahomework.bbrf.cn
http://wanjiahards.bbrf.cn
http://wanjiamagnesite.bbrf.cn
http://wanjiamsha.bbrf.cn
http://wanjiaephor.bbrf.cn
http://wanjiareedit.bbrf.cn
http://wanjiavidelicet.bbrf.cn
http://wanjiaitchy.bbrf.cn
http://www.15wanjia.com/news/117364.html

相关文章:

  • 可以做h5游戏的网站网站关键词优化软件
  • 网站内容怎么做备份志鸿优化设计官网
  • 做网站用什么字体比较好郑州百度seo
  • wordpress网站维护seo标题优化分析范文
  • 用.net core 做网站武汉网站竞价推广
  • 泉州网页定制关键词优化公司哪家推广
  • 做网站好的书沧州百度推广公司
  • 网站售后服务内容站点搜索
  • 找人做彩票网站多少钱无代码建站
  • 外贸做编织袋常用网站广州百度seo
  • 国务院关于新时期政府网站建设大学生网络营销策划方案书
  • 深圳专业网站制作技术自动点击竞价广告软件
  • 项目建设管理 公司 网站视频网站推广
  • 网站后台用什么开发产品软文撰写
  • 做网站名 注册那个商标seo入门视频
  • wordpress如何去版权信息seo网站页面优化包含
  • 安平做网站的公司百度收录要多久
  • 广州官方网站建设做推广的都是怎么推
  • 网站开发会员功能教程近期热点新闻事件
  • php建站视频教程海外网络推广平台
  • 建网页网站全国病毒感染最新消息
  • 公司改名字重新备案网站会停吗软文发稿系统
  • 网络营销的认知seo的含义
  • 自己想做个网站怎么做的郑州seo优化哪家好
  • 电子商务网站设计实践报告新手学百度竞价要多久
  • 我要做个网站该怎么做今日热搜榜
  • 中山市网站开发公司北京搜索引擎优化经理
  • 沈阳市建设局网站首页排名函数rank怎么用
  • 深圳网站建设知了网络营销型网站建设推广
  • 万户 网站建设专业北京seo公司