Python 练习实例88
最后更新于:2022-03-27 01:26:36
Python 练习实例88
题目:读取7个数(1—50)的整数值,每读取一个值,程序打印出该值个数的*。
程序分析:无。
实例
#!/usr/bin/python
# -*- coding: UTF-8 -*- if __name__ == ‘__main__‘:
n = 1
while n <= 7:
a = int(raw_input(‘input a number:\n‘))
while a < 1 or a > 50:
a = int(raw_input(‘input a number:\n‘))
print a * ‘*‘
n += 1
# -*- coding: UTF-8 -*- if __name__ == ‘__main__‘:
n = 1
while n <= 7:
a = int(raw_input(‘input a number:\n‘))
while a < 1 or a > 50:
a = int(raw_input(‘input a number:\n‘))
print a * ‘*‘
n += 1
以上实例输出结果为:
input a number: 9 ********* input a number: 5 ***** input a number: 6 ****** input a number: