Python入门实战:Round 4

2026-02-21 14:54:26

哈,这个系列是跟小伙伴一起组织的Python兴趣小组的习题,每一期内容会包括三个部分:题目、小伙伴答案和全球开发者答案。话不多说,Show you the code ~

工具/原料

题目来源:Codewars

Python 2.7

Round 4# RGB To Hex Conversion

The rgb() method is incomplete. Complete the method so that passing in RGB decimal values will result in a hexadecimal representation being returned. The valid decimal values for RGB are 0 - 255. Any (r,g,b) argument values that fall out of that range should be rounded to the closest valid value.

The following are examples of expected output values:Local answers

    这次的答案里,有一部分是需要大家阅读代码以后要去避免的Global answers

      全球开发者的答案用了匿名函数,但是可读性变差了,感觉不好注意事项

        代码下载:https://pan.baidu.com/s/1qZOzLNm

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢