没有合适的资源?快使用搜索试试~ 我知道了~
[笔记][“笨办法”学Python 3]1
需积分: 0 0 下载量 53 浏览量
2022-08-03
22:26:36
上传
评论
收藏 1.4MB PDF 举报
温馨提示
试读
86页
前言“笨办法”指的是“指令式”教学方式。debug 调试习题0. 准备工作习题0. 准备工作Windows 的 PowerShellmacOS 的 Termin
资源详情
资源评论
资源推荐
[笔记][“笨办法”学Python 3]
腾蛇起陆 Python
[笔记][“笨办法”学Python3]
前言
习题0.准备工作
习题1.第一个程序
习题2.注释和#号
习题3.数字和数学计算
习题4.变量和命名
习题5.更多的变量和打印
习题6.字符串和文本
习题7.更多打印
习题8.打印,打印
习题9.打印,打印,打印
习题10.那是什么
习题11.提问
习题12.提示别人
习题13.参数、解包和变量
习题14.提示和传递
习题15.读取文件
习题16.读写文件
习题17.更多文件操作
习题18.命名、变量、代码和函数
习题19.函数和变量
习题20.函数和文件
习题21.函数可以返回某些东西
习题22.到现在为止你学到了什么
习题23.字符串、字节串和字符编码
习题24.更多的练习
习题25.更多更多的练习
习题26.恭喜你,现在可以考试了!
习题27.记住逻辑关系
习题28.布尔表达式练习
习题29.if语句
习题30.else和if
习题31.作出决定
习题32.循环和列表
习题33.while循环
习题34.访问列表的元素
习题35.分支和函数
习题36.设计和调试
习题37.复习各种符号
习题38.列表的操作
习题39.字典,可爱的字典
习题40.模块、类和对象
习题41.学习面向对象术语
习题42.对象、类及从属关系
习题43.基本的面向对象分析和设计
习题44.继承与组合
习题45.你来制作一款游戏
习题46.项目骨架
习题47.自动化测试
习题48.用户输入进阶
习题49.创建句子
习题50.你的第一个网站
习题51.从浏览器获取输入
习题52.创建Web游戏
接下来的路
老程序员的建议
附录:命令行快速入门
简介:废话少说,命令行来也
练习1.准备工作
练习2.路径、文件夹和目录(pwd)
练习3.如果你迷失了
练习4.创建目录(mkdir)
练习5.更改目录(cd)
练习6.列出目录中的内容(ls)
练习7.删除目录(rmdir)
练习8.在多个目录中切换(pushd和popd)
练习9.创建空文件(touch/NewItem)
练习10.复制文件(cp)
练习11.移动文件(mv)
练习12.查看文件内容(less/more)
练习13.流文件内容显示(cat)
练习14.删除文件(rm)
练习15.退出终端(exit)
前言
“笨办法”指的是“指令式”教学方式。
debug 调试
习题0.准备工作
习题0.准备工作
Windows 的 PowerShell
macOS 的 Terminal
Linux 的 bash
Vim 用 :q! 或者 ZZ 退出
需要这些就够了
文本编辑器
命令行终端
Python
习题1.第一个程序
ex1.py
print("Hello World!")
print("Hello Again!")
print("I like typing this.")
print('Yay! Printing.')
print("I'd much rather you 'not'.")
print('I "said" do not touch this.')
SyntaxError 语法错误
# octothorpe,pound,hash,mesh
注释代码
习题2.注释和# 号
ex2.py
# A comment, this is so you can read your program later.
# Anything after the # is ignored by python.
print("I could have code like this.")
# and the comment after is ignored
# You can also use a comment to "disable" or comment out code:
# print("This won't run.")
print("This will run.")
# poundcharacter
多行注释
每一行都放一个 #
倒着阅读代码是很好的查错技巧。
习题3.数字和数学计算
ex3.py
print("I will now count my chickes:")
print("Hens", 25 + 30 / 6)
print("Roosters", 100 - 25 * 3 % 4)
print("Now I will count the eggs:")
print(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6)
print("Is it true that 3 + 2 < 5 - 7?")
print(3 + 2 < 5 - 7)
print("What is 3 + 2?", 3 + 2)
print("What is 5 - 7?", 5 - 7)
print("Oh, that's why it's False.")
print("How about some more.")
print("Is it greater?", 5 > -2)
print("Is it greater or equal?", 5 >= -2)
print("Is is less or equal?", 5 <= 2)
运算优先级 PEMDAS
括号 Parentheses
指数 Exponents
乘 Multiplication
除 Division
加 Addition
减 Substraction
习题4.变量和命名
变量 variable
_ 下划线 underscore 在变量里通常被用作假想的空格,用来隔开单词。
ex4.py
cars = 100
space_in_a_car = 4.0
drivers = 30
passengers = 90
cars_not_driven = cars - drivers
cars_driven = drivers
carpool_capacity = cars_driven * space_in_a_car
average_passengers_per_car = passengers / cars_driven
print("There are", cars, "cars available.")
print("There are only", drivers, "drivers available")
print("There will be", cars_not_driven, "empty cars today.")
print("We can transport", carpool_capacity, "people today.")
print("We have", passengers, "to carpool today.")
print("We need to put about", average_passengers_per_car, "in each car.")
= 的作用是为数据(数值、字符串等)取名
单等号 = 将右边的值赋给左边的变量名
双等号 == 检查左右两边的值是否相等
x = 100 比 x=100 好:操作符两边加上空格会让代码更容易阅读。
习题5.更多的变量和打印
剩余85页未读,继续阅读
艾闻
- 粉丝: 34
- 资源: 302
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0