-2

hi guys can anyone explain to me this code. i dont really get this. thanks a lot.

def readFile(name = ""):
try:
assert (name != "") , "The file name is not given!!"
except AssertionError:
print "file name is not given"
else:
try:
f = open(name, 'r')
except:
print 'File not found!'
else:
lines = f.readlines()
return lines
def fixNewline(lines):
newList = []
for line in lines:
line = line.replace("\n", "")
newList.append(line)
return newList

def converttoMatrix(lines):
matrix = []
for row in lines:
elements = row.split('\t')
rowToAppend = []
for element in elements:
rowToAppend.append(int(element))
matrix.append(rowToAppend)
return matrix

#to find the max value
def findmaxvalue(matrix):
maxvalue = 0
for row in matrix:
print row
for col in row:
print col
maxvalue = max(col,maxvalue)
return maxvalue

#to find the min value
def findminvalue(matrix):
minvalue = 0
for row in matrix:
#print row
for col in row:
#print col
minvalue = min(col,minvalue)
return minvalue


if __name__ == '__main__':
readFile()
readFile("")
readFile("xzy")


those inside the define statement are indented for some reason this would not allow me to indent. thanks for your help.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by SgtMe
0

What are you trying to do? What do you need to find out? What does it do? Why should we help you? Why aren't you using code tags? What the hell are you even talking about...

Edited by SgtMe: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.