题目:

Summation

Write a program that finds the summation of every number from 1 to num. The number will always be a positive integer greater than 0.

For example:

summation(2) -> 3
1 + 2 summation(8) -> 36
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8

解题方法:

很简单的题目:

def summation(num):
return sum([x for x in range(num+1)])

【Kata Daily 191010】Grasshopper - Summation(加总)的更多相关文章

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

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

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

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

  3. 【Kata Daily 191012】Find numbers which are divisible by given number

    题目: Complete the function which takes two arguments and returns all numbers which are divisible by t ...

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

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

  5. 【Kata Daily 190924】Difference of Volumes of Cuboids(长方体的体积差)

    题目: In this simple exercise, you will create a program that will take two lists of integers, a and b ...

  6. 【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 ...

  7. 【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 ...

  8. 【Kata Daily 190918】Spacify(插空)

    题目: Modify the spacify function so that it returns the given string with spaces insertedbetween each ...

  9. 【Kata Daily 190917】Numericals of a String(字符出现的次数)

    题目: You are given an input string. For each symbol in the string if it's the first character occuren ...

随机推荐

  1. 075 01 Android 零基础入门 01 Java基础语法 09 综合案例-数组移位 07 综合案例-数组移位-主方法功能4的实现

    075 01 Android 零基础入门 01 Java基础语法 09 综合案例-数组移位 07 综合案例-数组移位-主方法功能4的实现 本文知识点:综合案例-数组移位-主方法功能4的实现 说明:因为 ...

  2. SPI通信基础学习

    SPI是"Serial Peripheral Interface"的缩写,即"串行外设接口",是摩托罗拉公司推出的一种串行接口通信协议. 接线的示意图: SPI ...

  3. Docker笔记1:Docker 的介绍

    目  录 1.Docker 简介 2.Docker 特性 3.Docker 应用场景 4.Docker 优点 1.Docker 简介     Docker 提供了一个可以运行你的应用程序的封套(env ...

  4. 【5】进大厂必须掌握的面试题-Java面试-spring

    spring面试问题 Q1.什么是spring? Spring本质上是一个轻量级的集成框架,可用于用Java开发企业应用程序. Q2.命名Spring框架的不同模块. 一些重要的Spring Fram ...

  5. day14 Pyhton学习

    一.迭代器-概念 可迭代协议:内部含有__iter__方法的值/变量都是可迭代的 如何得到一个迭代器:可迭代变量.__iter__()返回一个迭代器 迭代器协议:内部含有__iter__方法和__ne ...

  6. 扫描仪扫描文件处理-ABBYY生成小体积黑白二值化PDF

    禁止所有预处理选项: PDF保存选项: 保存提示(选择"保存为仅图像PDF"):

  7. vbox挂载共享文件夹

      版权 挂载共享文件夹很简单,有2种方法,1是自动挂载,2是手动挂载. 一.自动挂载步骤: 1,把想共享的文件夹设置为共享. 2,在virtualbox界面对虚拟机设置共享文件夹,如下图.

  8. rabbitmq 交换机模式 -主题模式 topic

    建立一个交换机 tpc 并且绑定了各自的路由到 Q1 Q2 <?php require_once "./vendor/autoload.php"; use PhpAmqpLi ...

  9. swoole协程通道channel

    swoole 协程通道 为了协程直接互相通讯传递数据 和go的通道很相似 Co\run(function(){ $chan = new Swoole\Coroutine\Channel(1); Swo ...

  10. 聊聊简单又灵活的权限设计(RBAC)

    你:我看完能知道个啥?我:也就以下两点吧一. 了解基于 RBAC 思路的表设计二. 表数据在实际开发场景中是如何使用的你:我觉得那应该还有点干货吧我:我不要你觉得,我要我觉得 (͡ ͡° ͜ つ ͡͡ ...