![]() |
Python_2
1.0
|
Process fractions on a given file. More...
Public Member Functions | |
def | __init__ (self, filename) |
Constructor. More... | |
def | Reader (self, f) |
Reads a file with a numerator (int) and denominator (int) per line. More... | |
def | __getitem__ (self, i) |
Returns the ith fraction. More... | |
def | __setitem__ (self, i, f) |
Sets the ith fraction to f. More... | |
def | __str__ (self) |
Returns the sum and product of all entries of "lfracoes". More... | |
def | __repr__ (self) |
Returns each fraction in list "lfracoes". More... | |
Public Attributes | |
lfracoes | |
A list, which aggregates objects of type Fracao. More... | |
Process fractions on a given file.
def _01e_fracoes.Fracoes.__init__ | ( | self, | |
filename | |||
) |
Constructor.
Opens filename and calls Reader for inputting the fraction readings. Raises an exception if filename does not exist.
filename | fraction file name. |
def _01e_fracoes.Fracoes.__getitem__ | ( | self, | |
i | |||
) |
def _01e_fracoes.Fracoes.__repr__ | ( | self | ) |
Returns each fraction in list "lfracoes".
def _01e_fracoes.Fracoes.__setitem__ | ( | self, | |
i, | |||
f | |||
) |
Sets the ith fraction to f.
i | index. |
f | a fraction object. |
References _01e_fracoes.Fracoes.lfracoes.
def _01e_fracoes.Fracoes.__str__ | ( | self | ) |
Returns the sum and product of all entries of "lfracoes".
References _01e_fracoes.Fracoes.lfracoes.
def _01e_fracoes.Fracoes.Reader | ( | self, | |
f | |||
) |
Reads a file with a numerator (int) and denominator (int) per line.
Creates a Fracao object for each line and inserts it in the lfracoes list.
f | fraction file object. |
References _01e_fracoes.Fracoes.lfracoes.
_01e_fracoes.Fracoes.lfracoes |
A list, which aggregates objects of type Fracao.
Referenced by _01e_fracoes.Fracoes.__getitem__(), _01e_fracoes.Fracoes.__setitem__(), _01e_fracoes.Fracoes.__str__(), and _01e_fracoes.Fracoes.Reader().