復習python基礎語法,最好能做到使用python 寫一些簡單的算法。
1基礎基礎語法
1.0 輸入輸出
一個實用的print:format函數print('站點列表 {0}, {1}, 和 {other}。'.format('Google', 'Runoob', other='Taobao'))
站點列表 Google, Runoob, 和 Taobao。print("a", "b", sep="-", end="!\n") # a-b!
sep 多個對象間的分隔符 空格 end 結尾字符 \npi = 3.1415926
print(f"π 約等于 {pi:.2f}") # π 約等于 3.14# 讀一整行,返回 str
name = input("請輸入姓名:") # 用戶敲回車結束
print("你好,", name, type(name)) # 類型一定是 str# 一行讀多數字(最實用技巧)
nums = list(map(int, input("輸入若干整數,空格分隔:").split()))
print("列表:", nums)
需求 | 代碼片段 |
---|---|
輸入一行字符串 | s = input() |
輸入多個整數 | nu |