Matrix Formation In Python