code: def expectation_payload(prep_prog, operator_programs, random_seed):
      
      if operator_programs is None:
          operator_programs = [Program()]
  
      if not isinstance(prep_prog, Program):
          raise TypeError("prep_prog variable must be a Quil program object")
  
      payload = {'type': TYPE_EXPECTATION,
                 'state-preparation': prep_prog.out(),
                 'operators': [x.out() for x in operator_programs]}
  
      if random_seed is not None:
          payload['rng-seed'] = random_seed
  
      return payload
docs: REST payload for :py:func:`ForestConnection._expectation`