Skip to content

Instantly share code, notes, and snippets.

@NickWoodhams
Last active February 1, 2017 22:01
Show Gist options
  • Save NickWoodhams/f1bb126b95b6f9931e621d8650ea62f3 to your computer and use it in GitHub Desktop.
Save NickWoodhams/f1bb126b95b6f9931e621d8650ea62f3 to your computer and use it in GitHub Desktop.
Generate a tuple with two random ints between 0 and 1000
#! /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)
#! /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