#3-1 姓名
names = ['qiqi','danliang','mingliang','peng']
for x in range(0,4):
print(names[x])
#3-2 問候語
names = ['qiqi','qanliang','mingliang','peng']
for x in range(0,4):
print("hello," + names[x].title() + "大吉大利!")
#3-3 自己的列表
trip_mode = ['小黃車','摩拜','暴龍獸','大寶劍']
for x in range(0,4):
print("我今天想騎" + trip_mode[x] + "去抓皮卡丘!")
#3
-4 嘉賓名單
names =
for x in range
(0,3):
print('dear ' + names[x] + ',can you come to my dinner?')
#3
-5 修改嘉賓名單
names =
for x in range
(0,3):
print('dear ' + names[x] + ',can you come to my dinner?')
print(names[1] + '無法赴約。')
names[1] = ('趙麗穎') #改名單
for x in range
(0,3):
print('dear ' + names[x] + ',can you come to my dinner?')
#3
-6 新增嘉賓
names =
for x in range
(0,3):
print('dear ' + names[x] + ',can you come to my dinner?')
print('\n' + names[1] + '無法赴約。\n')
names[1] = ('趙麗穎') #改名單
for x in range
(0,3):
print('dear ' + names[x] + ',can you come to my dinner?')
print('\nhaha~,i found a bigger table, i can invite more people!\n')
names.insert(0,'紫霞')
names.insert(2,'靜香')
for x in range
(0,len(names)):
print('dear ' + names[x] + ',can you come to my dinner?')
#3
-7 縮減名單
names =
for x in range
(0,3):
print('dear ' + names[x] + ',can you come to my dinner?')
print('\n' + names[1] + '無法赴約。\n')
names[1] = ('趙麗穎') #改名單
for x in range
(0,3):
print('dear ' + names[x] + ',can you come to my dinner?')
print('\nhaha~,i found a bigger table, i can invite more people!\n')
names.insert(0,'紫霞')
names.insert(2,'靜香')
for x in range
(0,len(names)):
print('dear ' + names[x] + ',can you come to my dinner?')
print('\noh! gouride快遞沒給我把桌子送來,我只能邀請兩位了(┬_┬)!\n')
x = len(names)
for x in range
(0,x-2):
popped_name = names.pop()
print('實在抱歉,' + popped_name +'我不能與你共進晚餐了!')
for x in range
(0,len(names)):
print('dear ' + names[x] + ',我依然邀請你來與我共進晚餐!')
del names[1] #del列表應從後往前!
del names[0]
print(names)
#3-8 放眼世界
cities = ['chongqing','chengdu','xiamen','kuning','shenzhen']
print(cities)
print(sorted(cities))
print(cities)
print(sorted(cities,reverse=true))
print(cities)
cities.reverse()
print(cities)
cities.reverse()
print(cities)
cities.sort()
print(cities)
cities.sort(reverse=true)
print(cities)
#3
-9 晚餐嘉賓
names =
for x in range
(0,3):
print('dear ' + names[x] + ',can you come to my dinner?')
print('\n' + names[1] + '無法赴約。\n')
names[1] = ('趙麗穎') #改名單
for x in range
(0,3):
print('dear ' + names[x] + ',can you come to my dinner?')
print('\nhaha~,i found a bigger table, i can invite more people!\n')
names.insert(0,'紫霞')
names.insert(2,'靜香')
for x in range
(0,len(names)):
print('dear ' + names[x] + ',can you come to my dinner?')
print('\noh! gouride快遞沒給我把桌子送來,我只能邀請兩位了(┬_┬)!\n')
x = len(names)
for x in range
(0,x-2):
popped_name = names.pop()
print('實在抱歉,' + popped_name +'我不能與你共進晚餐了!')
for x in range
(0,len(names)):
print('dear ' + names[x] + ',我依然邀請你來與我共進晚餐!')
print('\n最後,我將邀請' + str(len(names)) + '個人參加晚宴!')
del names[1] #del列表應從後往前!
del names[0]
print(names)
Python 程式設計 從入門到實踐
1.官網安裝 3.環境配置 務必選中核取方塊add python to path 4.檢視 啟動python版本的命令 python 執行 print hello python world 5.終端執行x.py檔案 python x.py 7.檢視當前目錄中的所有檔案的命令 dir windows系...
Python程式設計從入門到實踐 基礎入門
python程式設計從入門到實踐 基礎入門 1 python中的變數 2 python首字母大寫使用title 方法,全部大寫upper 方法,全部小寫lower 方法 3 python中字串拼接使用 號 4 python中刪除字串的空格 刪除末尾空格的rstrip 刪除開頭空格的lstrip 刪除...
Python程式設計 從入門到實踐 1
內容總結自 python程式設計 從入門到實踐 安裝python3 安裝文字編輯器sublime text並配置python3環境 安裝sublime text tools new build system 將 untitled.sublime build 文件中的所有內容刪除,輸入以下內容 注意,...