code: def save_and_check(response, local_file, expected_checksum):
      
      with open(local_file, 'wb') as handle:
          for chunk in response.iter_content(4096):
              handle.write(chunk)
  
      actual_checksum = md5sum(local_file)
      if actual_checksum != expected_checksum:
          logging.error('Checksum mismatch for %r. Expected %r, got %r',
                        local_file, expected_checksum, actual_checksum)
          return False
  
      return True
docs: Save the content of an http response and verify the checksum matches.