HUN

4/1. moduloz_init

Írjunk osztályt Moduloz névvel modulo n (egész számok) maradék gyűrű elemek reprezentálására.
Például modulo 5 gyűrűben:
4 + 3 = 2 (mert 7 % 5 = 2)
2 - 3 = 4 (mert -1 % 5 = 4)
4 * 3 = 2 (mert 12 % 5 = 2)

A műveleteket ebben a feladatban még nem kell definiálni csak az __init__ és __str__ metódusokat. Létrehozáskor két paramétert kap egy ilyen objektum, az elsõ ami szerint a maradékot számoljuk, a második a szám értéke.
A moduló alapja pozitív egész, a szám maga egész lesz.
A __str__ csak adja vissza a számot, sztringként.

Például a következõ programrészletre:
a = Moduloz(5, 7)
print a


Azt a kimenetet kapjuk, hogy:
2

4/2. moduloz_operations

Írjuk meg az __add__, __sub__, __mul__ műveleteket a korábban megírt Moduloz osztályhoz!

Például modulo 5 gyűrűben:
4 + 3 = 2 (mert 7 % 5 = 2)
2 - 3 = 4 (mert -1 % 5 = 4)
4 * 3 = 2 (mert 12 % 5 = 2)

Figyeljünk arra, hogy ezen műveletek eredményei ne egészek (int), hanem a Moduloz osztály példányai legyenek!
Például a következő programrészletre:
 a = Moduloz(7, 9) b = Moduloz(7, 12) 
print a + b print a - b print a * b

Azt a kimenetet kapjuk, hogy:
 0 4 3 

4/3. matrix_init

Írjunk Matrix nevû osztályt ami mátrixokat reprezentál.

Például a következõ programrészletre:
 m = Matrix([[1, 2], [13, 4], [5, 6]])  print m 
Azt a kimenetet kapjuk, hogy:
  1   2  
13 4
5 6
Még csak az __init__ és __str__ metódusokat kell megírni. Egy mátrix létrehozáskor listák listáját kap, mely a mátrix elemeit tartalmazza. A kiírása történjen úgy, hogy minden elemnek legalább 4 karakternyi helye legyen. (A példában minden szám elõtt 3 szóköz van, kivéve a 13 elõtt, azelõtt 2.)

4/4. matrix_operations

Írjuk meg az __add__, __sub__, __mul__ műveleteket a korábban megírt Matrix osztályhoz!

A mátrixok négyzetesek lesznek, szóval a méretükkel nem kell most törődni.

Például a következõ programrészletre:
 m1 = Matrix([[1, 2], [3, 4]]) m2 = Matrix([[1, 0], [0, 2]])  print a + b 

Azt a kimenetet kapjuk, hogy:
    2   2  
3 6

ENG

4/1. moduloz_init

Define a class called Moduloz representing modulo n numbers (integers).
For example in modulo 5:
4 + 3 = 2 (because 7 % 5 = 2)
2 - 3 = 4 (because -1 % 5 = 4)
4 * 3 = 2 (because 12 % 5 = 2)

You don't have to implement the operations yet, just define the __init__ and the __str__ methods.

In the constructor you will have two parameters, except self. The first one is the base of the modulo, the second one is the actual number.

The base will be a positive integer, the value will be an integer.

The __str__ should return a string, containing the value.

For example:
a = ModuloZ(5, 7)
print a


Should print:
2

4/2. moduloz_operations

Implement the __add__, __sub__, __mul__ methods for the previous Moduloz class!

For example in modulo 5:
4 + 3 = 2 (because 7 % 5 = 2)
2 - 3 = 4 (because -1 % 5 = 4)
4 * 3 = 2 (because 12 % 5 = 2)

Mind that the operations should return an object of class Moduloz, not an integer (int)!
For example:
 a = Moduloz(7, 9) b = Moduloz(7, 12) 
print a + b print a - b print a * b

should print:
 0 4 3 
In the test outputs you can see the sum, difference and the product of the two input numbers.

Hint


4/3. matrix_init

Define a class called Matrix for representing matrices.

You have to implement the __init__ and __str__ methods.
The constructor has one parameter (except self), a list of list of numbers. The elements of the matrix.
The __str__ should return a multi-line string, containing the matrix in a tabular-like format.
For example:
 m = Matrix([[1, 2], [13, 4], [5, 6]])  print m 
should print this:
  1   2  
13 4
5 6
The numbers are padded to the right in 4 characters width. There are 3 spaces before each element, except the 13 because there are 2 spaces there.

4/4. matrix_operations

Implement the __add__, __sub__, __mul__ methods for the previous Matrix class.

The matrices will be square shaped, so every operation is compatible.

For example:
 m1 = Matrix([[1, 2], [3, 4]]) m2 = Matrix([[1, 0], [0, 2]])  print a + b 

should print this:
    2   2  
3 6


In the test you can see the sum, difference and the dot product of the two input matrices.

Hint