[TOC]
语言的分类
-
编译型语言
需要在不同的平台上编译,生成针对不同平台的专有的运行代码
-
解释型语言
不需要关注硬件底层,可以和不同的平台沟通
语言的版本
2.7版本的语言将最后支持到2020年
当前版本为3.6.1,已经安装
(当前的安装已经集成选项可以直接自动添加环境变量)
基础语法
变量(variable)
变量是什么?
变量是个容器变量干什么用
用于存储数据到内存变量怎么用
赋值-
变量定义的规则
- 变量名只能是 字母、数字或下划线的任意组合
- 变量名的第一个字符不能是数字
- 以下关键字不能声明为变量名
['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']
用户输入
作业
# import getpass
# username = input('username:')
# password = getpass.getpass('password:')
# print(username,password)
# if username == 'scott' and password=='123':
# print('welcome scott')
# else:
# print('wrong')
# ------------------
age = 49
def play_game(i):
while i < 3:
guess_age = int(input('guess my age:'))
i = i + 1
if guess_age > age:
print('Wrong,too old')
elif guess_age < age:
print('Wrong,too young')
else:
print('Right!!')
i=0
gift = input('do you like big sword? Y/N:')
if gift == 'Y':
print('满脑子骚操作,重新来')
else:
print('那你很棒棒哦')
break
play_game(i=0)
while 1:
print('小哥哥,还要接着玩吗?')
chose_play = input('Y/N:')
if chose_play == 'Y' or 'y':
play_game(i=0)
else:
print('你这样乱搞就没意思了')
break