It depends on the assignment. If it says do not use the libraries there is a learning outcome for it. For example, by not using kNN algorithm implemented in scikit-learn and implementing it, you will understand how the algorithm works and you think about mechanics behind the scene.
But generally, you are allowed to use any library that makes your job easier to solve the problem. However it is true for the assignments or prototypes, in the production environment efficiency of code also matters. So, the minimum complexity, a clean code, and minimum number of libraries are desired to reduce the overhead and save the memory and space, and in addition make our project maintainable.