<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Homework 4
CHE 116
Step1:  2. Representing Numbers (5 Points)
Answers these symbolically
[1 point] What is the mantissa and what is the exponent of $0.3422 \times 10^{-4}$. 
[1 point] What is the largest representable number with 10 bits?
[1 point] In a number system of base 8, how many numbers can be represented with 4 digits places?
[2 points] How do we do boolean expressions with floating numbers? Is it valid to compare floating numbers at all?
2.1
0.3442
2.2
$$
2^{10} - 1 = 1023
$$
2.3
$$
8^4 = 4096
$$
2.4
Floating point comparisons are fine with inequalities (&lt;, &gt;), but not equalities (==)
3. Booleans (20 Points)
[4 points] Write python code that will print 'greater than 10' when the variable z is greater than 10.
[4 points] Write python code that will print 'special' if the variable z less than -25 but greater than -35.
[2 points] Use the % operator in python, which computes the remainder of the left number after being divided by the right number, to compute the remainder of 12 divided by 5.
[4 points] Use the % operator in a boolean expression to print 'even' if the variable z is even.
[6 points] Write code that prints out if the variable z is positive or negative, even or odd, and greater in magnitude than 10.
Step2:  4. Lists and Slicing (11 Points)
Answers these questions in Python. Print your result
[2 points] Create a list of all positive even integers less than 20 using the range function.
[1 point] Using the list created above and a slice, print out the third-largest even integer less than 20.
[2 points] Print out the first 3 integers from your list in question 4.1
[2 points] Create a list of the integers 1 to 10 and then using the assignment operator (=), override the last element to be 100. 
[4 points] Create a list of the integers 1 to 4 and then use a for loop print out $2^i$, where $i$ is the elements in your list.
Step3:  5. Numpy (12 Points)
Answers these questions in Python
When specifying an interval, parenthesis indicate an exclusive end-point and brackets indicate an inclusive end-point. So $\left(0,1\right)$ means from 0 to 1, not including 0 or 1. $\left[0, 1\right)$ means from 0 to 1 including 0 but not including 1. 
[2 points] Create an array of numbers that goes from $\left[1, 10\right)$ in increments of 0.25 using the arange function.
[2 points] Create an array of numbers that goes from $\left[1, 10\right)$ in increments of 0.25 using the linspace function.
[2 points] Create an array of 21 numbers that go from $\left[0,1\right]$ using the arange function.
[2 points] Create an array of 21 numbers that go from $\left[0,1\right]$ using the linspace function.
[4 points] Using an array, print out the first 8 powers of 3 (e.g., $3^0$, $3^1$, $3^2$, etc)
Step4:  6. Plotting (16 Points)
*Answer these in questions in Python. Label your axes as x-axis and y-axis. *
[4 points] Make a plot of the cosine from $-pi$ to $0$.
[4 points] We will see that the equation $e^{-x^2}$ is important in a few weeks. Make a plot of it from -2, to 2. 
[8 pints] Plot $x$, $x^2$, and $x^3$ from -1 to 1. Label your lines with a legend, add a title, use the seaborn-darkgrid style, and set the figure size as $4\times3$.
<ASSISTANT_TASK:>
Python Code:
#1.1
import math
print('{:.4}'.format(math.pi))
#1.2 - no for loop
print('{:5.4}'.format(math.sqrt(1)))
print('{:5.4}'.format(math.sqrt(2)))
print('{:5.4}'.format(math.sqrt(3)))
print('{:5.4}'.format(math.sqrt(4)))
print('{:5.4}'.format(math.sqrt(5)))
#1.2 - for loop
for i in range(1, 6):
    print('{:5.4}'.format(math.sqrt(i)))
print('{0:} {0:}'.format('test'))
Explanation: Homework 4
CHE 116: Numerical Methods and Statistics
2/8/2018
1. String Formatting (4 Points)
Answer these in Python
[1 point] Print $\pi$ to 4 digits of precision. Use pi from the math module.
[2 points] Print the square root of the first 5 integers starting from 1 with 4 digits of precision. Print the terms with one per line and have them all take up exactly 5 spaces. 2 Bonus points if you use a for loop
[1 point] Show how to print the same variable twice using the variable index part of the : operator in a string.}
End of explanation
#3.1
z = -27
if z > 10:
    print('greater than 10')
#3.2
if z < -25 and z > -35:
    print('special')
#3.3
12 % 5
#3.4
if z % 2 == 0:
    print('even')
#3.5
if z % 2 == 0:
    print('even')
else:
    print('odd')
if z > 0:
    print ('positive')
elif z < 0:
    print('negative')
if abs(z) > 10:
    print('greater in magnitude than 10')
Explanation: 2. Representing Numbers (5 Points)
Answers these symbolically
[1 point] What is the mantissa and what is the exponent of $0.3422 \times 10^{-4}$. 
[1 point] What is the largest representable number with 10 bits?
[1 point] In a number system of base 8, how many numbers can be represented with 4 digits places?
[2 points] How do we do boolean expressions with floating numbers? Is it valid to compare floating numbers at all?
2.1
0.3442
2.2
$$
2^{10} - 1 = 1023
$$
2.3
$$
8^4 = 4096
$$
2.4
Floating point comparisons are fine with inequalities (&lt;, &gt;), but not equalities (==)
3. Booleans (20 Points)
[4 points] Write python code that will print 'greater than 10' when the variable z is greater than 10.
[4 points] Write python code that will print 'special' if the variable z less than -25 but greater than -35.
[2 points] Use the % operator in python, which computes the remainder of the left number after being divided by the right number, to compute the remainder of 12 divided by 5.
[4 points] Use the % operator in a boolean expression to print 'even' if the variable z is even.
[6 points] Write code that prints out if the variable z is positive or negative, even or odd, and greater in magnitude than 10.
End of explanation
#4.1
x = list(range(2,20,2))
x
#4.2
x[-3]
#4.3
x[:3]
#4.4
x = list(range(1,11))
x[-1] = 100
x
#4.5
x = list(range(1,5))
for thing in x:
    print(2**thing)
Explanation: 4. Lists and Slicing (11 Points)
Answers these questions in Python. Print your result
[2 points] Create a list of all positive even integers less than 20 using the range function.
[1 point] Using the list created above and a slice, print out the third-largest even integer less than 20.
[2 points] Print out the first 3 integers from your list in question 4.1
[2 points] Create a list of the integers 1 to 10 and then using the assignment operator (=), override the last element to be 100. 
[4 points] Create a list of the integers 1 to 4 and then use a for loop print out $2^i$, where $i$ is the elements in your list.
End of explanation
#5.1
import numpy as np
np.arange(1, 10, 0.25)
#5.2
np.linspace(1,9.75,36)
#5.3
np.arange(0,1.05, 0.05)
#5.4
np.linspace(0,1,21)
#5.5
x = np.arange(0,8)
print(3**x)
Explanation: 5. Numpy (12 Points)
Answers these questions in Python
When specifying an interval, parenthesis indicate an exclusive end-point and brackets indicate an inclusive end-point. So $\left(0,1\right)$ means from 0 to 1, not including 0 or 1. $\left[0, 1\right)$ means from 0 to 1 including 0 but not including 1. 
[2 points] Create an array of numbers that goes from $\left[1, 10\right)$ in increments of 0.25 using the arange function.
[2 points] Create an array of numbers that goes from $\left[1, 10\right)$ in increments of 0.25 using the linspace function.
[2 points] Create an array of 21 numbers that go from $\left[0,1\right]$ using the arange function.
[2 points] Create an array of 21 numbers that go from $\left[0,1\right]$ using the linspace function.
[4 points] Using an array, print out the first 8 powers of 3 (e.g., $3^0$, $3^1$, $3^2$, etc)
End of explanation
%matplotlib inline
import matplotlib.pyplot as plt
#6.1
x = np.linspace(-np.pi, 0, 100)
y = np.cos(x)
plt.plot(x,y)
plt.xlabel('x')
plt.ylabel('y')
plt.show()
#6.2
x = np.linspace(-2, 2, 100)
y = np.exp(-x**2)
plt.plot(x,y)
plt.xlabel('x')
plt.ylabel('y')
plt.show()
#6.3
plt.style.use('seaborn-darkgrid')
plt.figure(figsize=(4,3))
x = np.linspace(-1, 1, 100)
y1 = x
y2 = x**2
y3 = x**3
plt.plot(x,y1, label='x')
plt.plot(x,y2, label='x^2')
plt.plot(x,y3, label='x^3')
plt.xlabel('x')
plt.ylabel('y')
plt.legend()
plt.title('Nice Title')
plt.show()
Explanation: 6. Plotting (16 Points)
*Answer these in questions in Python. Label your axes as x-axis and y-axis. *
[4 points] Make a plot of the cosine from $-pi$ to $0$.
[4 points] We will see that the equation $e^{-x^2}$ is important in a few weeks. Make a plot of it from -2, to 2. 
[8 pints] Plot $x$, $x^2$, and $x^3$ from -1 to 1. Label your lines with a legend, add a title, use the seaborn-darkgrid style, and set the figure size as $4\times3$.
End of explanation
<END_TASK>