Created
April 18, 2013 03:40
-
-
Save quilime/5409921 to your computer and use it in GitHub Desktop.
random stars in the console
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
#!/usr/bin/python | |
import random | |
rows = 20 | |
cols = 80 | |
num_stars = 100 | |
rand_stars = [] | |
while (len(rand_stars) < num_stars): | |
rand = random.randint(0, rows * cols) | |
if rand not in rand_stars: | |
rand_stars.append(rand) | |
count = 0 | |
out = '' | |
for r in range(rows): | |
for c in range(cols): | |
if count in rand_stars: | |
out += '*' | |
else: | |
out += ' ' | |
count = count + 1 | |
out += "\n" | |
print out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment