# usage loop
summary = 0
for item in iterable:
summary += round(item, -1)
PYTHON round
PYTHON round
For
this problem,we'll round an int value up to the next multiple of 10 if
its rightmost digit is 5 or more,so 15 rounds up to 20.Alternately,
round down to the previous multiple of 10 if its rightmost digit is less
than 5,so 12 rounds down to 10.Given 3 ints,a b c,return the sum of
their rounded values.To avoid code repetition,write a separate helper
"def round10(num):" and call it 3 times.
Example Output:round_sum(16,17,18) → 60round_sum(12,13,14) → 30round_sum(6,4,4) → 10
For
this problem,we'll round an int value up to the next multiple of 10 if
its rightmost digit is 5 or more,so 15 rounds up to 20.Alternately,
round down to the previous multiple of 10 if its rightmost digit is less
than 5,so 12 rounds down to 10.Given 3 ints,a b c,return the sum of
their rounded values.To avoid code repetition,write a separate helper
"def round10(num):" and call it 3 times.
Example Output:round_sum(16,17,18) → 60round_sum(12,13,14) → 30round_sum(6,4,4) → 10
英語人氣:926 ℃時間:2020-09-14 18:12:31
優(yōu)質(zhì)解答
$ pythonPython 2.7.3 (default, Jan 2 2013, 16:53:07) [GCC 4.7.2] on linux2Type "help", "copyright", "cre...能不能解析下。我剛剛接觸對于語法不太熟悉。map(func, iterable) 對iterable里的每個元素調(diào)用func函數(shù), 返回值組成新的列表
我來回答
類似推薦
- =ROUND(SUM(C14:E14),2)
- =ROUND(SUM(K6:K8)/C16,2)這個怎么操作
- 明明過生日時時請好朋友們吃飯,買了4瓶橙汁,每瓶0.75升,每杯可倒3/10升,這些橙汁可倒多少杯?
- 花兒推開了春天的大門;雷電推開了夏天的大門仿著再寫4個句子!
- 隔一條長而寬的河如何測出松樹的高?
- 一個三位數(shù)除以一個二位數(shù),商最大是( )位數(shù),最小是( )位數(shù)
- 已知函數(shù)f(x)(x不等于0),對于任意非零實數(shù)x,y,滿足f(xy)=f(x)+f(y).
- 根號18/根號8*根號27/2
- sorry to break your walkman 翻譯成中文
- 誰有和還有的題目(注意,是練習(xí)題!)阿!現(xiàn)在要!求啊...
- 大氣層密度不均勻,所以人眼所看到的日落的太陽在實際位置的哪個位置
- 誰能給我一段100字以上描寫春雨的美文
猜你喜歡
- 1人類的視覺是什么視覺,是真正看見嗎?
- 2為什么漢語拼音與英文字母一樣?
- 3英語高手可以幫我看一篇文章有什么語法或詞匯錯誤嗎?還能添加點什么嗎?
- 4在家庭電路中,以下情況會引起保險絲熔斷的是( ) A.用測電筆接觸火線 B.連接電路時誤將火線與零線接通 C.將開關(guān)用導(dǎo)線接通 D.電路中用電器總功率過大
- 5理想,在饑餓面前,它是糧食……仿寫句子兩句?
- 6焰色反應(yīng)是一種化學(xué)反應(yīng)嗎?
- 7This ruler is green.同意句
- 8某年的10月份有5個星期二,4個星期三,這年的國慶節(jié)是星期幾
- 9用一根鐵絲圍成一個邊長是8分米的正方形,如果把它拉成平行四邊形,面積減少了16平方分米,這個平行四邊形的高是多少分米?
- 10They arrived at teh small village_____(safe)at last
- 11分?jǐn)?shù)應(yīng)用題一批稻谷放在甲,乙兩個糧庫中,甲庫所存的稻谷數(shù)量是乙?guī)斓陌朔种?后來從甲庫取出42噸,乙?guī)?/a>
- 12You'll never marry her-She's much too good for you