Pranathi M has Published 23 Articles

How will you compare modules, classes and namespaces in Python?

Pranathi M

Pranathi M

Updated on 11-May-2023 14:31:57

511 Views

Python allows you to save definitions to a file and then use them in a script or interactive instance of the interpreter. A module is a file that contains definitions that can be imported into other modules or the main module. So, a Python module is nothing more than a ... Read More

How to work with a text file in Python?

Pranathi M

Pranathi M

Updated on 11-May-2023 14:25:59

868 Views

For creating, reading, updating, and removing files, Python includes a number of functions. When reading or writing to a file, the access mode determines the kind of operations that can be performed on the file. Creating a file using Python To create new files or open existing files, we ... Read More

How do we use easy_install to install Python modules?

Pranathi M

Pranathi M

Updated on 16-Sep-2022 08:15:57

5K+ Views

Easy Install is a python module that is bundled with setuptools (easy_install) that allows you to download, compile, install, and manage Python packages automatically. It was included in setuptools in 2004 and is now deprecated. It was remarkable at the time for automatically installing dependencies and installing packages from PyPI ... Read More

How to set default parameter values to a function in Python?

Pranathi M

Pranathi M

Updated on 16-Sep-2022 07:38:48

13K+ Views

Python functions are used to implement logic that you wish to run repeatedly at various locations across your code. These functions accept function arguments as input parameters. You can specify default argument values in Python functions in addition to supplying parameters to them through function calls. If you don't explicitly ... Read More

What are the basic scoping rules for python variables?

Pranathi M

Pranathi M

Updated on 16-Sep-2022 07:37:34

330 Views

Variables are classified into Global variables and Local variables based on their scope. The main difference between Global and local variables is that global variables can be accessed globally in the entire program, whereas local variables can be accessed only within the function or block in which they are defined. ... Read More

How does variable scopes work in Python Modules?

Pranathi M

Pranathi M

Updated on 16-Sep-2022 07:34:35

932 Views

The scope of the Python object determines its accessibility. The scope must be specified in order to access the particular variable in the code because it cannot be accessible from anywhere in the program. The term "scope" describes the precise coding region where variables are shown. It is possible to ... Read More

What are required arguments of a function in python?

Pranathi M

Pranathi M

Updated on 16-Sep-2022 07:29:41

2K+ Views

Functions accept arguments that can contain data. The function name is followed by parenthesis that list the arguments. Simply separate each argument with a comma to add as many as you like. As the name implies, mandatory arguments are those that must be given to the function at the time ... Read More

How to use variable-length arguments in a function in Python?

Pranathi M

Pranathi M

Updated on 16-Sep-2022 07:28:09

15K+ Views

As the name implies, an argument with a variable length can take on a variety of values. You define a variable argument using a '*', for example *args, to show that the function can take a variable number of arguments. Observations on Python's variable-length arguments are as follows. The ... Read More

How to use Lambda Function in Python?

Pranathi M

Pranathi M

Updated on 16-Sep-2022 07:24:05

2K+ Views

The anonymous nature of Python Lambda Functions indicates that they lack a name. As we already know, a standard Python function is defined using the def keyword. Similar to this, the lambda keyword is utilized in Python to declare an anonymous function. Syntax The syntax of the lambda expression in ... Read More

How to create python namespace packages in Python 3?

Pranathi M

Pranathi M

Updated on 16-Sep-2022 07:20:38

2K+ Views

Using namespace packages, you can distribute the sub-packages and modules of one package among many, independent distribution packages (referred to as distributions in this document to avoid ambiguity). In Python, a namespace package allows you to spread Python code among several projects. This is useful when you want to release ... Read More

Advertisements