1 def count(temp1,cha,temp2):2 res = int(temp1) cha int(temp2)3 return res4 way = input("請輸入計(jì)算方式(加/減/乘/除):")5 temp1 = input("輸入第一個(gè)數(shù)")6 temp2 = input("輸入第二個(gè)數(shù)")7 if way == '加':8 res = jia(temp1,+,temp2)9 elif way == '減':10 res = jian(temp1,-,temp2)11 elif way == '乘':12 res = cheng(temp1,*,temp2)13 elif way == '除':14 res = chu(temp1,/,temp2)15 print(res)下面的這個(gè)補(bǔ)充的和上面的是一樣的,但最初提問或許系統(tǒng)有些問題,沒有縮進(jìn)————————————————————————————————————1 def count(temp1,cha,temp2):2 res = int(temp1) cha int(temp2)3 return res4 way = input("請輸入計(jì)算方式(加/減/乘/除):")5 temp1 = input("輸入第一個(gè)數(shù)")6 temp2 = input("輸入第二個(gè)數(shù)")7 if way == '加':8 res = jia(temp1,+,temp2)9 elif way == '減':10 res = jian(temp1,-,temp2)11 elif way == '乘':12 res = cheng(temp1,*,temp2)13 elif way == '除':14 res = chu(temp1,/,temp2)15 print(res)
涉及到函數(shù)if elif的問題,請問該怎么解決?
繁華開滿天機(jī)
2022-05-24 10:06:04