<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
Step1:  Day 5
Step2:  Example
Step3:  Question 1
Less than 19.5 hours?
Step4:  Question 2
Between 20 and 22 hours?
<ASSISTANT_TASK:>
Python Code:
import math
from matplotlib import pylab as plt
%matplotlib inline
def pdf(x, m, variance):
    sigma = math.sqrt(variance)
    probability density function
    return 1 / (sigma * math.sqrt(2 * math.pi)) * math.e ** (-1 * ((x - m)**2 / (2 * variance ** 2)))
pdf(20, 20, 4)
Explanation: Day 5: Normal Distribution I
https://www.hackerrank.com/challenges/s10-normal-distribution-1
Objective
In this challenge, we learn about normal distributions. Check out the Tutorial tab for learning materials!
Task
In a certain plant, the time taken to assemble a car is a random variable, X, having a normal distribution with a mean of 20 hours and a standard deviation of 2 hours. What is the probability that a car can be assembled at this plant in:
Question 1:
Less than 19.5  hours?
Question 2:
Between  20 and 22 hours?
Input Format
There are  lines of input (shown below):
20 2
19.5
20 22
The first line contains 2 space-separated values denoting the respective mean and standard deviation for X. The second line contains the number associated with question 1. The third line contains 2 space-separated values describing the respective lower and upper range boundaries for question 2.
If you do not wish to read this information from stdin, you can hard-code it into your program.
End of explanation
N = range(50)
mean = 15
variance = 3
plt.plot(N, [pdf(i, mean, variance) for i in N])
def cumulative(x, m, stdv):
    return 0.5 * (1 + math.erf((x-m)/ (stdv * math.sqrt(2)) ))
[(i, cumulative(i, 20.0, 3.0)) for i in range(1, 30)]
mean = 20 
variance = 4
Explanation: Example
End of explanation
x = 19.5
q1_answer = cumulative(x, mean, math.sqrt(variance))
q1_answer
Explanation: Question 1
Less than 19.5 hours?
End of explanation
lower_hour, upper_hour = 20.0, 22.0
q2_answer = cumulative(upper_hour, mean, math.sqrt(variance)) - cumulative(lower_hour, mean, math.sqrt(variance))
q2_answer
Explanation: Question 2
Between 20 and 22 hours?
End of explanation
<END_TASK>