Do practice timed tests using conditions as similar to the exam as possible. Ideally use the same platform that you use in the course. But you can find similar platforms to the one you are describing online, such as HackerRank and LeetCode, which also have banks of questions on different topics at different levels of difficulty you can use for practice.
Usually, these kinds of platforms have an ability to test your code on user-specified input or pre-made examples. Always test your code as you write it, especially in these kinds of exams. Test your code every time you add a new logical feature. The test can be as simple as feeding in a simple set of input and adding print strings to check you are getting the output you expect at every step -- just something you can do quickly to check yourself as you work. When you have a complete solution to a question, make sure your code runs on simple tests and gives correct results. When it does, then try thinking of edge cases, and if you're being graded on efficiency, try making a huge example test set. You should be able to generate test data quickly (if not, practice it). You also should practice thinking of good test cases -- simple ones that test correctness on "sane and small" input, and more complicated ones that can find edge cases and are large.
Learn techniques to calm yourself down in the exam room. Make sure you eat and sleep well before the exam. Don't cram -- study and practice in advance, and use the time before the exam to calm your mind. Take deep breaths. If you find yourself scrambling during the exam, take a moment to center yourself. Imagine yourself being in the comfortable place where you take your practice tests. Try to break your task into smaller, manageable sub-tasks that you can test, and build your way up to a solution, rather than trying to solve everything at once. Don't be smart. Be systematic.