reasoning under uncertainty def __repr__(self)return self name "variable({self name}) representing factors factor ismathematicallya function from variables into numberthat is given value for each of its variableit gives number factors are used for conditional probabilitiesutilities in the next and are explicitly constructed by some algorithms (in particular variable eliminationa variable assignmentor just assignmentis represented as {variable valuedictionary factor can be evaluated when all of its variables are assigned the method get_value evaluates the factor for an assignment the assignment can include extra variables not in the factor this method needs to be defined for every subclass probfactors py -factors for graphical models from display import displayable import math class factor(displayable)nextid= each factor has unique identifierfor printing def __init__(self,variables)self variables variables ordered list of variables self id factor nextid self name " {self id}factor nextid + def can_evaluate(self,assignment)"""true when the factor can be evaluated in the assignment assignment is {variable:valuedict ""return all( in assignment for in self variables def get_value(self,assignment)"""returns the value of the factor given the assignment of values to variables needs to be defined for each subclass ""assert self can_evaluate(assignmentraise notimplementederror("get_value"abstract method the method __str__ returns brief definition (like " ( , , )"the method to_table returns string representations of table showing all of the assignments of values to variablesand the corresponding value probfactors py -(continued def __str__(self)version june