This content originally appeared on DEV Community and was authored by Nitin-bhatt46
PACKAGES .
Importing a Python Package
To use a package in Python, you need to:
• Ensure the package is installed (using pip for external packages).
• Use the import statement in your script.
Standard Import Example:
python
import math # Imports the standard math package
result = math.sqrt(16)
For user-created packages or subpackages:
python
from mypackage.mymodule import myfunction
Pseudocode:
• Install the package, if external.
• Use import package_name or from package.module import item.
Importing a Less Common Package (PrettyTable)
Step 1: Install PrettyTable
bash
pip install prettytable
Step 2: Import and Use
python
from prettytable import PrettyTable
READ THE DOCUMENT AND GENRATE BELOW OUTPUT.
print(table)
OUTPUT :-
+-----------------------+------------+
| Pokemon Name | Type |
+----------------------+------------+
| Pikachu | Electric |
| Squirtle | Water |
| Charmander | Fire |
+----------------------+------------+
Pseudocode:
• Run pip install for the package (e.g., pip install prettytable)
• Use from prettytable import PrettyTable in your code
• Create table objects and operate using its methods
Coffee Machine Program Using Packages (GitHub Version Outline)
• Import logic to bring classes together.
• ALL THE PACKAGES ARE IN GITHUB.
• DOWNLOAD AND CREATE OUTPUT WHICH WE HAVE GENERATE IN PREVIOUS COFFEE_MACHINE
This content originally appeared on DEV Community and was authored by Nitin-bhatt46
Nitin-bhatt46 | Sciencx (2025-10-29T04:42:00+00:00) Day 18 of My AI & Data Mastery Journey: From Python to Generative AI. Retrieved from https://www.scien.cx/2025/10/29/day-18-of-my-ai-data-mastery-journey-from-python-to-generative-ai/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.