For Python 2, it makes no difference. There, print is a statement and 'hello' and ('hello') are its argument. The latter gets simplified to just 'hello' and as such it’s identical.
In Python 3, the print statement was removed in favor of a print function. Functions are invoked using braces, so they are actually needed. In that case, the print 'hello' is a syntax error, while print('hello') invokes the function with 'hello' as its first argument.
You can backport the print function to Python 2, by importing it explicitly. To do that add the following as the first import of your module:
from __future__ import print_function
Then you will get the same behaviour from Python 3 in Python 2, and again the parentheses are required.
if. This means the code was typed anew without much attention into SO and the structure of the original code might be something completely different. The indent of theifis also invalid - an indent must follow a statement that opens a block. So, no, the code samples aren't even close to valid.