zoukankan      html  css  js  c++  java
  • python 变量 数据类型 用户交互 条件判断-if 循环语句-while reak和continue

    一 python介绍

    1.1.python是一门什么样的语言

    1.2.python的优缺点

    1.3.python解释器

    二.python发展史

    三.python的安装

    四. 第一个python程序

    五. 变量

    六.常量

    七.注释

    八.python的基本数据类型

    九.用户交互

    十.流程控制if语句

    十一. 流程控制-while循环
     十二. 流程控制-break和continue

    一.python介绍
        python的创始人为吉多·范罗苏姆(Guido van Rossum)。1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹 打发时间,决心开发一个新的脚本解释程序,作为ABC语言的一种继承。 

    Python可以应用于众多领域,如:数据分析、组件集成、网络服务、图像处理、数值计算和科学计算等众多领域。目 前业内几乎所有大中型互联网企业都在使用Python,如:Youtube、Dropbox、BT、Quora(中国知乎)、豆瓣、知 乎、Google、Yahoo!、Facebook、NASA、百度、腾讯、汽车之家、美团等。

    1.1.python是一门什么样的语言

    编译型:全部打包,然后整体编译。

    解释型:逐句的执行编译。

    1.2.python的优缺点

    优点 :(优雅 明确 简单) 开发效率高 高级语言 可移植性

    缺点 : 速度慢 代码不能加密 线程不能利用多cpu

     1.3.python解释器 

    cpython  ipython  pypy  jython   ironphon

    二.python发展史 1989年,为了打发圣诞节假期,Guido(龟叔)开始写Python语言的编译器。Python这个名字,来自Guido所挚 爱的电视剧Monty Python’s Flying Circus。他希望这个新的叫做Python的语言,能符合他的理想:创造一种 C和shell之间,功能全面,易学易用,可拓展的语言。 1991年,第一个Python编译器诞生。它是用C语言实现的,并能够调用C语言的库文件。从一出生,Python已 经具有了:类,函数,异常处理,包含表和词典在内的核心数据类型,以及模块为基础的拓展系统。 Granddaddy of Python web frameworks, Zope 1 was released in 1999 Python 1.0 - January 1994 增加了 lambda, map, filter and reduce. Python 2.0 - October 16, 2000,加入了内存回收机制,构成了现在Python语言框架的基础 Python 2.4 - November 30, 2004, 同年目前流行的WEB框架Django 诞生 Python 2.5 - September 19, 2006 Python 2.6 - October 1, 2008 Python 2.7 - July 3, 2010 In November 2014, it was announced that Python 2.7 would be supported until 2020, and reaffirmed that there would be no 2.8 release as users were expected to move to Python 3.4+ as soon as possible Python 3.0 - December 3, 2008 Python 3.1 - June 27, 2009 Python 3.2 - February 20, 2011 Python 3.3 - September 29, 2012 Python 3.4 - March 16, 2014 Python 3.5 - September 13, 2015

    三.python的安装
    一路确定即可. 记得path下打钩

    四. 第一个python程序

    1、进入cmd ,输入python进入编辑模式,这个 时候我们可以直接编写python程序

    2、也可以在怕.py中编写python代码。通过python来执行python代码,中文注意更改utf-8编码

    print(“hello”)

    print(“sylar”)

    print(“tory”)

    五、变量

    变量:将运算的中间结果暂存到内存,以便后续程序调用。

    a=1+2+3 # a=6先左后右

    变量的命名规则:

        1、变量由字母、数字,下滑线搭配组合而成

        2、不能数字开头或者全数字

        3、不能是python的关键字 def if while

        4、不啊使用中文

        5、不要太长

        6、尽量有意义

       7、推荐使用:

          1驼峰体,首字母大写

         2、下划线,单词用下划线分开

    ageOfAlex =128

    taiBaiJinXing =128

    yin_wang_ de_nian_ling =55

    六:常量:大写

    七、注释

    单行注释:#

    多行注释:"""  """     '''  '''   ' '      "   "

    八、基本数据类型

    整数int  字符串str 布尔bool Ture真 False

    s = '周杰伦‘

    ss = "周润发"

    sss = '''周春远'''

    ssss = """周星星"""

    print(ssss)

    a = "周润发"

    print(type(a))#打印a的数据类型=>str

    b = 128

    print(type(b))

    c = Ture

    print(type(c))

    print(1+2)

    a = '1'

    b = ‘1’

    print(a+b)#字符11

    a=''银王"

    print(a*3) # * xx 两遍

    name = input

    s = "我叫”+name+“,今年18岁"

    print(s)

    a = input("请输入a:")

    b = input("请输入b:")

    c = int(a)

    d = int (b)

    print(c+d)

    十 if

    if money > 500

        print("打车回家")

        print("喝喝啤酒")

        print(吃吃烧烤)

    money = 200

    if money > 500:

        print(”喝喝小酒")

    else:

        print("喝水")

    money = 1350

    if money > 3000:

        print("大宝剑")

    eilf money > 2000: 

       print("洗脚城")

    eilf money >1000:

        print("喝喝小酒")

    else:

        print ("回家喝水")

    十一、while循环

    flag = True

    count = 1

    while flag:

        printa("1")

        print("2")

        count = count + 1

        if count == 6:

            flag = False

    print("吃饭")

    数数问题

    index = 1 

    while index < 101:

        print(index)

       index =index + 1

    index = 1

    sum = 0

    while index < 101

       sum = sum + index

        index = index + 1

    print(sum)

    十二 break和continue

    index = 1

    while index < 101:

       print(index)

       inedex = index + 1

       if index == 88 :

        break 

    print("中午吃啥啊")

    index = 1

    while index < 101:

        if index == 88:

            index = index + 1

            countinue

        print(index)

    index = index + 1

    1. 什么是计算机?
     CPU: 大脑 3GHZ
     内存: 缓冲硬盘和CPU
     硬盘: 保存数据的 70MB/S
     
     读写的内容都是01代码二进制
     
    2. 编程语言简单分类
     最早的是机器语言
     汇编语言
     高级语言: C语言,Pyhon, java, c++, c#, object-c
    3. python是什么编程语言
    4. python分类
     1. python2. 有很多陋习
     2. python3.
    5. 安装python - 找坤哥
    6. 第一个python程序
     1. 在命令行中编写python代码
     2. 把程序写在.py文件中. 注意编码(UTF-8)
    7. 变量
    8. 数据类型
    9. 用户交互
    10. 条件判断-if
    11. 循环语句-while
    12. break和continue

  • 相关阅读:
    计数排序
    桶排序
    给定两个数组,这两个数组是排序好的,让你求这两个数组合到一起之后第K大的数。
    leetcode349 python3 112ms 求两个数组的交集
    leetcode852 C++ 20ms 找最高峰 序列先增后减
    leetcode665 C++ 36ms 非递减数列 这题没啥意思
    leetcode414 C++ 4ms 第三大的数字
    C++ 堆排序 以及用堆排序解决topk问题
    leetcode628 python3 124ms 三个数字的最大乘积
    leetcode26 C++ 20ms 删除排序数列中的重复元素
  • 原文地址:https://www.cnblogs.com/lnrick/p/9111868.html
Copyright © 2011-2022 走看看