score = {}
if score > 18:
print('adult')
else:
print('teenager')
結果是 adult,求解惑
if score > 18:
print('adult')
else:
print('teenager')
結果是 adult,求解惑
2023-03-28
最贊回答 / 慕少0598786
因為你寫錯了a=0b=0while True:? ? if a > 1000:? ? ? ? break? ? if a % 2 == 0:? ? ? ? b=b+a? ? a=a+1print(b)?這樣才對
2023-03-27
l=[75,92,59,68,99]
sum=0
a=0
for i in l:
if i is not None:
sum=eval("sum + i")
a=eval("a+1")
else:
break
b=eval("sum/a")
print("總值是:",sum)
print("一共有",a,"個值")
print("平均值為:",b)
sum=0
a=0
for i in l:
if i is not None:
sum=eval("sum + i")
a=eval("a+1")
else:
break
b=eval("sum/a")
print("總值是:",sum)
print("一共有",a,"個值")
print("平均值為:",b)
2023-03-23
a=int(input("請輸入您的年齡:"))
if a >=18:
print("adult")
elif a <18 and a > 6:
print("teenager")
elif a >=3 and a<=6:
print("kid")
else:
print("baby")
if a >=18:
print("adult")
elif a <18 and a > 6:
print("teenager")
elif a >=3 and a<=6:
print("kid")
else:
print("baby")
2023-03-23
template = '{}'
result1 = template.format('Life is short, you need Python')
print(result1)
temp = 'Life is short, {}'
result2 = temp.format('you need Python')
print(result2)
tmp = "{0} {1} {2}, {3} {4} {5}"
result3 = tmp.format('Life','is','short','you','need','Python')
print(result3)
result1 = template.format('Life is short, you need Python')
print(result1)
temp = 'Life is short, {}'
result2 = temp.format('you need Python')
print(result2)
tmp = "{0} {1} {2}, {3} {4} {5}"
result3 = tmp.format('Life','is','short','you','need','Python')
print(result3)
2023-03-19
print(r"""'\"To be, or not to be\": that is the question.\nWheth
er it\'s nobler in the mind to suffer.'""")
er it\'s nobler in the mind to suffer.'""")
2023-03-19
print("special string: '")
print("\"")
print("\\")
print("\\\\")
print("\\n")
print("\\t")
print("\"")
print("\\")
print("\\\\")
print("\\n")
print("\\t")
2023-03-19
L = ['Alice', 'Bob', 'Candy', 'David', 'Ellena']
name1 = L.pop(2)
name2 = L.pop(2)
print(L)
name1 = L.pop(2)
name2 = L.pop(2)
print(L)
2023-03-16
最新回答 / 天堂沒有神
template1 = 'Life is {},'template2 = 'you need {a}'k423 = 'python'print(template1.format('short'),template2.format(a=k423))這樣就可以
2023-03-15
最新回答 / qq_慕工程7590247
result = template.format(w=w , c=c , b=b, i=i )這一行要這樣寫,w=w,第一個w指template = 'Hello {w}, Hello {c}, Hello , Hello {i}.'這里定義的形參,第二個指 w = 'World'這里定義的實參學了函數就知道了這個報錯就是編譯器找不到你定義的實參
2023-03-15