菜鸟教程 -- 学的不仅是技术,更是梦想!

Python 基础教程
(追記) (追記ここまで)

Python 练习实例88

Python 100例 Python 100例

题目:读取7个数(1—50)的整数值,每读取一个值,程序打印出该值个数的*。

程序分析:无。

实例

#!/usr/bin/python# -*- coding: UTF-8 -*-if__name__ == '__main__': n = 1whilen <= 7: a = int(raw_input('input a number:\n'))whilea < 1ora > 50: a = int(raw_input('input a number:\n'))printa * '*'n += 1

以上实例输出结果为:

input a number:
9
*********
input a number:
5
*****
input a number:
6
******
input a number:

Python 100例 Python 100例

AI 思考中...

4 篇笔记 写笔记

  1. #0

    yanice

    672***[email protected]

    4

    参考方法:

    #!/usr/bin/python
    # -*- coding: UTF-8 -*-
    import random
    # 随机输出 3 个 1~10 的星个数
    num=[]
    s=['*']
    for i in range(0,3):
     num.append(random.randint(1,10)) 
     print " * 个数为:",num[i]
     print '*'*num[i]
    

    yanice

    672***[email protected]

    9年前 (2017年08月23日)
  2. #0

    掷骰子

    fxy***[email protected]

    2

    Python3 下测试实例:

    #!/usr/bin/python3
    import random
    for i in range(1,7):
     a = random.randint(0,50)
     print(a,'\n')
     for j in range(0,a):
     print('*',end='')
     print('\n')
    

    掷骰子

    fxy***[email protected]

    9年前 (2017年09月07日)
  3. #0

    pjdssjdcr

    735***[email protected]

    1

    参考方法:

    # -*- coding: utf-8 -*-
    from __future__ import print_function
    for i in range(7):
     n = int(raw_input('a number:\n'))
     for j in range(n):
     print('*',end = '')
     print('')

    pjdssjdcr

    735***[email protected]

    9年前 (2017年10月12日)
  4. #0

    tiantian

    120***[email protected]

    1

    参考方法:

    #encoding=utf-8
    for i in range(7):
     a=int(raw_input("enter a number(1-50): "))
     if a<0 or a>50:
     a=int(raw_input("enter a number(1-50): "))
     print "*"*a

    tiantian

    120***[email protected]

    9年前 (2017年11月01日)

点我分享笔记

  • 昵称 (必填)
  • 邮箱 (必填)
  • 引用地址

AltStyle によって変換されたページ (->オリジナル) /