# How to Find the Z Critical Value in Python?

In this article, we are going to learn about how to find the Z Critical Value in Python.

## What is Z Critical Value?

In statistics, the region under the common normal model is referred to as the Z critical value. Every possible variable's probability is shown. A test statistic is what is produced when we do a hypothesis test. To determine if the outcome of the hypothesis test is statistically significant, the test statistic can be compared to a Z critical value. An outcome is regarded as statistically significant when its absolute value exceeds the Z critical value. The determination of Z critical value in Python will be covered in this tutorial.

When you do a hypothesis test, you will receive a test statistic as a consequence. To see if the hypothesis test findings are statistically significant, compare the test statistic to a Z critical value. If the absolute value of the test statistic exceeds the Z critical value, the test findings are statistically significant.

### Syntax

In Python, you may get the Z critical value using the scipy.stats.norm.ppf() method, which has the following syntax −

scipy.stats.norm.ppf(q)


where q represents, the significance level to use.

## Z critical value in python

### 1. Left-tailed test

Let's say we wish to determine the Z critical value for a left-tailed test with a.05 levels of significance −

### Example

!pip3 install scipy
import scipy.stats

#find Z critical value
scipy.stats.norm.ppf(.05)


### Output

-1.6448536269514729


The crucial value for Z is -1.64485. The test's results are thus statistically significant if the test statistic is below this threshold.

### 2. Right-tailed test

Let's say we're looking for the Z critical value for a right-tailed test with a.05 levels of significance −

### Example

import scipy.stats

#find Z critical value
scipy.stats.norm.ppf(1-.05)


### Output

1.6448536269514722


The crucial number for Z is 1.64485. The test's results are thus considered statistically significant if the test statistic is higher than this number.

### 3. Two-tailed test

Let's say we're looking for the Z critical value for a two-tailed test with a.05 levels of significance −

### Example

import scipy.stats

#find Z critical value
scipy.stats.norm.ppf(1-.05/2)


### Output

1.959963984540054


There are always two essential values when you do a two-tailed test. 1.95996 and -1.95996 are the Z critical values in this situation. Therefore, the test's findings are statistically significant if the test statistic is either less than -1.95996 or more than 1.95996.

## Conclusion

In statistics, Z critical value is used to determine the insights of the data, so the machine learning model can use it and gives prediction based on it.