 # Python pow() method

## pow() in Python

Python pow() function returns the power of the given numbers. This function computes x**y. This function first converts its arguments into float and then computes the power.

Syntax: pow(x,y)

Parameters :

• x : Number whose power has to be calculated.
• y : Value raised to compute power.

Return Value :  Returns the value x**y in float.

## Python pow() example

### Example 1: Working of pow()

 `# Python code to demonstrate pow()` `# version 1` `print``(``"The value of 3**4 is : "``, end``=``"")` `# Returns 81` `print``(``pow``(``3``, ``4``))`

Output:

`The value of 3**4 is : 81.0`

### Example 2: Python pow() with three argument

float pow(x,y,mod) function computes (x**y) % mod. This function first converts its arguments into float and then computes the power.

Syntax: float pow(x,y,mod)

Parameters :

• x : Number whose power has to be calculated.
• y : Value raised to compute power.
• mod :  Value with which modulus has to be computed.

Return Value :  Returns the value (x**y) % mod in float.

 `# Python code to demonstrate pow()` `# version 2` `print``(``"The value of (3**4) % 10 is : "``, end``=``"")` `# Returns 81%10` `# Returns 1` `print``(``pow``(``3``, ``4``, ``10``))`

Output:

`The value of (3**4) % 10 is : 1`

### Implementation Cases in pow() : `# Python code to discuss negative` `# and non-negative cases` `# positive x, positive y (x**y)` `print``(``"Positive x and positive y : "``, end``=``"")` `print``(``pow``(``4``, ``3``))` `print``(``"Negative x and positive y : "``, end``=``"")` `# negative x, positive y (-x**y)` `print``(``pow``(``-``4``, ``3``))` `print``(``"Positive x and negative y : "``, end``=``"")` `# positive x, negative y (x**-y)` `print``(``pow``(``4``, ``-``3``))` `print``(``"Negative x and negative y : "``, end``=``"")` `# negative x, negative y (-x**-y)` `print``(``pow``(``-``4``, ``-``3``))`

Output:

```Positive x and positive y : 64
Negative x and positive y : -64
Positive x and negative y : 0.015625
Negative x and negative y : -0.015625```

Last Updated on November 13, 2021 by admin

## Python – Pandas Dataframe.sample()Python – Pandas Dataframe.sample()

Python Pandas Dataframe.sample()   Pandas sample() is used to generate a sample random row or column from the function caller data frame. Syntax: DataFrame.sample(n=None, frac=None, replace=False, weights=None, random_state=None, axis=None) Parameters: n: int value, Number of random rows to generate. frac:

## Pandas dataframe.std()Pandas dataframe.std()

Pandas dataframe.std() Pandas dataframe.std() function return sample standard deviation over requested axis. By default the standard deviations are normalized by N-1. It is a measure that is used to quantify the amount of variation or dispersion of a set of

## Taking multiple inputs from user in PythonTaking multiple inputs from user in Python

Taking multiple inputs from user in Python Developer often wants a user to enter multiple values or inputs in one line. In C++/C user can take multiple inputs in one line using scanf but in Python user can take multiple

## Python – Creating a button in tkinterPython – Creating a button in tkinter

Python | Creating a button in tkinter Tkinter is Python’s standard GUI (Graphical User Interface) package. It is one of the most commonly used packages for GUI applications which comes with Python itself. Let’s see how to create a button

## Difference between Python and C++Difference between Python and C++

Difference between Python and C++ Python tutorial: Python is a high-level, interpreted programming language. It was invented back in 1991, by Guido Van Rossum. Python is an object-oriented programming language that has large enormous library support making the implementation of various

## Randomly select rows from Pandas DataFrameRandomly select rows from Pandas DataFrame

In data analysis and machine learning tasks, it is often necessary to randomly select rows from a Pandas DataFrame. This can be useful for tasks such as creating train-test splits, generating random samples, or conducting statistical analysis on a subset

## Python – Convert a list of Tuples into DictionaryPython – Convert a list of Tuples into Dictionary

Python | Convert a list of Tuples into Dictionary Sometimes you might need to convert a tuple to dict object to make it more readable. In this article, we will try to learn how to convert a list of tuples into a dictionary. Here

## Priority Queue in PythonPriority Queue in Python

Priority Queue in Python Priority Queues are abstract data structures where each data/value in the queue has a certain priority. For example, In airlines, baggage with the title “Business” or “First-class” arrives earlier than the rest. Priority Queue is an