
第1课 信手涂鸦很快乐——初识Python

扫一扫,看视频
子曰:“工欲善其事,必先利其器。”要做好一件事,准备工作非常重要。学习Python语言也一样,第一步就是要在计算机上下载并安装Python软件,再配置Python的环境变量。
本课让我们一起来探秘Python吧!
研究室
1.理解题意
下载与安装 Python软件之前,让我们先来认识一下关键单词。

2.开动脑筋

规划院
1.思路分析
跟其他程序设计语言一样,在应用之前需要先安装程序,并配置好环境变量。
2.算法描述
下载与安装Python软件的一般操作步骤如下图所示。

加工坊
1.下载与安装Python
打开浏览器,以关键词“python官网”搜索Python官方网站,也可以直接输入网址打开Python官方网站,然后下载Python软件。
(1)打开Python官方网站 打开浏览器,按下页图所示的操作,搜索并打开Python官方网站。
(2)下载Python软件 在Python官方网站的首页,按下页图所示的操作,下载安装程序。


下载时要注意选择与自己的计算机操作系统相匹配的 Python版本,这里以32位操作系统为例进行介绍。
(3)安装Python软件 双击下载好的Python-3.7.3.exe文件,按照提示安装Python软件。

(4)查看 安装结果 安装结束后,可在“开始”菜单中查看Python软件。

(5)认识单行编辑界面 按下页图所示的操作,打开单行编辑界面,出现命令提示符“>>>”,在这里一次只能输入一条Python指令。
(6)认识多行程序编辑器 选择“File”→“New File”命令,打开多行程序编辑器,在这里可以一次输入多条Python指令。保存后,系统可一次性执行指令。


2.创建与运行程序
(1)创建程序文件 按下图所示的操作,打开多行程序编辑器,输入程序代码。

(2)保存Python程序文件 输入完程序代码后,按下图所示的操作保存文件。

(3)运行程序 按下图所示的操作运行程序,查看程序的运行结果。

3.答疑解惑
(1)p rint 意为打印、印刷、发表,程序设计语言中一般用print()命令将程序结果输出到某个设备。
(2)print() 在Python中,print()命令可以输出数值或者字符串。

print与( )之间可以加空格,如print ( );也可以不加空格,如print( )。二者输出的结果都是一样的,可根据个人编程习惯选用。
4.拓展应用
● 利用 print()命令输出字符串。

● 利用print()命令输出算术表达式的结果。

● 利用print()命令输出变量。

阅览室
1.配置Python环境变量
安装Python时,如果没有勾选“Add Python 3.7 to PATH”复选框,那么在Windows操作系统中配置好Python环境变量后也可正常使用。
(1)判断是否需要配置环境变量 按下页图进行操作,如果出现图中所示的界面,说明Python安装成功,否则需要配置环境变量。

(2)查找安装目录 按下图所示的操作,查找并复制Python安装目录。

(3)打开“高级系统设置”窗口 按下图所示的操作,打开计算机的“高级系统设置”窗口。

(4)配置环境变量 按下图所示的操作,将复制的Python安装目录粘贴到“变量值”文本框中。

2.调试程序
输入指令后,如果出现红色英文提示,则说明给Python下达了错误的指令,Python不能识别你下达的指令,这是反馈给你的提示信息。

创新园
1.阅读程序写结果
>>>print("3+5=",3+5)
输出结果:_____________。
2.编写程序
利用print()命令编写一段程序,输出下图所示的图案。
