zoukankan      html  css  js  c++  java
  • Python 9*9口诀

    #!/usr/bin/env python
    # _*_ coding:utf-8 _*_
    # Author:Liuyoushui
    # Time = 2017/7/18 10:33
    
    print ('
    '.join([' '.join(['%s*%s=%2s' % (y,x,x*y) for y in range(1,x+1)]) for x in range(1,10)]))
    
    print(['{}*{}={} '.format(n,i,i*n)  for  i in range(1,10) for n in range(1,10)])
    
    print ((['%s*%s=%2s' % (y,x,x*y) for y in range(1,x+1)]) for x in range(1,10))
    
    print ([ ['{}*{}={} '.format(i,n,i*n)  for  i in range(1,10) if n >=i] for n in range(1,10) ] )
    
    a = ([ ['{}*{}={} '.format(i,n,i*n)  for  i in range(1,10) if n >=i] for n in range(1,10) ] )
    for i in a:
        print(' | '.join(i))
    
    for i in a:
        print(i)
    
    E:Pythonpython3.5python.exe E:/pycharm/projects/item/tanzhou/test/随机数.py
    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 4*5=20 5*5=25
    1*6= 6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=36
    1*7= 7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49
    1*8= 8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=64
    1*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
    ['1*1=1 ', '2*1=2 ', '3*1=3 ', '4*1=4 ', '5*1=5 ', '6*1=6 ', '7*1=7 ', '8*1=8 ', '9*1=9 ', '1*2=2 ', '2*2=4 ', '3*2=6 ', '4*2=8 ', '5*2=10 ', '6*2=12 ', '7*2=14 ', '8*2=16 ', '9*2=18 ', '1*3=3 ', '2*3=6 ', '3*3=9 ', '4*3=12 ', '5*3=15 ', '6*3=18 ', '7*3=21 ', '8*3=24 ', '9*3=27 ', '1*4=4 ', '2*4=8 ', '3*4=12 ', '4*4=16 ', '5*4=20 ', '6*4=24 ', '7*4=28 ', '8*4=32 ', '9*4=36 ', '1*5=5 ', '2*5=10 ', '3*5=15 ', '4*5=20 ', '5*5=25 ', '6*5=30 ', '7*5=35 ', '8*5=40 ', '9*5=45 ', '1*6=6 ', '2*6=12 ', '3*6=18 ', '4*6=24 ', '5*6=30 ', '6*6=36 ', '7*6=42 ', '8*6=48 ', '9*6=54 ', '1*7=7 ', '2*7=14 ', '3*7=21 ', '4*7=28 ', '5*7=35 ', '6*7=42 ', '7*7=49 ', '8*7=56 ', '9*7=63 ', '1*8=8 ', '2*8=16 ', '3*8=24 ', '4*8=32 ', '5*8=40 ', '6*8=48 ', '7*8=56 ', '8*8=64 ', '9*8=72 ', '1*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 ']
    <generator object <genexpr> at 0x000001A2147D0E08>
    [['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 ', '4*5=20 ', '5*5=25 '], ['1*6=6 ', '2*6=12 ', '3*6=18 ', '4*6=24 ', '5*6=30 ', '6*6=36 '], ['1*7=7 ', '2*7=14 ', '3*7=21 ', '4*7=28 ', '5*7=35 ', '6*7=42 ', '7*7=49 '], ['1*8=8 ', '2*8=16 ', '3*8=24 ', '4*8=32 ', '5*8=40 ', '6*8=48 ', '7*8=56 ', '8*8=64 '], ['1*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 ']]
    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  | 4*5=20  | 5*5=25 
    1*6=6  | 2*6=12  | 3*6=18  | 4*6=24  | 5*6=30  | 6*6=36 
    1*7=7  | 2*7=14  | 3*7=21  | 4*7=28  | 5*7=35  | 6*7=42  | 7*7=49 
    1*8=8  | 2*8=16  | 3*8=24  | 4*8=32  | 5*8=40  | 6*8=48  | 7*8=56  | 8*8=64 
    1*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 
    ['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 ', '4*5=20 ', '5*5=25 ']
    ['1*6=6 ', '2*6=12 ', '3*6=18 ', '4*6=24 ', '5*6=30 ', '6*6=36 ']
    ['1*7=7 ', '2*7=14 ', '3*7=21 ', '4*7=28 ', '5*7=35 ', '6*7=42 ', '7*7=49 ']
    ['1*8=8 ', '2*8=16 ', '3*8=24 ', '4*8=32 ', '5*8=40 ', '6*8=48 ', '7*8=56 ', '8*8=64 ']
    ['1*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 ']
    
    Process finished with exit code 0
    
  • 相关阅读:
    [转自老马的文章]用MODI OCR 21种语言
    [转老马的文章]MODI中的OCR模块
    贴片晶振的脚位方向如何区分
    晶振简介及如何使用示波器测试晶振
    Lintcode 150.买卖股票的最佳时机 II
    Lintcode 82.落单的数
    Lintcode 97.二叉树的最大深度
    Lintcode 9.Fizz Buzz 问题
    LeetCode之461. Hamming Distance
    NYOJ之题目325 zb的生日
  • 原文地址:https://www.cnblogs.com/liuyoushui/p/7200570.html
Copyright © 2011-2022 走看看