GitLab system status is available here and here

Commit 5318fb21 authored by Ethan Yeung's avatar Ethan Yeung
Browse files

session 6 prompt for coding journal 1

parent 3addc6b9
%% Cell type:code id:d87d8f00 tags:
``` python
from math import sin
def sine(x):
return sin(x)
```
%% Cell type:markdown id:d6c72632 tags:
uses the math library to return the sine of a value
%% Cell type:code id:81e39760 tags:
``` python
from math import cos
def cosine(x):
return cos(x)
```
%% Cell type:markdown id:e42035be tags:
uses the math library to return the cosine of a value
%% Cell type:code id:015f427b tags:
``` python
from math import pi
from numpy import linspace
x_vals = linspace(0, 2*pi, 1000)
sin_vals = []
cos_vals = []
for x in x_vals:
sin_vals.append(sine(x))
cos_vals.append(cosine(x))
```
%% Cell type:markdown id:3b0e3a33 tags:
puts the values of x, sin(x), and cos(x) into lists
%% Cell type:code id:e3a021ac tags:
``` python
print(" x | sin(x) | cos(x)")
print("------|-----------|----------")
for i in range(0, 10):
x = x_vals[i]
s = sin_vals[i]
c = cos_vals[i]
print(f"{x:.5} | {s:.5} | {c:.5}")
```
%% Cell type:markdown id:5cb6268c tags:
prints out the first ten values of x, sin(x), and cos(x)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment