Python九九乘法表
来源:互联网 发布:资生堂淘宝旗舰店真吗 编辑:程序博客网 时间:2024/06/05 10:16
代码:
# -*- coding: utf-8 -*-def multi_table(): result = '' for i in range(1, 10): for j in range(1, i + 1): separator = '\n' if j == i else '\t' result += '%d * %d = %-2d' % (j, i, i * j) result += separator return resultr = multi_table()print(r)
输出:
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 = 161 * 5 = 5 2 * 5 = 10 3 * 5 = 15 4 * 5 = 20 5 * 5 = 251 * 6 = 6 2 * 6 = 12 3 * 6 = 18 4 * 6 = 24 5 * 6 = 30 6 * 6 = 361 * 7 = 7 2 * 7 = 14 3 * 7 = 21 4 * 7 = 28 5 * 7 = 35 6 * 7 = 42 7 * 7 = 491 * 8 = 8 2 * 8 = 16 3 * 8 = 24 4 * 8 = 32 5 * 8 = 40 6 * 8 = 48 7 * 8 = 56 8 * 8 = 641 * 9 = 9 2 * 9 = 18 3 * 9 = 27 4 * 9 = 36 5 * 9 = 45 6 * 9 = 54 7 * 9 = 63 8 * 9 = 72 9 * 9 = 81
阅读全文
0 0
- [Python]九九乘法表
- python 九九乘法表
- Python九九乘法表
- Python九九乘法表
- python 九九乘法表
- Python九九乘法表
- Python九九乘法表
- Python编写九九乘法表
- python版的九九乘法表
- [Python]打印九九乘法表
- Python实现九九乘法表
- python打印九九乘法表
- Python版九九乘法表
- Python实现九九乘法表
- Python程序-打印九九乘法表
- python的九九乘法表
- python 实践 九九乘法表
- 用Python输出九九乘法表
- MT2503与SIM系列模块连接服务器区别比较
- IntelliJ IDEA的初次使用(二)
- linux安装JDK
- maven:Fatal error compiling: 无效的目标 发行版: 1.8 -> [Help 1]
- 为什么从java源码到class字节码是由编译器完成
- Python九九乘法表
- Parameter index out of range (1 > number of parameters, which is 0)
- 此文章是原创,若是转载,请表明出处
- Error:Cannot change dependencies of configuration ':app:_debugAnnotationProcessor' after it has been
- 关于DBUtil“Cannot create bean”异常
- 170526 逆向-CrackMe(3)
- Action Synopsis: Pose Selection and Illustration 实现
- SpringMVC数据格式化之日期转换@DateTimeFormat
- Updates were rejected because the tip of your current branch is behindhint: its remote counterpart.