You're writing Python code. You need to understand how Python code works.
TypeError is from this line:
expression = round("UID" / 2, 0) <> "UID" / 2
In Python, something surrounded by double quotes is a
str, more commonly referred to as just a "string." So
"UID" is a string, a sequence of text characters. Note that a string is a value; it is not a variable. Your code above attempts to divide the string by 2, but this can't work. Division doesn't make sense for a text value. This like asking, "What's the result of the text, 'jgsdjhdshj' divided by 2?" It doesn't make any sense as a question. That's why you get
TypeError: unsupported operand type;
int don't support being divided together. Note that this happens immediately when Python attempts to execute that line, before anything following is executed.
The confusion most likely comes from ESRI deciding to reuse a lot of Python syntax in their own custom tools like the field calculator. They made it look like Python even though it isn't really Python. (It probably gets pre-parsed by ESRI and then evaluated as Python after some transformation.)
The way the achieve what you do in the field calculator with actual Python code is to make that input a string:
expression = 'round("UID" / 2, 0) <> "UID" / 2'
(I've chosen single quotes to delimit the string here, but Python has several ways of delimiting strings.)
Your second error, the
ExecuteError, is something different. This error is from ArcGIS. It appears that the expression you provided is in some way malformed. It's difficult to be sure without knowing more about your set up, but the first thing I would ask is, "What kind of data source are you using?" If it's not an actual relational database (examples include Microsoft SQL Server, Oracle, and PostgreSQL), then using double quotes to refer to the field name is incorrect; in the cases of File GDBs (the directories ending in
.gdb) or shapefiles, try surrounding the field name in square brackets instead. (So
"UID" would become
All of these details are discussed in the documentation of the tool you're using.
Side note: The sort of design ESRI has chosen here (taking user input as a string, performing some transformation, and then evaluating it as code) is normally considered bad form in Python (and most programming languages) since it's very easy to accidentally create a security vulnerability. Don't follow their example in your own code.