Hello, well well, I'm all new with Python, actually I've heard of it for the first time 2 or 3months ago...
I have to do a project for my class (I'm not even in Computer Sciences)and I need some help...

I start to be familiar with different expressions of the Python language, but I still don't have the Informatician logic...
my program is not ready yet,I still need to add a few things but it doesn't work...(maybe it's normal, but as I told you, I don't understand Python!!:( ) I don't know if you can already tell what's the problem with it by looking at it, or I should specify "my task"...

Thanks a lot, and here it goes:

>>> def create_list(size):
	my_list=[]
	for i in range(size):
		my_list.append(0)
	return my_list
>>> def create_matrix(rows,colomns):
		matrix=[]
	for i in range(rows):
		matrix.append(create_list(colomns))
	return matrix

    
# add a colomn of  0

>>>for j in range(len(my_list)):
	row = my_list[j]
	row.append(0)
	
	
# Add a row of 0
	
>>>for i in range(len(my_list)):
        colomn=my_list[i]
        colomn.append(0)

#  fix : z=1

>>> matrix[rows][colomns-2]=1
>>> matrix[rows][colomns-1]=1

>>> def search_pivot(matrix,rows,colomns):
	pivot=0
	for k in range(rows):
		if valeur_absolue(matrix[k][colomns]>valeur_absolue(pivot):
				  pivot=matrix[k][colomns]
	return pivot

So first of all, I have to ceate a matrix (nxm) n rows m colomns
2.) add a row and a colomn of 0
3.) fix a variable fro example z=1
4.)I don't know how you say it, in french it is called "pivot" it's a number in every colomn that needs to be equal with 1, by doing lineary combinations with the rows, I'm going to add my code, maybe it would be clearer like that... or not :(
after finding my "pivot" in every colomn, my matrix has only 0s and one 1 in ever colomn, except the last colomn which has different values.
5.) i have to take the last column and I have to turn them into integers (by giving a precision degree of 'n')
6.)then find the biggest common divider of the numbers of the last colomn to obtain sthg pretty...

Well, I don't know if it seems clearer now, but for me it's still really really hazy...

First, add some print statements for testing:

# add a colomn of  0
 
>>>for j in range(len(my_list)):
	row = my_list[j]
	row.append(0)
        print "row now =", j, row 
 
# Add a row of 0
 
>>>for i in range(len(my_list)):
        colomn=my_list[i]
        colomn.append(0)
        print "column now =", i, colomn
#
# a matrix (list of lists) is usually created by two for loops
matrix = []
for x in range(size):
    matrix.append([])  ## this row = empty list
    for y in range(size):  ## columns
        matrix[x].append(0)

matrix[1][2] = 1  ## change one entry
print matrix

Edited 5 Years Ago by woooee: n/a

This article has been dead for over six months. Start a new discussion instead.