Write a 440 Hz Sine Wave to .wav-File using Python and SciPy This is my first post on DSP.SE! I'm a student in Computer Sciences and am just getting started with Signals and Systems, thus getting in touch with discrete signals and analyzing them. 

I wanted to explore this world a little further and so my first goal is to create a Sine Wave that has a Frequency of 440 Hz and write it to a .wav-File. Of course i have all the calculus in mind, but i can't seem to figure out the problem myself!

So far, i have this:

#!/usr/bin/env python3

import numpy as np
from scipy.io import wavfile

sampleRate = 44100

t = np.linspace(0, 20, sampleRate * 5)  #  Produces a 5 second Audio-File
y = np.sin(440 * t)  #  Should have frequency of 440Hz

wavfile.write('Sine.wav', sampleRate, y)


I understand why this code always creates a File, that is 5 seconds long, but i can't figure out, how to get the frequency right!

Have i even gotten the rest of the code right, Dsp-Guy-wise?
After some experimenting i came up with the following:

#!/usr/bin/env python3

import numpy as np
from scipy.io import wavfile

sampleRate = 44100
frequency = 440
length = 5

t = np.linspace(0, length, sampleRate * length)  #  Produces a 5 second Audio-File
y = np.sin(frequency * 2 * np.pi * t)  #  Has frequency of 440Hz

wavfile.write('Sine.wav', sampleRate, y)


I pulled out one of my math-books and figured out how to write the sine-function:

Since sin(x) has a period of 2*pi, sin(2*pi*x) has a period of 1/Frequency of 1Hz. Thus, sin(440*2*pi*x) has a Frequency of 440Hz. 

The last thing that was unclear to me was how to get the array-length and element-count right!

Opting for a File that has a sample rate of 5 seconds at 44.1 kHz Sample Rate, i need 5 * 44.1k samples, so that was already ok. But since sin(440*2*pi*x) performs 440 periods until t == 1, the array simply has to have a duration of 5 (5 seconds in my case to be precise). enlarging the array boundaries would have squished the array-values together, resulting in a higher pitched sound.

Sorry to anyone that has already scratched their head, i probably should have thought for a little bit longer!