make solutions run as programs, how create object of Solution, etc.?

Beginner question. How do I make the solutions run as a executable program in my terminal? How do I create an object of Solution, how do I call the method, what does the print statement have to look like?

For example, for problem 9 I found the following solution below. I would like in my terminal prompt after I run the program something like:

Input: 121
Output: TRUE

class Solution:
    def isPalindrome(self, x: int) -> bool:
        if x < 0: return False
        return self.reverse(x) == x
    
    def reverse(self, x):
        y = 0
        while x:
            d = x % 10
            y = y * 10 + d
            x //= 10
        return y
Comments (1)