北信Python0906-第六天-作业

1.打印 9 * 9 乘法表: 使用while循环和for循环
1 * 1 = 1
2 * 1 = 2 2 * 2 = 4
3 * 1 = 3 3 * 2 = 6 …

9 * 1 = 9 9 * 2 = 18 … 9 * 9 = 81
选做: 使用while单层循环完成
while循环

i = 1
while i <= 9:
    j = 1
    while(j <= i):   
        print(f'{i}*{j}={i*j}', end='\t')
        j += 1
    print('')
    i += 1

“E:\云计算\python\20210906Python\python interpreter\python.exe” E:/云计算/python/20210906Python/pycharm-professional-2018.3.7安装/others/10.16.py
11=1
2
1=2 22=4
3
1=3 32=6 33=9
41=4 42=8 43=12 44=16
51=5 52=10 53=15 54=20 55=25
6
1=6 62=12 63=18 64=24 65=30 66=36
7
1=7 72=14 73=21 74=28 75=35 76=42 77=49
81=8 82=16 83=24 84=32 85=40 86=48 87=56 88=64
91=9 92=18 93=27 94=36 95=45 96=54 97=63 98=72 9*9=81

Process finished with exit code 0

for循环

for i in range(1, 10):
    for j in range(1, i+1):
        print(f'{j}x{i}={i*j}\t', end='')
    print()

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值