Bird
0
0

Which function is used to convert a Python dictionary to a JSON string?

easy📝 Conceptual Q2 of 15
Python - Structured Data Files

Which function is used to convert a Python dictionary to a JSON string?

Ajson.dumps()
Bjson.loads()
Cjson.dump()
Djson.load()
Step-by-Step Solution
Solution:
  1. Step 1: Understand the difference between dumps and dump

    json.dumps() converts a Python object to a JSON string.
  2. Step 2: Differentiate from load and loads

    json.loads() parses a JSON string to a Python object; json.dump() writes JSON to a file; json.load() reads JSON from a file.
  3. Final Answer:

    json.dumps() -> Option A
  4. Quick Check:

    Convert dict to JSON string = json.dumps() [OK]
Quick Trick: Use json.dumps() to get JSON string from dict [OK]
Common Mistakes:
  • Mixing dumps() with dump()
  • Using load() instead of loads() for strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes