• 代码如下
#!/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. 启动phpstyle Apache的80端口被win7的System PID=4的进程占用的解决方法 以及 如何在phpStyle里发布程序

    学习前端是,用到Ajax,php语言,操作mysql数据库,浏览器无法解析php代码(把源码输出):原因,我之前用的是tomcat服务器写jsp,servlet,php用的是apache服务器,没有配 ...

  2. Spring 拦截器的使用

    一.Web.xml配置 在Web.xml 配置Spring核心控制器DispatcherServlet接收所有请求 <servlet> <servlet-name>spring ...

  3. python widows安裝scipy

    https://blog.csdn.net/github_39611196/article/details/76718707 Python3.x直接运行pip install scipy即可.Pyth ...

  4. Flask之flask-script

    简介 Flask-Scropt插件为在Flask里编写额外的脚本提供了支持.这包括运行一个开发服务器,一个定制的Python命令行,用于执行初始化数据库.定时任务和其他属于web应用之外的命令行任务的 ...

  5. Win2003X64位,IIS6.0 32位 浏览报错的解决方案

    目录 问题案例 原因分析 解决问题 其他 问题案例 1)服务浏览出现: service unavailable 2)服务浏览出现:HTTP 404 当前页找不到 3)在事件查看器:应用程序中报错:在同 ...

  6. shell_01

    定义变量: name='qwer' 不解析任何字符 name="qwer" 会解析$和\特殊字符 name1=123;name2=456 定义多个变量 now_date=`date ...

  7. Pycharm建立web2py项目并简单连接MySQL数据库

    引言 web2py是一种免费的,开源的web开发框架,用于敏捷地开发安全的,数据库驱动的web应用:web2p采用Python语言编写,并且可以使用Python编程.web2py是一个完整的堆栈框架, ...

  8. MySQL对指定字段进行加密(双向加密)

    1:建表 test create table test( name varchar(200), value blob ); 插入数据 使用 ENCODE 加密: ,ENCODE('加密字段值', '钥 ...

  9. bash: ./a.sh: /bin/bash^M: bad interpreter: No such file or directory的解决方法------dos--->unix

    一些人喜欢用vim来写linux shell script, 但是, 有的人喜欢在Windows下用一些方便的编辑器(比如鼎鼎大名的Notepad++)写好, 然后拷贝文件到linux下, 结果呢, ...

  10. C语言中const和数组

    C语言中const的用法 const:在定义变量时,如果使用关键字const,那就表示限制这个变量值不允许被改变. (1)     修饰变量 const离谁越近,谁的值就不能改变. int const ...