[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