题目:

Complete the function which takes two arguments and returns all numbers which are divisible by the given divisor. First argument is an array of numbers and the second is the divisor.

Example

divisible_by([1, 2, 3, 4, 5, 6], 2) == [2, 4, 6]

解题方法:

def divisible_by(numbers, divisor):
return [x for x in numbers if x%divisor == 0]

【Kata Daily 191012】Find numbers which are divisible by given number的更多相关文章

  1. 【Kata Daily 190929】Password Hashes(密码哈希)

    题目: When you sign up for an account somewhere, some websites do not actually store your password in ...

  2. 【Kata Daily 190923】Odder Than the Rest(找出奇数)

    题目: Create a method that takes an array/list as an input, and outputs the index at which the sole od ...

  3. 【Kata Daily 190920】Square(n) Sum(平方加总)

    题目: Complete the square sum function so that it squares each number passed into it and then sums the ...

  4. 【Kata Daily 190919】Sort Out The Men From Boys(排序)

    题目: Scenario Now that the competition gets tough it will Sort out the men from the boys . Men are th ...

  5. 【Kata Daily 190911】Multiplication Tables(乘法表)

    题目: Create a function that accepts dimensions, of Rows x Columns, as parameters in order to create a ...

  6. 【kata Daily 190905】What's a Perfect Power anyway?(完美幂)

    原题: A perfect power is a classification of positive integers: In mathematics, a perfect power is a p ...

  7. 【Kata Daily 190904】Calculating with Functions(函数计算)

    原题: This time we want to write calculations using functions and get the results. Let's have a look a ...

  8. 【Kata Daily 191010】Grasshopper - Summation(加总)

    题目: Summation Write a program that finds the summation of every number from 1 to num. The number wil ...

  9. 【Kata Daily 190927】Counting sheep...(数绵羊)

    题目: Consider an array of sheep where some sheep may be missing from their place. We need a function ...

随机推荐

  1. Vue学习 一 环境搭建

    Vue  ui  启动 创建一个新项目 包管理器 npm Bable 转换js 至低版本的支持(兼容低版本) TypeScript  对TypeScript  的支持  (暂时不需要) PWA    ...

  2. 多测师讲解selenium—自动化测试课堂面试题总结—高级讲师肖sir

    1.你有做过自动化?你用什么语言? python2.自动化中如何使用语言打开一个网址?浏览器,浏览器对应驱动,导入库,类,get,url3.在一个浏览器中打开多个窗口?open_windows dri ...

  3. day28 Pyhton MRO和C3算法

    1.python多继承.一个类可以拥有多个父类 class ShenXian: # 神仙 def fei(self): print("神仙都会飞") class Monkey: # ...

  4. 【C语言学习笔记】空间换时间,查表法的经典例子!知识就是这么学到的~

    我们怎么衡量一个函数/代码块/算法的优劣呢?这需要从多个角度看待.本篇笔记我们先不考虑代码可读性.规范性.可移植性那些角度. 在我们嵌入式中,我们需要根据实际资源的情况来设计我们的代码.比如当我们能用 ...

  5. 【传递闭包】HDU 2157 How many ways??

    UPD:现在才发现本题是个传递闭包 题目内容 春天到了,HDU校园里开满了花,姹紫嫣红,非常美丽. 葱头是个爱花的人,看着校花校草竞相开放,漫步校园,心情也变得舒畅. 为了多看看这迷人的校园,葱头决定 ...

  6. property和setter装饰器

    # property装饰器 # 作用: 将一个get方法转换为对象的属性. 就是 调用方法改为调用对象 # 使用条件: 必须和属性名一样 # setter方法的装饰器: # 作用:将一个set方法转换 ...

  7. Vue slot插槽通俗解释

    slot内容分发是Vue的Api来源 <div id="app"> <my-list> {{msg}} </my-list> </div& ...

  8. vue知识点15

    1.回调地狱的三种方案:函数    promise     async await          2. 子组件与子组件之间的传递: 可以借用公共父元素.子组件A  this.$emit(" ...

  9. C++ 智能指针(一)

    内存安全 在C++中,动态内存的管理是通过一对运算符来完成的:new,在动态内存中为对象分配空间并返回一个指向该对象的指针,我们可以选择对对象来进行初始化:delete,接收一个动态对象的指针,销毁该 ...

  10. StringUtils工具类(Apache lang3 )

    引入依赖 <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons- ...