Python Logical And Statement Sql Interview Query Question