The advent of 5G technology has ushered in a new era of communication where the customization of network services is crucial to meet diverse user demands. Network slicing has emerged as a pivotal technology to achieve this customization. In this research, we present an innovative approach to optimize network slicing in 5G by employing K-Prototype Clustering for slice creation and Context-Aware Slice Selection for efficient resource allocation. In slice creation, we delve into the innovative application of the K-Prototype clustering algorithm. Recognizing that 5G networks encompass numerical and categorical attributes, the K-Prototype algorithm enables the creation of network slices that cater to diverse service requirements. By harnessing this clustering technique, our proposed method optimizes the creation of network slices, resulting in improved resource utilization and reduced network congestion. Furthermore, we introduce the concept of Context-Aware Slice Selection, which considers the dynamic and evolving nature of network demands. Context-awareness ensures that network slices are selected based on real-time contextual information, enabling a more adaptive and responsive network. This approach leads to the efficient allocation of resources and a higher quality of service for end-users. To evaluate the performance of our proposed methodology, we employ key performance metrics, including slice selection accuracy, slice selection delay, and radio link failure. Through comprehensive testing and analysis, our research demonstrates that our approach consistently outperforms existing methods in terms of these metrics.