Created
January 24, 2022 10:11
-
-
Save misgeatgit/1efa36956f9a6f0e8bb410563f712ee8 to your computer and use it in GitHub Desktop.
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
mport json | |
import urllib | |
people = ["Misgana", "Rahel", "Yosef", "Nemera", "Hawi", "Bayetta", "Fantaye", "Kemeru", "Ayantu", "Ayelech"] | |
generated = [False]*len(people) | |
random_number_service_url = f"https://qrng.anu.edu.au/API/jsonI.php?length={len(people)}&type=uint16" | |
names_generated = [] | |
while not all(generated): | |
request = urllib.request.urlopen(random_number_service_url) | |
data = json.load(request) | |
indices = [n%len(people) for n in data['data']] | |
for i in indices: | |
generated[i] = True | |
names_generated.append(people[i]) | |
counts = {} | |
for name in names_generated: | |
if name in counts: | |
counts[name] += 1 | |
else: | |
counts[name] = 1 | |
for name_count in sorted(counts.items(), key= lambda item: item[1], reverse=True): | |
print(name_count[0]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment