From 5b745282a923bee43b1bd3ee972a2351637b45ae Mon Sep 17 00:00:00 2001 From: uttamo Date: Thu, 28 Sep 2017 01:02:29 +0100 Subject: [PATCH 1/2] Use random.choice instead of random.randint random.choice is better for selecting random elements from a list than using random.randint to generate random indices to select --- scripts/13_random_name_generator.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/scripts/13_random_name_generator.py b/scripts/13_random_name_generator.py index 6f0a00a..0acb9bf 100755 --- a/scripts/13_random_name_generator.py +++ b/scripts/13_random_name_generator.py @@ -1,4 +1,4 @@ -from random import randint +from random import choice def random_name_generator(first, second, x): @@ -10,13 +10,8 @@ def random_name_generator(first, second, x): - number of random names """ names = [] - for i in range(0, int(x)): - random_first = randint(0, len(first)-1) - random_last = randint(0, len(second)-1) - names.append("{0} {1}".format( - first[random_first], - second[random_last]) - ) + for i in range(x): + names.append("{0} {1}".format(choice(first), choice(second))) return set(names) From cb448c2dc3593dbfbe1ca47b49193b320115aae5 Mon Sep 17 00:00:00 2001 From: Michael Herman Date: Sun, 25 Mar 2018 08:56:49 -0600 Subject: [PATCH 2/2] updated readme --- LICENSE | 2 +- readme.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 2ae0d76..3a6fa11 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 realpython +Copyright (c) 2018 Real Python Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/readme.md b/readme.md index 59d5c64..78f4a72 100755 --- a/readme.md +++ b/readme.md @@ -32,4 +32,5 @@ 1. **30_fullcontact.py**: Call the [FullcContact](https://www.fullcontact.com/developer/) API 1. **31_youtube_sentiment.py**: Calculate sentiment score from the comments of a Youtube video 1. **32_stock_scraper.py**: Get stock prices +1. **33_country_code.py**: Convert country code to country name 1. **34_git_all_repos.py**: Clone all repositories from a public user or organization on Github. Usage: `python git_all_repos.py users USER_NAME` or `python git_all_repos.py orgs ORG_NAME`