• 代码如下
#!/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 = 36
7 * 1 = 7 7 * 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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乘法口诀表的更多相关文章

  1. Python 打印99乘法口诀表

    import string for x in xrange(1,10): for y in xrange(1,x+1): print string.ljust("%d*%d = " ...

  2. Java 面试 - 打印九九乘法口诀表

    在Java面试过程中, 面试者经常会被要求手写代码或上机操作.一般来说,手写代码或上机操作,主要还是考察面试者的分析问题和解决问题的能力.打印九九乘法口诀无疑是非常基础的,那么如何实现呢?首先我们先来 ...

  3. java 打印出99乘法口诀表

    public class Mutiplay { /** *实现99乘法表 * @param args */ public static void main(String[] args) { Syste ...

  4. print函数详解及python打印99乘法表的不同方法

    首先你需要了解print的原型,并且要知道在python2和python3中print函数功能不同,不只是表现在后面带不带()一方面! 在python3中,通过help(print)可以得到print ...

  5. python打印99乘法表

    代码如下: print(XXX,end="\t") #表示打印不换行 附带python部分转义字符:

  6. 如何利用while语句打印“九九乘法口诀表”

    需求:输出九九乘法表 plus.py代码如下: i=1 j=1 while i<=9: j=1 while j<=i: print(j,'*',i,'=',str(i*j)+' ',end ...

  7. python 9*9乘法口诀表

    # -*- coding: utf-8 -*- # __author__ = 'Carry' for i in range(1, 10): for j in range(1, i + 1): prin ...

  8. 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' ...

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

随机推荐

  1. angular中的动画效果

    用angular来形成动画效果的代码如下 <!DOCTYPE html> <html lang="en" ng-app="app"> & ...

  2. Go语言 map的实现

    Go中的map在底层是用哈希表实现的,你可以在 $GOROOT/src/pkg/runtime/hashmap.goc 找到它的实现. 数据结构 哈希表的数据结构中一些关键的域如下所示: struct ...

  3. cloud native

    什么是原生云(cloud native)应用? 原生云cloud-native应用的定义是:首先,应用系统应该与底层物理基础设施解耦.说白了,应用程序应该与操作系统等基础设施分离,不应该依赖Linux ...

  4. Googlebot (Google Web search)

    w推测“域名解析过程中,Google crawlers中首先是Googlebo中的Google Web search上阵”. +-----+----------------+------------- ...

  5. Python3量化技术常用插件

    1. 确定自己的系统为64位版本 2. 下载安装Python3 64位版本 如果要使用zipline,建议使用python3.5.另外发现很多东西要求的也是3.5. 主页地址: https://www ...

  6. JUnit4.12 源码分析(二)之TestRule

    1. TestRule TestRule和@Before,@After,@BeforeClass,@AfterClass功能类似,但是更加强大; JUnit 识别TestRule的两种方式: 方法级别 ...

  7. JSON 序列化与反序列化(二)使用TypeReference 构建类型安全的异构容器

    1. 泛型通常用于集合,如Set和Map等.这样的用法也就限制了每个容器只能有固定数目的类型参数,一般来说,这也确实是我们想要的. 然而有的时候我们需要更多的灵活性,如数据库可以用任意多的Column ...

  8. 1.新建项目出现包名有一道红线The SDK platform-tools version ((23)) is too old to check APIs compiled with API 20

    原因分析: 就是platform-tools的版本太低导致的 解决方法: 1.点开SDK Manager,打开SDK Tools面板,将Platform-tools更新 2.更新完之后重启as即可

  9. MySQLdb使用批量插入executemany方法插入mysql

    python的MySQLdb库可以使用批量操作executemany,进行多行插入. 比如向user表(username,salt,pwd)插入数据,具体的sql语句如下: sql = 'INSERT ...

  10. Java 语言中 Enum 类型的使用介绍【转载】

    简介:本文主要介绍了 Java 语言中枚举类型,以及如何定制 Enum 类型的定义,如何正确使用 Enum 类型. From:http://www.ibm.com/developerworks/cn/ ...