Last active
April 19, 2018 21:06
-
-
Save mightywombat/7cf88eacda92692b4225b248203aa80f to your computer and use it in GitHub Desktop.
practicepython.org Ex 05
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
# practicepython.org Ex 05 | |
import random as ra | |
def randrng(): | |
numlist = [] | |
rnglen = ra.randrange(10, 20) | |
while rnglen > 0: | |
numlist.append(ra.randrange(1, 100)) | |
rnglen -= 1 | |
return numlist | |
range1 = randrng() | |
range2 = randrng() | |
matchy = [] | |
for value1 in range1: | |
for value2 in range2: | |
if value1 == value2: | |
matchy.append(value2) | |
print ( "Matching numbers are, in order: " + str(sorted(matchy))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script generates a list of randomly generated length (between 10 and 20), populated with randomly generated numbers (1 to 100) and compares them together to extract the overlapping values between the lists. It then presents the list of matching numbers at the command line, ordered lowest to highest.