Rajendra Dharmkar has Published 452 Articles

What is the difference between attributes and properties in python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 08-May-2023 12:03:59

6K+ Views

In python, everything is an object. And every object has attributes and methods or functions. Attributes are described by data variables for example like name, age, height etc. Properties are special kind of attributes which have getter, setter and delete methods like __get__, __set__ and __delete__ methods. A property decorator ... Read More

What are the differences between list, sequence and slice data types in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 08-May-2023 11:52:34

1K+ Views

We will learn about the differences between list, sequence, and slice data types in Python in this article. Lists − In Python, a list is a type of data that can hold multiple values in a single variable. You can think of it like a shopping list that contains multiple ... Read More

Why would you use the return statement in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 02-May-2023 14:00:23

3K+ Views

The return statement in Python is used to return a value or a set of values from a function. When a return statement is encountered in a function, the function execution is stopped and the value specified in the return statement is returned to the caller. The main purpose of ... Read More

What do the python file extensions, .pyc .pyd .pyo stand for?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 02-May-2023 13:52:24

6K+ Views

The .py, .pyc, .pyo and .pyd files have their own significance when it comes to executing python programs. They are used for − .py: The input source code that you've written. .pyc: The compiled bytecode. If you import a module, python will build a *.pyc file that contains the bytecode ... Read More

How to write recursive Python Function to find factorial?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 02-May-2023 13:49:46

474 Views

Factorial of a number is the product of all the positive integers from 1 to that number. For example, the factorial of 4 is 4*3*2*1 = 24. To find the factorial of a number using recursive Python function, we can define a function that calls itself with a smaller input ... Read More

How to set python environment variable PYTHONPATH on Windows?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 02-May-2023 12:43:46

34K+ Views

On Windows, you can set the PYTHONPATH environment variable to specify the directories that Python should search for modules when importing them. Here are several ways to set the PYTHONPATH environment variable on Windows Set PYTHONPATH using Command Prompt You can set the PYTHONPATH environment variable using Command Prompt by ... Read More

How to set python environment variable PYTHONPATH on Mac?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 02-May-2023 12:42:27

9K+ Views

To set the Python environment variable PYTHONPATH on a Mac, you can follow these steps − Open the Terminal app on your Mac. Navigate to your home directory by typing cd ~ and pressing Enter. Open the .bash_profile file in a text editor by typing open -e .bash_profile and pressing ... Read More

How to set Python environment variable PYTHONPATH on Linux?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 02-May-2023 12:39:55

16K+ Views

To set the PYTHONPATH environment variable on Linux, follow these steps − Open a terminal window on your Linux system. Determine the path to your Python module or package. For example, suppose you have a Python module named mymodule located in the /home/user/myproject folder. Set the PYTHONPATH environment variable to the path of your module or package using ... Read More

How to remove all trailing whitespace of string in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 02-May-2023 12:33:55

4K+ Views

Any character or group of characters that depicts horizontal or vertical space is known as whitespace. A whitespace character usually takes up space on a page even though it does not correspond to any visible mark when it is rendered. Pressing the spacebar will allow you to enter a whitespace ... Read More

How to pass Python function as a function argument?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 02-May-2023 12:32:13

20K+ Views

In Python, you can pass a function as an argument to another function. This is known as a higher-order function. In other words, a function is called a higher-order function if it contains other functions as parameters or returns functions. Python supports the usage of higher-order functions as it is ... Read More

Advertisements