Replacing a character with a number based on lines

Hi,

I am in need of help for the two things which is to be done.

First, I have a file that has around four columns. The first column is filled with letter "A".

There are around 400 lines in the files as shown below.

A  1   5.2   3.2
A  2   0.2   4.5
A  1   2.2   2.2
A  5   2.1   3.2
....................

I want to replace the letter " A " with the number "2" but only for the lines from 201st line to 300th line. So, as an ouput , I should have letter " A " in the first column for the first 200 lines , then the number " 2 " should be displayed for the first column from the line 201st to 300th line instead of letter "A". From 301st line to 400th line, the first column should be displayed as " A"

Second thing, is that, I have a file with four columns. It consists of around 400 lines.

The first column consists of letter "A" or " B ". For example:

A  1   5.2   3.2
A  2   0.2   4.5
B  0   5.5   11
A  1   2.2   2.2
B  1   9.9   0.01
A  5   2.1   3.2

I want the letter " A" in the first column to be replaced with number " 1" and the letter " B" in the second column to be replace with number " 2" . The expected result should be:

1  1   5.2   3.2
1  2   0.2   4.5
2  0   5.5   11
1  1   2.2   2.2
2  1   9.9   0.01
1  5   2.1   3.2
sed '
  201,300s/^A/1/
 ' in_file >out_file
 
sed '
  s/^A/1/
  t
  s/^B/2/
 ' in_file >out_file

The t skips the B test if it is an A, for speed.

Just re-formatting as one-liners (basically same content as previous correct response):

sed '201,300 s/^A/1/' in_file_1 > out_file_1
sed 's/^A/1/; s/^B/2/' in_file_2 > out_file_2