Boolean23. A four-digit number is given. Check the truth of the statement: "This number is read equally from left to right and from right to left".

Решение на Python 3:

import random

N = random.randrange(1000,10000)
N = 2222
print("Число: ", N)
p1 = int(N/100)
p2 = N-p1*100
p2_d1 = int(p2/10)
p2_d0 = p2 - p2_d1*10
print("First half: ", p1)
print("Second half: ", p2)
print("Tens: ", p2_d1)
print("Units: ", p2_d0)
x = (p1 == (p2_d0*10 + p2_d1))
print("The number is the same \n from left to right and from right to left: ", x)