闲言碎语

python自学-乘法口诀代码

yyhouse · 10月18日 · 2019年

[v_notice]自己编写的代码,欢迎路过的大神批阅和点评[/v_notice]

实现功能

1、打印输乘法口诀 ceng=9
2、i=ceng resut=i+1 * ceng
1*1=1
1*2=2 2*2=4
1*3=3 2*3=6 3*3=9
。。。

源代码

ceng=1
print('开始打印乘法口诀。')
che=input('敲击回车开始展现。')
print(che,end='')
for ceng in range(1,10):
	i=1
	while i<=ceng:
		print('{}*{}={}'.format(i,ceng,(i*ceng)),end=' ')
		i+=1
	else:
		print('')
print('乘法口诀打印完毕。',end=' ')

效果展示

chengfa.png

0 条回应