Python math: Difference between revisions

From wikinotes
m (Will moved page Python Math to Python math)
 
(No difference)

Latest revision as of 14:53, 6 May 2018

I'm no mathematician, and I severely doubt that I'll use anywhere near all of the math modules that python is capable of using. I think as I get more into 3D engines, this may play an important role.


Basic Math

## Arithmetic
var = 1 + 3 - 1
var = 4 / 2 *4
var = 13 // 4			## division without remainder
var = 13 % 4			## remainder only

## Exponents

iterations

 import itertools

permutations every possible combination of a number without repetition (ex: single dice)

import itertools
for i in itertools.permutations('ABCD', 2) :
  print i

Cartesian Product Every possible combination of a number with repeating numbers (ex: multiple dice)

import itertools
for i in itertools.product('ABCD', repeat=2) :
  print i