Last active
February 1, 2017 22:01
-
-
Save NickWoodhams/f1bb126b95b6f9931e621d8650ea62f3 to your computer and use it in GitHub Desktop.
Generate a tuple with two random ints between 0 and 1000
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 | |
# required library to create a matrix | |
import numpy | |
# random int library | |
from random import randint | |
from pprint import pprint | |
# create an empty list variable to add lists into | |
rows = [] | |
# iterate 2000 times, varible i is the number of iteration it's currently on | |
for i in range(2000): | |
# create 2 random ints between 0 and 1000 | |
r1 = randint(0, 1000) | |
r2 = randint(0, 1000) | |
# create a list of the two random ints | |
rand_pair = [r1, r2] | |
# prints the rand_pair variable to your terminal | |
print(rand_pair) | |
# append a 1x2 list to the rows list | |
rows.append(rand_pair) | |
# Creates a numpy matrix | |
m = numpy.matrix(rows) | |
pprint(m) |
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 | |
from random import randint | |
r1 = randint(0, 1000) | |
r2 = randint(0, 1000) | |
print(r1, r2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment