路飛學城-python開發集訓-第1章
阿新 • • 發佈:2018-05-17
等等 繼續 import 字符串 pass pri port 流程控制語句 概念
第一章節,因為之前看過,所有比較熟悉。首先是介紹了一下ALEX自己和他的50塊錢的眼模。其實就是介紹了一下python語言的發展史。
然後就是講了一些基礎的概念,比如什麽是變量,什麽是常量。
編程語言的類型,比如解釋型,比如編譯型。
然後講了一些數據類型,例如數字、字符串、布爾值等等。
最重要的就是講了流程控制語句。
這貼幾個自己敲的代碼。
猜年齡小遊戲。
# __*__ coding: utf-8 __*__ __author__ = "David.z" my_age = 31 count = 0 while count < 4: guess_age = int (input("猜一猜我的年紀:")) if guess_age == my_age: print ("你太棒了,你猜對了!") break elif guess_age < my_age: print ("猜的太小了!") else: print ("猜的太大了!") count += 1 if count == 4 : choice = input("已經達到4次了,你還要繼續猜嗎?輸入Y或y繼續") if choice == "y" or choice == "Y": count =0 else: print ("你已經放棄猜年齡!")
# Author"David.z import login import getpass _username = ‘alex‘ _password = ‘123‘ #將用戶輸入的內容賦值給name變量 user = input("請輸入用戶名:") #pwd = getpass.getpass("請輸入密碼:") pwd = input("請輸入密碼:") if user == _username and pwd == _password:print ("welcome user %s login"% user) else: print ("Wrong username or password") #打印輸入的內容 print(user,pwd)
路飛學城-python開發集訓-第1章