题目:

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(乘法表)的更多相关文章

  1. [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 ...

  2. hdu4951 Multiplication table (乘法表的奥秘)

    http://acm.hdu.edu.cn/showproblem.php?pid=4951 2014多校 第八题 1008 2014 Multi-University Training Contes ...

  3. [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 ...

  4. JSP基础语法---九九乘法表-java jsp

    <%@ page language="java" import="java.util.*" contentType="text/html; ch ...

  5. Python练习:九九乘法表

    打印 n * n 的乘法表 #打印 9*9 乘法表 def Multiplication(n): # n - 定义打印的行数 max_len = len(str((n)**2)) #计算最大值的占位( ...

  6. java-js知识库之一——canvas绘制9*9乘法表

    不知不觉一年又要过去了,软件这一行入坑快两年了,一直不知道这两年干了些啥,也不知道自己到底会些什么,工作也是些简单的东西,谁都能做,对未来也是很茫然.今天和同事优化数据库,头都是懵的,很多东西都感觉似 ...

  7. java打印一下九九乘法表

    public class Multiplication { public static void main(String[] args) { printTable(); } // 打印九九乘法表 pu ...

  8. 打印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 ...

  9. C#之打印乘法表

    设计说明 由图可知: 1.我们需要打印出九行: 2.每行中最大列数等于行数: 代码实现 public void Display1() { Console.WriteLine("乘法表:&qu ...

随机推荐

  1. opencv的imread函数相对路径问题和 main 参数问题

    参考: https://blog.csdn.net/u013404374/article/details/80178822 https://blog.csdn.net/fujilove/article ...

  2. puts()和gets()函数

    puts()和gets()函数 1. puts()函数 puts()函数用来向标准输出设备(屏幕)写字符串并换行, 其调用格式为: puts(s); 其中s为字符串变量(字符串数组名或字符串指针). ...

  3. abp(net core)+easyui+efcore实现仓储管理系统——出库管理之二(五十)

    abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统--ABP总体介绍(一) abp(net core)+ ...

  4. 网站搭建-云服务器是什么-云服务器ECS是什么

    学习上瘾了,本博客关闭,后期再总结整理.

  5. CSS的背景

    CSS的背景 1. 背景颜色background-color div { background-color: 颜色值; } 一般情况下元素背景颜色默认是transparent(透明). 2. 背景图片 ...

  6. 转 RabbitMQ 入门教程(PHP版) 使用rabbitmq-delayed-message-exchange插件实现延迟功能

    延迟任务应用场景 场景一:物联网系统经常会遇到向终端下发命令,如果命令一段时间没有应答,就需要设置成超时. 场景二:订单下单之后30分钟后,如果用户没有付钱,则系统自动取消订单. 场景三:过1分钟给新 ...

  7. 说明资源路径位置类型无法解析The type javax.servlet.http.HttpServletResponse cannot be resolved.

    导入dispatch项目后报错: 解决办法:在项目上单击鼠标右键>  Add Libraries  选择 Server Runtime,下一步  选中Apache Tomcat7 完成  切换标 ...

  8. Model实体类

    Model又叫实体类,这个东西,大家可能觉得不好分层.包括我以前在内,是这样理解的:UI<-->Model<-->BLL<-->Model<-->DAL ...

  9. LNOI 2020 退役记

    不会爆零了吧嘤嘤嘤 \(Day -7\) 周五正在上化学珂,突然被老师叫出去说省选还有名额,问我报不报名.啊嘞嘞还有一周了告诉我还有名额?经过了激烈的思想斗争,还是决定停课搞一搞,学一回OI好歹看看省 ...

  10. C++switch结构