---恢复内容开始---
交互器模式
开始--》cmd --> cd c:\ -->dir
cd = change directory
dir = 查看当前目录文件列表
cd .. 返回上一层目录
cd ../.. 返回上上一层目录
cd ../../.. 返回上上上一层目录
cd ../../../.. 返回上上上上一层目录
D:\>"d:\Program Files\Python35\python.exe" c:\hello.txt
Hello World!
#c:\hello.txt .txt 代表文件的扩展名(后缀名),用于区分文件类型
.txt 记事本文本文件
.doc word文件
.xls excel文件
.ppt PPT文件
.exe 可执行文件
.jpg .png .jpeg 图片
.gif 动态图片
.pdf PDF文件
.mp4 .avi 视频
.py python文件
.java java 文件
.c .h c源码
.php php文件
.js javascript
Hello World程序
变量
变量 是 为了存储 程序运算过程中的一些中间 结果,为了方便日后调用
Variables变量 are used to store保存、储存 information信息 to be referenced被日后调用 and manipulated操作或更改 in a computer program程序. They also并且还 provide提供 a way方式 of labeling标记 data数据 with a descriptive描述性 name, so our programs can be understood理解 more clearly更清晰 by the reader阅读者 and ourselves我们自己. It is helpful to think of variables as containers容器 that hold保持、保存 information(如果我们把变量看作成是一个保存信息的容器是更容易理解的). Their sole主要 purpose目的 is to label标记 and store存储 data in memory内存里. This data数据 can then然后 be used使用它 throughout整个 your program.
变量的命名规则
1. 要具有描述性
2. 变量名只能_,数字,字母组成,不可以是空格或特殊字符(#?<.,¥$*!~)
3. 不能以中文为变量名
4. 不能以数字开头
5. 保留字符是不能被使用
猜年龄
1 age_of_princal = 56 2 guess_age = int( input(">>:") ) 3 if guess_age == age_of_princal: 4 print("Yes,you got it..") 5 elif guess_age > age_of_princal: 6 print("shoud try samller..") 7 else: 8 print("try bigger ...")
猜分数
score = int(input("score:")) if score > 90: print("A") elif score > 80: print("B") elif score > 70: print("C") elif score > 50: print("D") else: print("滚")
猜还能活几年
death_age = 80 name = input("your name:") age = input("your age:") #input 接受的所有数据都是字符串,即便你输入的是数字,但依然会被当成字符串来处理 print( type(age) ) #int integer =整数 把字符串转成int,用int(被转的数据) #str string =字符串 把数据转成字符串用str(被转的数据) print("Your name:",name) #print("You can still live for ", death_age - int(age)," years ....") print("You can still live for " + str(death_age - int(age)) +" years ....")
---恢复内容结束---
浙公网安备 33010602011771号