4-5 鍵盤輸入字串值
s = input('請輸入姓名:')
print(s)
print(type(s))請輸入姓名:tomlin
tomlin
<class 'str'>
Last updated
s = input('請輸入姓名:')
print(s)
print(type(s))請輸入姓名:tomlin
tomlin
<class 'str'>
Last updated
try:
chi = int(input('請輸入國文分數:'))
eng = int(input('請輸入英文分數:'))
avg = (chi+eng) / 2
print(f'平均={avg}')
except:
print('輸入數值錯誤')請輸入國文分數:75
請輸入英文分數:80
平均=77.5