📄 Abstract
Reversing an integer is one of the most common introductory programming problems used to understand loops, arithmetic operations, string manipulation, and algorithm design. In Python, an integer can be reversed either by using arithmetic operations or by converting the number into a string and reversing its characters. Although both methods produce the same output, they differ in terms of implementation, memory usage, and readability. This research presents a comparative study of these two integer reversal techniques. The first approach uses a user-defined reverse_num() function that performs digit-by-digit reversal through modulus and integer division operations. The second approach uses Python's built-in type conversion and string slicing features to achieve the same result with fewer lines of code. Both methods are evaluated based on correctness, execution time, auxiliary space complexity, code readability, and practical usability. The study includes theoretical analysis together with experimental observations obtained using different input sizes. The results show that both approaches have a linear time complexity of O(d), where d represents the number of digits in the input integer. However, the arithmetic method requires only constant auxiliary space O(1), while the type conversion method requires O(d) auxiliary space because it creates an additional string during execution. The findings indicate that the arithmetic approach is more suitable when memory efficiency is important, whereas the type conversion approach is preferred when code simplicity and readability are the primary objectives. This study provides a practical comparison that helps students and beginner programmers understand the advantages and limitations of both techniques before selecting an appropriate implementation.
🏷️ Keywords
📚 How to Cite:
Pranav R , E Tanish , A COMPARATIVE CASE STUDY OF INTEGER REVERSAL TECHNIQUES IN PYTHON: ARITHMETIC OPTIMIZATION VS TYPE CONVERSION , Volume 12 , Issue 7, July 2026, EPRA International Journal of Multidisciplinary Research (IJMR) , Pages: 693 - 701 ,