JNCIA-DevOps Data Serialization Practice Question
You are writing a Python script using the PyEZ library to retrieve interface facts from a Juniper EX Series switch. The resulting data structure is stored in a Python dictionary. You need to dump this dictionary into a YAML file so it can be read by an Ansible playbook later. Which PyYAML function should you use to convert the Python dictionary into a YAML-formatted string or file stream?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
yaml.dump()
yaml.dump() is the standard PyYAML function used to serialize Python objects (such as dictionaries) into a YAML-formatted stream or string.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
yaml.load()
Why it's wrong here
yaml.load() is used for deserializing YAML text into Python objects, not serializing Python objects to YAML.
- ✗
yaml.serialize()
Why it's wrong here
yaml.serialize() is an internal low-level PyYAML emitter function, not the primary user-facing serialization method.
- ✗
yaml.safe_load()
Why it's wrong here
yaml.safe_load() is a secure deserialization method used to parse untrusted YAML inputs.
- ✓
yaml.dump()
Why this is correct
yaml.dump() serializes a Python object structure into a YAML byte or string stream.
About these practice questions
Courseiva writes every JNCIA-DevOps question from scratch — 306 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed August 2026 · checked against the official Juniper Networks exam blueprint
This JNCIA-DevOps practice question is part of Courseiva's free Juniper Networks certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the JNCIA-DevOps exam.