Lazy Programming Series

Lazy programming Series – Module and Simple Program

Modules:

In Python, a module is a file containing Python definitions and statements. The file name is the module name with the suffix .py added. Modules allow you to organize Python code into reusable units. These units can consist of functions, classes, and variables that can be used in other Python files by importing the module.

For example, if you have a file named my_module.py with the following content:

You can use this module in another Python script by importing it:

In this example, the another_script.py file imports the my_module module and uses its greet and square functions. This helps in organizing code, promoting code reusability, and avoiding naming conflicts.

You can also use the from ... import ... syntax to import specific functions or variables from a module:

This way, you directly import only the elements you need from the module. Modules are a fundamental concept in Python programming, providing a way to structure and organize code in larger projects.

Pip stands for:- python package manager

Modules are of 2 types:

  1. Build-in Module
  2. External Module

C:\> pip install panda

Simple Program to begin the python programming.

Code:

Output:

Hi, I’m saksham dixit

Leave a Reply

Your email address will not be published. Required fields are marked *