Back to index

gcompris  8.2.2
Public Member Functions | Public Attributes
gnumch.PrimeLevelset Class Reference

List of all members.

Public Member Functions

def __init__
def getError
def getTitle
def setLevel
def getNumber

Public Attributes

 numlevels
 num_sublevels
 level_max
 curlevel
 cur_sublevel

Detailed Description

Definition at line 106 of file gnumch.py.


Constructor & Destructor Documentation

Definition at line 107 of file gnumch.py.

00107 
00108     def __init__(self):
00109         self.numlevels = 1
00110         self.num_sublevels = 9
00111         self.level_max = [ 3, 5, 7, 11, 13, 17, 19, 23, 29 ]
00112         self.curlevel = 1
00113         self.cur_sublevel = 1


Member Function Documentation

def gnumch.PrimeLevelset.getError (   self,
  num 
)

Definition at line 114 of file gnumch.py.

00114 
00115     def getError(self, num):
00116         fmt = _('%d is divisible by %s.')
00117         n = int(num.text)
00118 
00119         if n == 1:
00120             return _("1 is not a prime number.")
00121 
00122         factors = []
00123         for i in range(2, n/2 + 1):
00124             if n % i == 0:
00125                 factors.append(i)
00126         s = makeNumList(factors) % tuple(factors)
00127         return fmt % (n,s)

Here is the call graph for this function:

Definition at line 135 of file gnumch.py.

00135 
00136     def getNumber(self):
00137         n = random.randint( 1, self.level_max[self.cur_sublevel-1] )
00138         return Number( str(n), isPrime(n) )

Here is the call graph for this function:

Definition at line 128 of file gnumch.py.

00128 
00129     def getTitle(self):
00130         return _('Primes less than %d') % ( self.level_max[self.cur_sublevel-1] + 1 )

def gnumch.PrimeLevelset.setLevel (   self,
  level,
  sublevel 
)

Definition at line 131 of file gnumch.py.

00131 
00132     def setLevel(self, level, sublevel):
00133         self.cur_sublevel = level
00134         self.cur_sublevel = sublevel


Member Data Documentation

Definition at line 112 of file gnumch.py.

Definition at line 111 of file gnumch.py.

Definition at line 110 of file gnumch.py.

Definition at line 109 of file gnumch.py.

Definition at line 108 of file gnumch.py.


The documentation for this class was generated from the following file: