CBSE 2026 results are out, Mukul scored a perfect 100/100 in Computer ScienceSee all toppers →

KwickAcademy Python · 8 min · free

Working with JSON and Third-party Libraries

8 min4 KwickClipsFull text belowFree
Next lesson →Kajal Ma'am (MCA), teaching since 2004Remembered in this browser

Learn what a Python library is, how pip installs third-party packages, and how to read and write JSON with dumps(), loads(), dump() and load().

On screen in this lesson

Module and library

Module: one Python file of reusable code
Library: a collection of modules for one kind of job
Standard library: comes with Python, like math and json
Third-party library: written by others, installed separately

What pip does

pip is Python's package installer
It downloads libraries from PyPI, the Python Package Index
Type it in the terminal, not inside Python
Safest form: python -m pip install numpy

Useful pip commands

CommandWhat it does
pip install NAMEdownloads, installs
pip listlists installed
pip show NAMEversion and details
pip uninstall NAMEremoves a library

What is JSON?

JSON: JavaScript Object Notation, a text format for data
Used by apps and websites to send data
Looks like a Python dictionary: {"name": "Riya"}
Keys and text always use double quotes

JSON and Python types

JSONPythonExample
objectdict{"a": 1}
arraylist[1, 2]
stringstr"Pune"
true, falseTrue, Falsetrue
nullNonenull

Choosing a well maintained library

Recent releases on its PyPI page
Clear documentation with examples
Many users, and questions get answers
A licence that allows your use
Exact name spelled correctly

Quick answers

What is the difference between dumps() and dump()?

dumps and loads, with an s, work with JSON text; dump and load, without an s, work with files.

What does True become in JSON?

true in small letters, and None becomes null.

KwickClips from this lesson

Short clips, one idea each. Good for revision the night before.

The full lesson, in text

Hello students, welcome to Kwickprep. When a weather app shows the temperature of Mumbai, how does the data travel from a server to your phone? Very often, it travels as JSON. Today we will learn what a library is and how pip installs one. We will also read and write JSON, and pick a good library.

First, some new words. A module is one Python file full of ready-made code that you can reuse. A library is a collection of modules for one kind of job, like maths or drawing charts. The standard library comes free with Python, and it includes math and json. A third-party library is written by other programmers, and you must install it before using it.

The import keyword brings a module into your program. After import math, we use its tools with a dot. Math dot sqrt gives the square root, so the square root of one hundred forty four is twelve point zero. Math dot pi is the value of pi, which is more than three. No installation was needed, because math comes with Python.

To install a third-party library, we use pip. Pip is the package installer that comes with Python, and a package is a library ready to install. Pip downloads packages from PyPI, the Python Package Index, a huge free online store of libraries. You type pip commands in the terminal, also called the command prompt, not inside a Python program. The safest form is python, dash m, pip install, and then the library name, because it uses the same Python you run.

Here are four pip commands you will use often. Pip install, followed by a name, downloads and installs that library. Pip list shows every library already installed on your computer. Pip show, followed by a name, tells you its version and details. Pip uninstall removes a library you no longer need. On some computers, the command is written as pip three instead of pip.

Now, JSON. JSON stands for JavaScript Object Notation, and it is a simple text format for storing data. Apps and websites use it to send data to each other, like train running status or cricket scores. It looks very much like a Python dictionary, which stores pairs of keys and values inside curly brackets. One strict rule is that keys and text must always use double quotes, never single quotes.

JSON has its own names for types, and Python converts them for you. A JSON object becomes a Python dictionary. A JSON array becomes a Python list. A JSON string becomes a Python string. JSON writes true and false in small letters, while Python uses a capital T and capital F. And JSON null becomes Python None, which means no value.

The json module has two pairs of functions. JSON dot dumps turns a Python value into a JSON string. The s at the end means string. So text is now plain text, ready to send. JSON dot loads does the opposite, and turns JSON text back into a dictionary. So back of marks is a number again, and eighty eight plus two prints ninety.

Pause and predict. We turn a list with True, None and hi in single quotes into JSON. What prints? True becomes true in small letters. None becomes null. And the single quotes change to double quotes. Exams and interviews love this small trap.

To save JSON in a file, we use dump and load, without the s. Open with w means open the file for writing, and it creates the file if it is missing, or replaces what was inside. The with keyword closes the file safely when the block ends. Here f is the open file. JSON dot dump writes the dictionary into result dot json. Then we open it again for reading, and json dot load gives back a dictionary. Python prints a dictionary with single quotes, because that is Python style, not JSON.

Anyone can upload a library, so choose carefully. First, check its page on PyPI for a recent release date, which shows people still fix it. Second, look for clear documentation, which means a guide with examples. Third, prefer a library with many users, where questions and bug reports get answers. Fourth, check the licence, which is the rule for how you may use the code. Fifth, type the name exactly, because fake libraries sometimes copy popular names with one letter changed.

Now a mini demo with a real third-party library called numpy. Numpy is a very popular maths library, and it is updated regularly. We install it once from the terminal, with python, dash m, pip install numpy. In the program, we write import numpy as np, so np becomes a short nickname. Numpy gives us an array, which holds many numbers and can work on all of them at once.

Here are the marks of four students in an array. Mean gives the average, which is the total divided by the count, so seventy eight point seven five. Max gives the highest mark, ninety five. Now the magic part. Marks plus five adds five grace marks to every student at once, with no loop. Float, int and tolist turn numpy answers into plain Python values, so they print just like normal numbers and lists.

Let us revise what we learned today. A library is ready-made code, and pip installs third-party libraries from PyPI. Dumps and loads, with an s, convert between Python and JSON text. Dump and load, without an s, write and read JSON files. Choose libraries with recent releases, clear documentation and many users. And numpy can work on a whole list of numbers at once. Try saving your own marks as a JSON file today.

Courses that teach this

CourseUnit
Programming All levels PythonInput/Output and File Handling

Voice-over in this lesson is AI-generated. The script is written and checked by Kajal Ma'am. Boards can revise a syllabus mid-year, so confirm anything you plan around against the official board circular. Keep your passwords, OTPs and ID numbers to yourself — we never ask for them. To reach Kajal Ma'am, use the WhatsApp button; sharing your number there is how we call you back.

Free to watch, no sign-up. Live classes with Kajal Ma'am are the paid course; these lessons stay free either way.

Want a plan that actually fits your board dates?

Ask Kajal Ma'am directly, 20+ years teaching computer science. Free demo class first, no payment.

Talk to Kajal Ma'am on WhatsApp

Or see the Class 12 Computer Science course →

Studying outside India?

We coach CBSE, IGCSE & international students across the globe, one-to-one, in your local time zone.

Visit International →