Does it look bad if you take an AP exam before the class?

Like others who have commented, I would not do this.

I would either take the AP test early and then not take the class, or more likely I would wait until you have taken the class before taking the test. My suspicion is that you might know the material reasonably well, but there might be quite a few details that you do not know or do not have quite a complete grasp of.

Also, if you are interested in CS, or in any of the many subjects that make use of CS (AI and machine learning come to mind, but math is another area that uses CS, as is physics, and there is a lot more), then computer science principles is an area where it is worth taking the time to know very well. Calculus is another area which has a very broad applicability to a lot that you are likely to do in the future (both in a class and on a job) and that is very much worth learning very well.

Patience will serve you well in life.

2 Likes