Major and natural minor scales based on C and A respectively do not contain any altered notes. To build these scales from any other note, it is necessary to change one or more notes. For example, in the G major scale, the note F is sharp. If you wanted to write a melody in G major, you would have to change all the F notes. To reduce the number of accidentals when writing music, we use key signatures. These accidentals, written between the key and the time signature, affect all notes of that name throughout the piece, including those in other octaves.
Key signatures are placed at the beginning of each staff, between the clef and the time signature:
In the previous melodic fragment, all the Fs are sharp. Therefore, if you want to write a natural F, you should precede it with a natural.
Keys with sharps in their key signatures are the following:
Keys with flats in their key signatures are the following: