最贊回答 / 慕絲7207896
你的變量K沒有遞增啊,正確代碼如下def l_sum1(k):? ? a = 0? ? b = 0? ? while b <= k:? ? ? ? a += b? ? ? ? b += 1? ? return aprint(l_sum1(100))
2021-03-25
最新回答 / 慕粉1217398274
取模運算的結果就是除法運算的余數,99/30=3余9所以99%3的結果就是9,==>沒什么用就是表示個箭頭,后面是這行程序運行的結果,#是注釋,#后面的部分只會作為文本顯示,不作為程序運行
2021-03-22
最新回答 / 慕運維1448452
額,,,,,短路計算,a? and? b? 如果a是false? 那么輸出就是a? 如果a是true 那么輸出無論b是true或者false,都是b。你這里a=“pd”然后print(“hello”,a and “world”)a已經賦值字符串pd應該是true!
2021-03-22
已采納回答 / qq_加油少年_2
template="Life is short,{} "?data="you need Python."result=template.format(data)?print(result)不要全部寫在一行啊
2021-03-21
最新回答 / 慕斯卡8373086
def sums (n):? ? refult = 0? ? if n > 0 and n <= 100:? ? ? ? while n > 0 :? ? ? ? ? ? refult = refult + n? ? ? ? ? ? n -= 1? ? ? ? return refult? ? else:? ? ? ? return '參數要在1-100之間'n1 = 99print(sums(n1))def fact(n):? ? if n == 1:? ? ? ? return 1?...
2021-03-20
最贊回答 / 幕布斯9526405
你直接吧print頂格就行了,Python語言里你這樣寫是表示print在while循環(huán)內,所以每循環(huán)一次就會執(zhí)行一次,頂格之后就表示print在循環(huán)外,那循環(huán)結束之后才會執(zhí)行一次print
2021-03-18
最新回答 / 幕布斯8123072
# Enter a code#coding=utf-8age = 19if age >= 18:? ? print('adult')? ? print('咚咚嗆今年{}歲'.format(age))
2021-03-18