用python打印99乘法口诀表
- 代码如下
#!/usr/bin/env python
# encoding: utf-8
__author__ = 'Nicholas.Cage'
i = 1
j = 1
while i <= 9:
j = 1
while j <= i:
print "%s * %s = %s\t" % (i, j, i*j),
j += 1
i += 1
print
print
for i in range(1, 10):
for j in range(1, i+1):
print "%s * %s = %s\t" % (i, j, i*j),
print
print
i = 9
while i >= 1:
j = 1
while j <= i:
print("%s * %s = %s\t" % (i, j, i*j)),
j += 1
i -= 1
print
print
for i in range(9, 0, -1):
for j in range(i, 0, -1):
print "%s * %s = %s\t" % (i, j, i*j),
print
- 运行结果如下
ssh://root@192.168.109.200:22/root/.pyenv/shims/python -u /root/var/tmp/apepy/Review/2_multi_nine_nine.py
1 * 1 = 1
2 * 1 = 2 2 * 2 = 4
3 * 1 = 3 3 * 2 = 6 3 * 3 = 9
4 * 1 = 4 4 * 2 = 8 4 * 3 = 12 4 * 4 = 16
5 * 1 = 5 5 * 2 = 10 5 * 3 = 15 5 * 4 = 20 5 * 5 = 25
6 * 1 = 6 6 * 2 = 12 6 * 3 = 18 6 * 4 = 24 6 * 5 = 30 6 * 6 = 36
7 * 1 = 7 7 * 2 = 14 7 * 3 = 21 7 * 4 = 28 7 * 5 = 35 7 * 6 = 42 7 * 7 = 49
8 * 1 = 8 8 * 2 = 16 8 * 3 = 24 8 * 4 = 32 8 * 5 = 40 8 * 6 = 48 8 * 7 = 56 8 * 8 = 64
9 * 1 = 9 9 * 2 = 18 9 * 3 = 27 9 * 4 = 36 9 * 5 = 45 9 * 6 = 54 9 * 7 = 63 9 * 8 = 72 9 * 9 = 81
1 * 1 = 1
2 * 1 = 2 2 * 2 = 4
3 * 1 = 3 3 * 2 = 6 3 * 3 = 9
4 * 1 = 4 4 * 2 = 8 4 * 3 = 12 4 * 4 = 16
5 * 1 = 5 5 * 2 = 10 5 * 3 = 15 5 * 4 = 20 5 * 5 = 25
6 * 1 = 6 6 * 2 = 12 6 * 3 = 18 6 * 4 = 24 6 * 5 = 30 6 * 6 = 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* 2 = 10 5 * 1 = 5
4 * 4 = 16 4 * 3 = 12 4 * 2 = 8 4 * 1 = 4
3 * 3 = 9 3 * 2 = 6 3 * 1 = 3
2 * 2 = 4 2 * 1 = 2
1 * 1 = 1
Process finished with exit code 0
用python打印99乘法口诀表的更多相关文章
- Python 打印99乘法口诀表
import string for x in xrange(1,10): for y in xrange(1,x+1): print string.ljust("%d*%d = " ...
- Java 面试 - 打印九九乘法口诀表
在Java面试过程中, 面试者经常会被要求手写代码或上机操作.一般来说,手写代码或上机操作,主要还是考察面试者的分析问题和解决问题的能力.打印九九乘法口诀无疑是非常基础的,那么如何实现呢?首先我们先来 ...
- java 打印出99乘法口诀表
public class Mutiplay { /** *实现99乘法表 * @param args */ public static void main(String[] args) { Syste ...
- print函数详解及python打印99乘法表的不同方法
首先你需要了解print的原型,并且要知道在python2和python3中print函数功能不同,不只是表现在后面带不带()一方面! 在python3中,通过help(print)可以得到print ...
- python打印99乘法表
代码如下: print(XXX,end="\t") #表示打印不换行 附带python部分转义字符:
- 如何利用while语句打印“九九乘法口诀表”
需求:输出九九乘法表 plus.py代码如下: i=1 j=1 while i<=9: j=1 while j<=i: print(j,'*',i,'=',str(i*j)+' ',end ...
- python 9*9乘法口诀表
# -*- coding: utf-8 -*- # __author__ = 'Carry' for i in range(1, 10): for j in range(1, i + 1): prin ...
- python3 打印九九乘法口诀表
for i in range(1, 10): for j in range(1, i+1): # print(f'{i}×{j}={i*j}', end='\t') print('%d×%d=%d' ...
- scala 打印一个乘法口诀表 (<<scala 编程>> P87)
(for(i <- 1 to 9;j <- 1 to i; s = s"$j*$i=${i*j}\t") yield {if(j==1) s"$s\n&quo ...
随机推荐
- 160321、ORACLE分页查询SQL语法——最高效的分页
--1:无ORDER BY排序的写法.(效率最高) --(经过测试,此方法成本最低,只嵌套一层,速度最快!即使查询的数据量再大,也几乎不受影响,速度依然!) SELECT * FROM (SELE ...
- CentOS开启telnet连接
开启telnet连接通道 yum安装telnet yum -y install telnet-server* 关闭防火墙 /etc/init.d/iptables stop 编辑配置文件 vim /e ...
- Go语言 基本类型
在内存中的形式 首先看一下在go中,一些基础类型在内存中是以什么形态存在的,如下图所示: 变量j的类型是int32, 而变量i的类型是int,两者不是同一个类型,所以赋值操作i=j是一种类型错误can ...
- cocoapod 最新安装使用步骤
cocoapod 最新安装使用步骤 安装 1.sudo gem update (2个-)system :更新你的gem system至最新 2.gem sources (2个-)remove htt ...
- 牛B三人组-快速排序-堆排序-归并排序
快速排序 随便取个数,作为标志值,这里就默认为索引位置为0的值 记录左索引和右索引,从右往左找比标志值小的,小值和左索引值交换,右索引变化,然后从左往右找比标志值大的,大值和右索引值交换,左索引变化 ...
- 010-Hadoop Hive sql语法详解5-HiveQL与SQL区别
1.Hive不支持等值连接 •SQL中对两表内联可以写成:•select * from dual a,dual b where a.key = b.key;•Hive中应为•select * from ...
- SDUT3146:Integer division 2(整数划分区间dp)
题目:传送门 题目描述 This is a very simple problem, just like previous one. You are given a postive integer n ...
- NGS中的一些软件功能介绍
1.bowtie 短序列比对工具,blast也是短序列比对工具,速度快,结果易理解. 输入可以是fastq或者fasta文件. 生成比对结果文件sam格式的吧. 2.bwa 转自:https://ww ...
- CCF 炉石传说(模拟)
试题编号: 201612-3 试题名称: 炉石传说 时间限制: 1.0s 内存限制: 256.0MB 问题描述 <炉石传说:魔兽英雄传>(Hearthstone: Heroes of Wa ...
- Oracle Union Union All 对查询结果集操作
在Oracle中提供了三种类型的集合操作: 并(UNION).交(INTERSECT).差(MINUS) Union:对两个结果集进行并集操作,不包括重复行,同时进行默认规则的排序: Union Al ...