当前位置:网站首页>实例008:九九乘法表
实例008:九九乘法表
2022-07-05 08:16:00 【懒笑翻】
实例008:九九乘法表
题目:输出 9*9 乘法口诀表。
程序分析:分行与列考虑,共9行9列,i控制行,j控制列。
# 第i行有i列,range是半闭半开区间因此range要到i+1 # 为输出更美观,对于相乘的结果设置为%-2d即占2位,-表示左对齐,不加-就是默认右对齐 end=''即输出后不换行
代码如下:
for i in range(1, 10):
for j in range(1, i + 1): # 第i行有i列,range是半闭半开区间因此range要到i+1
print('%d*%d=%-2d ' % (i, j, i * j), end='') # 为输出更美观,对于相乘的结果设置为%-2d即占2位,-表示左对齐,不加-就是默认右对齐 end=''即输出后不换行
print() #换行输出结果如下:
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 
边栏推荐
- QEMU STM32 vscode debugging environment configuration
- Google sitemap files for rails Projects - Google sitemap files for rails projects
- 【论文阅读】2022年最新迁移学习综述笔注(Transferability in Deep Learning: A Survey)
- STM32 virtualization environment of QEMU
- STM32 outputs 1PPS with adjustable phase
- Basic information commands and functions of kernel development
- Network communication process
- Explication de la procédure stockée pour SQL Server
- Soem EtherCAT source code analysis attachment 1 (establishment of communication operation environment)
- Brief discussion on Buck buck circuit
猜你喜欢

Ble encryption details

More than 90% of hardware engineers will encounter problems when MOS tubes are burned out!
![C WinForm [help interface - send email] - practice five](/img/2a/c4e7abe054e6fdd45acc7d297a033d.jpg)
C WinForm [help interface - send email] - practice five
![[cloud native | learn kubernetes from scratch] III. kubernetes cluster management tool kubectl](/img/8a/702019b44c8e60dffbcd898330afcb.png)
[cloud native | learn kubernetes from scratch] III. kubernetes cluster management tool kubectl

Several implementation schemes of anti reverse connection protection of positive and negative poles of power supply!

Network communication process

STM32 single chip microcomputer -- debug in keil5 cannot enter the main function

【论文阅读】2022年最新迁移学习综述笔注(Transferability in Deep Learning: A Survey)

MySQL MHA high availability cluster

Classic application of MOS transistor circuit design (1) -iic bidirectional level shift
随机推荐
leetcode - 445. 两数相加 II
Consul安装
Detailed summary of FIO test hard disk performance parameters and examples (with source code)
STM32 single chip microcomputer - external interrupt
Explain task scheduling based on Cortex-M3 in detail (Part 1)
Several important parameters of LDO circuit design and type selection
Gradle复合构建
Sql Server的存儲過程詳解
C WinForm [display real-time time in the status bar] - practical exercise 1
PMSM dead time compensation
Classic application of MOS transistor circuit design (1) -iic bidirectional level shift
Wifi-802.11 negotiation rate table
Create inf module in AMI code
matlab timeserise
STM32 outputs 1PPS with adjustable phase
Talk about the circuit use of TVs tube
Fundamentals of C language
Simple design description of MIC circuit of ECM mobile phone
Development tools -- gcc compiler usage
More than 90% of hardware engineers will encounter problems when MOS tubes are burned out!