分类:字符串
知识点:
-
获取输入 input().strip().split(" ")
-
拼接列表 " ".join(list)
-
输出指定位数的浮点数 print("%.2f" % value)
题目来自【华为招聘模拟考试】
python
# If you need to import additional packages or classes, please import here.
def func():
# please define the python3 input here. For example: a,b = map(int, input().strip().split())
words = input().strip().split(" ")
# please finish the function body here.
total_words = len(words)
new_str = "".join(words)
total_length = len(new_str)
# please define the python3 output here. For example: print().
# print(round(total_length/total_words, 2)) # round有bug
print("%.2f" % (total_length/total_words))
if __name__ == "__main__":
func()
注意,不要使用round,有bug
by: 软件工程小施同学