Created
September 11, 2016 02:09
-
-
Save Spotik/0148a82fb42bba568c22fce3ff3fff54 to your computer and use it in GitHub Desktop.
https://repl.it/D3j4/0 created by Spotik
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Escreva um programa que leia um número N (obrigatoriamente entre 0 e 50) e em seguida preencha uma lista com | |
N elementos inteiros gerados aleatoriamente entre 0 e 1000 (usar a função randint da biblioteca random).''' | |
from random import randint | |
numero = -1 | |
lista = [] | |
count = 0 | |
while numero < 0 or numero > 50: | |
numero = input("Informe um número entre 0 e 50: ") | |
while count < numero: | |
x = randint(0,1000) | |
lista.append(x) | |
count += 1 | |
count = 0 | |
while count < len(lista): | |
print lista[count] | |
count += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python 2.7.10 (default, Jul 14 2015, 19:46:27) | |
[GCC 4.8.2] on linux | |
Informe um número entre 0 e 50: -3 | |
Informe um número entre 0 e 50: -3 | |
Informe um número entre 0 e 50: 60 | |
Informe um número entre 0 e 50: 5 | |
619 | |
385 | |
604 | |
489 | |
920 | |
=> None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment