P1動手試一試
練習1-1python.org
練習1-2:輸入錯誤
錯誤信息:追蹤:最近一次調用:文件:(路徑),第一行,在模塊printf("Hello Python !"),名字錯誤:名字“printf”沒有被定義
不會導致輸入錯誤的邏輯錯誤:
沒有空格,語法合乎python規則,但是不符合用戶期望
練習1-3無窮的技藝
略
練習2-1:簡單消息
message="Python is my friend!"; #創建python變量,指向值Python is my friend! print(message); #打印變量message所指的值
運行結果
練習2-2:多條簡單消息
message="Python is my friend!"; #創建python變量,指向值Python is my friend! print(message); #打印變量message所指的值 message="PHP is the best programming language in the world!";#使用已經指向特定值的變量,給它重新指向一個值 print(message); #打印變量新指向的值
運行結果
練習2-3:個性化消息
練習2-4:調整名字的大小寫
練習2-5:名言
練習2-6:名言2
練習2-7:剔除人名中的空白
練習2-8:數字8
練習2-9:最喜歡的數
練習2-10:添加注釋
練習 2-11:Python之禪
練習3-1:姓名
練習3-2:問候語
練習3-3:自己的列表
練習3-4:嘉賓名單
練習3-5:修改嘉賓名單
練習3-6:添加嘉賓
練習3-7:縮減名單
#練習3-8:放眼世界 想出至少5個你渴望去的地方 Scenic_Spot=["tiananmen","the Great Wall","tibet","hong Kong","inner Mongolia"]#創建列表 print(Scenic_Spot) print(sorted(Scenic_Spot))#sorted方法臨時排序 print(Scenic_Spot) Scenic_Spot.reverse()#reverse方法進行反轉列表 print(Scenic_Spot) Scenic_Spot.reverse()#再次反轉 print(Scenic_Spot) Scenic_Spot.sort()#永久排序 print(Scenic_Spot) Scenic_Spot.sort(reverse=True)#反向永久排序 print(Scenic_Spot)
練習:3-9
練習3-10:嘗試使用各個函數
略
持續更新中。。。