【Kata Daily 190911】Multiplication Tables(乘法表)
题目:
Create a function that accepts dimensions, of Rows x Columns, as parameters in order to create a multiplication table sized according to the given dimensions. **The return value of the function must be an array, and the numbers must be Fixnums, NOT strings.
Example:
multiplication_table(3,3)
1 2 3
2 4 6
3 6 9
-->[[1,2,3],[2,4,6],[3,6,9]]
Each value on the table should be equal to the value of multiplying the number in its first row times the number in its first column.
解题办法:
def multiplication_table(row, col):
L = []
# Good Luck!
for i in range(1, row+1):
L1 = []
for j in range(1, col+1):
mul = i * j
L1.append(mul)
L.append(L1)
return L
这题还是挺简单的。按照思路来就好
看一下网友的简写一句话的写法:
def multiplication_table(row,col):
return [[(i+1)*(j+1) for j in range(col)] for i in range(row)]
【Kata Daily 190911】Multiplication Tables(乘法表)的更多相关文章
- [LeetCode] Kth Smallest Number in Multiplication Table 乘法表中的第K小的数字
Nearly every one have used the Multiplication Table. But could you find out the k-th smallest number ...
- hdu4951 Multiplication table (乘法表的奥秘)
http://acm.hdu.edu.cn/showproblem.php?pid=4951 2014多校 第八题 1008 2014 Multi-University Training Contes ...
- [Swift]LeetCode668. 乘法表中第k小的数 | Kth Smallest Number in Multiplication Table
Nearly every one have used the Multiplication Table. But could you find out the k-th smallest number ...
- JSP基础语法---九九乘法表-java jsp
<%@ page language="java" import="java.util.*" contentType="text/html; ch ...
- Python练习:九九乘法表
打印 n * n 的乘法表 #打印 9*9 乘法表 def Multiplication(n): # n - 定义打印的行数 max_len = len(str((n)**2)) #计算最大值的占位( ...
- java-js知识库之一——canvas绘制9*9乘法表
不知不觉一年又要过去了,软件这一行入坑快两年了,一直不知道这两年干了些啥,也不知道自己到底会些什么,工作也是些简单的东西,谁都能做,对未来也是很茫然.今天和同事优化数据库,头都是懵的,很多东西都感觉似 ...
- java打印一下九九乘法表
public class Multiplication { public static void main(String[] args) { printTable(); } // 打印九九乘法表 pu ...
- 打印a*a的乘法表
/*利用for循环打印 9*9 表? 1*1=1 1*2=2 2*2=4 1*3=3 2*3=6 3*3=9 1*4=4 2*4=8 3*4=12 4*4=16 1*5=5 2*5=10 3*5=15 ...
- C#之打印乘法表
设计说明 由图可知: 1.我们需要打印出九行: 2.每行中最大列数等于行数: 代码实现 public void Display1() { Console.WriteLine("乘法表:&qu ...
随机推荐
- VS2015建立一个完整的c++工程:头文件.h 源文件.cpp,自动生成类
https://blog.csdn.net/weixin_40539125/article/details/81430801 打开VS2015 ,新建VS win32工程,前面步骤很简单,不再阐述 下 ...
- Golang搭建接口测试框架
测试报告 使用goconvey作为测试报告,使用方法: 安装 $ go get github.com/smartystreets/goconvey $ $GOPATH/bin/goconvey 导入包 ...
- Mysql的Sql语句优化
在Mysql中执行Sql语句经常会遇到有的语句执行时间特别长的情况,出现了这种情况我们就需要静下心分析分析. 首先,我们需要确定系统中哪些语句执行时间比较长.这个可以使用Mysql的慢日志来跟踪.下面 ...
- Linux init 详解(0,1,2,3,4,5,6)
一.什么是 init init是Linux系统操作中不可缺少的程序之一. 所谓的init进程,它是一个由内核启动的用户级进程. 内核自行启动(已经被载入内存,开始运行,并已初始化所有的设备驱动程序和数 ...
- Request对象基础应用实例代码一
输入用户名:<br><input type="text" name="yhm"><br><br>输入密码:< ...
- day39 Pyhton 并发编程02 后
一.开启子进程的另一种方式 import os from multiprocessing import Process class MyProcess(Process): def __init__(s ...
- MVC-WebApi配置 Swagger(Web Api可视化文档)
一.从创建MVC WebApi开始 第一步创建MVC WebApi就创建好了,接下来就进入正题,上干货 ================================================ ...
- spring boot:actuator的安全配置:使用spring security做ip地址限制(spring boot 2.3.2)
一,actuator有哪些环节要做安全配置? actuator是应用广泛的监控工具, 但在生产环境中使用时,需要做严格的安全保障, 避免造成信息泄露等严重的安全问题 actuator可以采取的安全措施 ...
- gti 常用命令
git add 文件 : 追踪指定文件git add . :追踪所有的文件git commit -m "注释" : 提交报本地仓库git push : 推送远程仓库git pull ...
- 懒人福音——GitHub 热点速览 Vol.42
作者:HelloGitHub-小鱼干 懒人福音是什么?就是省时省事,正如 Waypoint 一样,你不需要在多个平台构建代码即可部署发布应用,它允许你将应用程序构建.部署和发布生命周期定义为代码.Bi ...