Next question, If a note in a score has an accidental or natural with it and the same note has an accidental in the key signature how is this affecting pitch? I think it does not. If it did, why is the accidental entered with the note, if it is already in the signature.
An accidental is an alteration that is not in the key signature.
So if we are in the key of G major, an f sharp has an alteration (sharp) but is not an accidental. In the same key, an f has an alteration (none) which requires an accidental (natural) to be printed.
In lilypond we explicitly represent pitches as a step plus alteration (if an alteration is omitted, it is assumed as none, not as following the key signature). This is a design decision that allows the notes to be entered as specified pitches, regardless of the key signature. Thus, the pitches do not change when the key signature changes; only the display of the pitches changes.
Personally, I am glad the lilypond creators made this choice. I always enter the pitches I want to hear, and the display of those pitches can be easily changed.
Thanks,
Carl