Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try:
- import random as r;
- except ImportError:
- print( "Nie ma takiego modulu!!!" );
- def losuj_z_przedzialu( start, stop ):
- l = r.randint( start, stop );
- return l;
- def losuj_z_konkretnego_zestawu( l ):
- lk = r.choice( l );
- return lk;
- def losuj_decyzje():
- d = r.randint( 0, 1 );
- return d;
- def zapisz_plik( lista ):
- file = "plik.csv";
- try:
- f = open( file, 'a' );
- except IOError:
- print( "Nieudana proba pracy z plikiem!");
- lista = str( lista );
- f.write( lista );
- f.write( '\n' );
- f.close();
- def czyszczenie():
- file = "plik.csv";
- try:
- f = open( file, 'w' );
- except IOError:
- print( "Nieudana proba pracy z plikiem!");
- f.write( '' );
- f.close();
- class System_decyzyjny:
- 'Generator systemu decyzyjnego'
- liczba_obiektow = 5;
- liczba_atrybutow = 4;
- def wypelnij_i_stworz( self ):
- lista = []
- for i in range( 0, System_decyzyjny.liczba_atrybutow ):
- x = losuj_z_przedzialu( 0, 9 )
- #x = losuj_z_konkretnego_zestawu( l = [ 1, 3, 7, 12 ] )
- lista.append( x );
- y = losuj_decyzje();
- lista.append( y );
- print( lista );
- zapisz_plik( lista );
- czyszczenie();
- for ob in range( 0, System_decyzyjny.liczba_obiektow ):
- ob = System_decyzyjny();
- ob.wypelnij_i_stworz();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement