20183215 2019-2020-2 《Python程序设计》实验一报告
课程:《Python程序设计》
班级: 1832
姓名: 董振龙
学号: 20183215
实验教师:王志强
实验日期:2020年4月17日
必修/选修:公选课
1.实验内容
1.熟悉Python开发环境;
2.练习Python运行、调试技能;
3.编写程序,练习变量和类型、字符串、对象、缩进和注释等;
4.掌握git技能
2. 实验过程及结果
安装Pycharm并申请教育许可证
百度Jetbrains,第一条检索结果即为Jetbrains官网,点击进入。
如图,便可以申请教育许可证,免费使用正版Pycharm。不久之后,便会有Jetbrains发来邮件(如下图),点击邮件中链接,便可以下载Pycharm。
下载完毕后便可以一路无脑安装。顺便说一下,英语不是很好的比如说我,找到了这个:JetBrains 系列软件汉化包
配置Pycharm并熟悉Python开发环境
PyCharm是一种Python IDE,带有一整套可以帮助用户在使用Python语言开发时提高其效率的工具,比如调试、语法高亮、Project管理、代码跳转、智能提示、自动完成等。
使用之前,我阅读了官方的帮助资料,成功配置了Pycharm。
练习Python运行、调试技能
先要新建项目:文件➡新建项目,选择文件夹之后,便可以成功新建项目。
在“项目工具”窗口中选择项目根目录之后右键(如下图),便可以新建一个Python文件,然后就可以在代码编辑区进行编辑,Ctrl+s保存,按Shift+F10运行代码。Shift+F9可以进行调试。
编写程序,练习变量和类型、字符串、对象、缩进和注释等
'''
人生苦短,我用Python
'''
def divide(a,b):
if b==0:
print("除数为零,除式不成立") #判定除数是否为零
else:
return a/b
a=float(input("请输入被除数:"))
b=float(input("请输入除数:"))
result=divide(a,b)
if ZeroDivisionError:
print(result)
else:
print("结果是:",result)
Pycharm中运行结果如下
设置断点,断点运行一次,结果如下
掌握git技能
配置git参考了:pycharm+gitee环境搭建(超详细)
将这次代码git到码云
先commit文件
然后push
这时打开码云,便可以看到仓库里有了这次的代码
3. 实验过程中遇到的问题和解决过程
- 问题:第一次接触git,傻傻不会弄
- 问题解决方案:直接百度pycharm+gitee,找到了大佬的博客,然后成功解决。
感悟及思考
这次实验让我更好的了解了python,在选修这门课之前,我便自学了一段时间,现在发现,当时自学的内容很浅薄,git更是第一次听说,总之这次实验受益匪浅。人生苦短,我爱python。