1. 程式人生 > >用戶輸入和while循環

用戶輸入和while循環

ont 數字 暫停 實參 ann sage 回車 轉化 put

函數input()可以讓程序暫停執行,等待用戶輸入後,按回車繼續執行。

message = input(”請輸入:“)

print(message) 通常輸入的東西程序會默認其為字符串,若想轉化為數字,需要加int函數。

while循環 a=1

while a <=5:

break 退出當前循環

continue 返回循環頭,不執行後續語句。

python 傳遞任意數量的實參:

def make_cokie(*source)

print(source)

make_cokie("apple","orange","banna") *將形參名source創建為空元組,並將所有的元組都封裝進這個元組中。

用戶輸入和while循環