Latest web development tutorials

Python beinhaltet 88 Übungen

Python 100 Li Python 100 Li

Titel: 7 liest die Nummer (1-50) ganzzahlige Werte, die jeweils einen Wert zu lesen, das Programm druckt die Nummer der Wert *.

Programmanalyse: Keine.

Source Code:

#!/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

Das obige Beispiel Ausgabe lautet:

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

Python 100 Li Python 100 Li