python学习——练习题(8)
2017-12-18 09:57
211 查看
""" 题目:输出 9*9 乘法口诀表。 """ def answer1(): """ 自己用最普通的双重循环来输出 :return: """ print("输出一:") for i in range(1, 10): for j in range(1, i + 1): print("%d x %d =%2s" % (i, j, i * j), end=" ") print() answer1() def answer2(): """ while循环,与另一种格式化 注意print 百分号(%)格式化输出,以%开始为标志设置输出的格式,而fomate格式化是以冒号(:)开始为标志设置字符串格式 :return: """ print("输出二:") i = 1 while i < 10: j = 1 while j <= i: print("{} x {} ={:2}".format(i, j, i * j), end=" ") j += 1 print() i += 1 answer2()
相关文章推荐
- python学习——练习题(1)
- python三天简单学习Day2练习题
- python学习——练习题(7)
- python学习——练习题(10)
- Python小白学习之路(四)——第一次练习题
- 【python】编程学习练习题--3
- python3学习之练习题
- python学习——练习题(13)
- PythonNLP学习进阶:第二章练习题(Python自然语言处理)
- Python练习题 10-2 C语言学习笔记
- 【python】编程学习练习题-2
- python学习——练习题(6)
- Python初学习:简单的练习题
- Python学习之day4列表练习题:购物车
- python学习习题总结(9)——练习题猴子桃子,7个数字组成的奇数。。。
- 【Python学习笔记】Python练习题:filter()
- python学习--小练习题(二)
- python 进阶学习之5--入门练习题
- 【python】编程学习练习题-1
- python学习——练习题(9)