0
点赞
收藏
分享

微信扫一扫

Python程序设计方法学


文章目录

  • ​​一. 实例:体育竞技分析​​
  • ​​1. 自顶向下(设计)​​
  • ​​2. 自底向上(执行)​​
  • ​​3. 体育竞技分析代码​​
  • ​​4. 代码展示​​
  • ​​5. 理解自顶向下和自底向上​​
  • ​​二. Python程序设计思维​​
  • ​​1. 计算思维与程序设计​​
  • ​​(1). 计算思维​​
  • ​​1. 概述​​
  • ​​2. 特征​​
  • ​​3. 举例理解​​
  • ​​4. 核心概念​​
  • ​​(2). 计算思维与程序设计关系​​
  • ​​2. 计算生态与Python语言​​
  • ​​(1). 来源​​
  • ​​(2). 特点​​
  • ​​(3). 计算生态的价值​​
  • ​​(4). 计算生态的运用​​
  • ​​3. 用户体验与软件产品​​
  • ​​(1). 用户体验​​
  • ​​(2). 提高用户体验的方法​​
  • ​​4. 基本的程序设计模式​​
  • ​​(1). IPO​​
  • ​​(2). 自顶向下设计​​
  • ​​(3). 模块化设计​​
  • ​​(4). 配置化设计​​
  • ​​5. 应用开发的四个步骤​​
  • ​​三. Python第三方库安装​​
  • ​​1. 看见更大的Python世界​​
  • ​​(1). Python社区​​
  • ​​1. 使用方法​​
  • ​​2. 第三方库的pip安装方法​​
  • ​​(1). pip指令​​
  • ​​(2). 常用的pip指令​​
  • ​​3. 第三方库的集成安装方法​​
  • ​​4. 第三方库的文件安装方法​​
  • ​​四. OS库的基本使用​​
  • ​​1. OS库的基本介绍​​
  • ​​2. OS库的路径操作​​
  • ​​2. OS库的进程管理​​
  • ​​3. OS库的环境参数​​
  • ​​五. 第三方库自动安装脚本​​
  • ​​1. 问题分析​​
  • ​​2. 将要安装的第三方库​​
  • ​​3. 第三方库自动安装脚本​​
  • ​​4. 举一反三​​
  • ​​六. Python从入门到精通​​

一. 实例:体育竞技分析

Python程序设计方法学_Python

1. 自顶向下(设计)

Python程序设计方法学_第三方库_02

2. 自底向上(执行)

Python程序设计方法学_python_03

3. 体育竞技分析代码

Python程序设计方法学_Python_04


Python程序设计方法学_python_05


Python程序设计方法学_第三方库_06


Python程序设计方法学_第三方库_07


Python程序设计方法学_Python_08


Python程序设计方法学_第三方库_09


Python程序设计方法学_第三方库_10


Python程序设计方法学_安装方法_11


Python程序设计方法学_python_12


Python程序设计方法学_python_13


总结:

Python程序设计方法学_python_14

4. 代码展示

#MatchAnalysis.py
from random import random
def printIntro():
print("这个程序模拟两个选手A和B的某种竞技比赛")
print("程序运行需要A和B的能力值(以0到1之间的小数表示)")
def getInputs():
a = eval(input("请输入选手A的能力值(0-1): "))
b = eval(input("请输入选手B的能力值(0-1): "))
n = eval(input("模拟比赛的场次: "))
return a, b, n
def simNGames(n, probA, probB):
winsA, winsB = 0, 0
for i in range(n):
scoreA, scoreB = simOneGame(probA, probB)
if scoreA > scoreB:
winsA += 1
else:
winsB += 1
return winsA, winsB
def gameOver(a,b):
return a==15 or b==15
def simOneGame(probA, probB):
scoreA, scoreB = 0, 0
serving = "A"
while not gameOver(scoreA, scoreB):
if serving == "A":
if random() < probA:
scoreA += 1
else:
serving="B"
else:
if random() < probB:
scoreB += 1
else:
serving="A"
return scoreA, scoreB
def printSummary(winsA, winsB):
n = winsA + winsB
print("竞技分析开始,共模拟{}场比赛".format(n))
print("选手A获胜{}场比赛,占比{:0.1%}".format(winsA, winsA/n))
print("选手B获胜{}场比赛,占比{:0.1%}".format(winsB, winsB/n))
def main():
printIntro()
probA, probB, n = getInputs()
winsA, winsB = simNGames(n, probA, probB)
printSummary(winsA, winsB)
main()

结果:
这个程序模拟两个选手A和B的某种竞技比赛
程序运行需要A和B的能力值(以0到1之间的小数表示)
请输入选手A的能力值(0-1): 0.45
请输入选手B的能力值(0-1): 0.55
模拟比赛的场次: 1000
竞技分析开始,共模拟1000场比赛
选手A获胜230场比赛,占比23.0%
选手B获胜770场比赛,占比77.0%

5. 理解自顶向下和自底向上

Python程序设计方法学_第三方库_15

二. Python程序设计思维

1. 计算思维与程序设计

(1). 计算思维

1. 概述

Python程序设计方法学_python_16

2. 特征

Python程序设计方法学_第三方库_17

3. 举例理解

Python程序设计方法学_安装方法_18


Python程序设计方法学_安装方法_19


Python程序设计方法学_第三方库_20


Python程序设计方法学_Python_21


Python程序设计方法学_第三方库_22

4. 核心概念

Python程序设计方法学_第三方库_23

(2). 计算思维与程序设计关系

Python程序设计方法学_Python_24

2. 计算生态与Python语言

(1). 来源

Python程序设计方法学_Python_25


Python程序设计方法学_Python_26


Python程序设计方法学_python_27

(2). 特点

Python程序设计方法学_python_28


Python程序设计方法学_Python_29


Python程序设计方法学_Python_30

(3). 计算生态的价值

Python程序设计方法学_python_31

(4). 计算生态的运用

Python程序设计方法学_Python_32

​​Python计算生态优质网站https://python123.io/index/py_env​​

3. 用户体验与软件产品

(1). 用户体验

用户体验是程序到产品的关键环节

Python程序设计方法学_Python_33

(2). 提高用户体验的方法

Python程序设计方法学_python_34


Python程序设计方法学_安装方法_35


Python程序设计方法学_第三方库_36

4. 基本的程序设计模式

(1). IPO

Python程序设计方法学_第三方库_37

(2). 自顶向下设计

Python程序设计方法学_Python_38

(3). 模块化设计

Python程序设计方法学_安装方法_39


Python程序设计方法学_python_40

(4). 配置化设计

Python程序设计方法学_python_41


Python程序设计方法学_第三方库_42

5. 应用开发的四个步骤

Python程序设计方法学_Python_43


Python程序设计方法学_python_44


Python程序设计方法学_python_45

三. Python第三方库安装

1. 看见更大的Python世界

(1). Python社区

​​Python全球社区https://pypi.org​​

Python程序设计方法学_安装方法_46


Python程序设计方法学_Python_47

1. 使用方法

Python程序设计方法学_python_48


Python程序设计方法学_Python_49

2. 第三方库的pip安装方法

(1). pip指令

Python程序设计方法学_安装方法_50

(2). 常用的pip指令

Python程序设计方法学_python_51


Python程序设计方法学_Python_52


Python程序设计方法学_python_53


Python程序设计方法学_第三方库_54


Python程序设计方法学_安装方法_55


Python程序设计方法学_python_56


Python程序设计方法学_Python_57

3. 第三方库的集成安装方法

Python程序设计方法学_Python_58

4. 第三方库的文件安装方法

Python程序设计方法学_python_59


Python程序设计方法学_Python_60


Python程序设计方法学_第三方库_61

四. OS库的基本使用

1. OS库的基本介绍

Python程序设计方法学_Python_62


Python程序设计方法学_第三方库_63

2. OS库的路径操作

Python程序设计方法学_Python_64


Python程序设计方法学_安装方法_65


Python程序设计方法学_python_66


Python程序设计方法学_python_67


Python程序设计方法学_python_68


Python程序设计方法学_安装方法_69

2. OS库的进程管理

Python程序设计方法学_安装方法_70


Python程序设计方法学_安装方法_71


Python程序设计方法学_python_72

3. OS库的环境参数

Python程序设计方法学_安装方法_73


Python程序设计方法学_Python_74


Python程序设计方法学_Python_75

五. 第三方库自动安装脚本

1. 问题分析

Python程序设计方法学_Python_76

2. 将要安装的第三方库

Python程序设计方法学_Python_77


Python程序设计方法学_Python_78


Python程序设计方法学_安装方法_79


Python程序设计方法学_Python_80

3. 第三方库自动安装脚本

#BatchInstall.py
import os
libs = {"numpy","matplotlib","pillow","sklearn","requests",\
"jieba","beautifulsoup4","wheel","networkx","sympy",\
"pyinstaller","django","flask","werobot","pyqt5",\
"pandas","pyopengl","pypdf2","docopt","pygame"}
try:
for lib in libs:
os.system("pip install "+lib)
print("Successful")
except:
print("Failed Somehow")

4. 举一反三

Python程序设计方法学_python_81

六. Python从入门到精通

Python程序设计方法学_python_82


Python程序设计方法学_第三方库_83


举报

相关推荐

0 条评论