e032: P39 input()輸入資料
Tags : Python
Accepted rate : 0人/0人 (0%) [非即時]
評分方式:
Tolerant

最近更新 : 2024-12-26 14:16

Content

input()可以讓使用者於程式執行後輸入資料。例如,以下程式可以輸入資料,括號內的「input a:」是輸入提示。

Python將輸入的東西一律視為字串,所以若要進行數值運算,請先用int()函數將字串轉為數值。請鍵入以下程式,並輸入數值、觀察結果。

a = input("input a:")
b = input("input b:")
print(a+b)  # 字串相加
a = int(input("input a:"))
b = int(input("input b:"))
print(a+b)  # 數值相加

Input
Output
Sample Input #1
3
5
3
5
Sample Output #1
35
8
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (100%): 1.0s , <1K
Hint :
Tags:
Python
出處:
[管理者: zero(育達管理員) ]


ID User Problem Subject Hit Post Date
沒有發現任何「解題報告」