Interview question sharing

Common Interview Questions

  1. operator
     print(1 > 2 and 3 or 4)

    The idea is operator rules: () > not > and > or , the same priority is calculated from left to right; there is also a formula for 0 to get 0 and 1 to get 1 . Therefore, for this question, calculate and first, and 1>2 is False, so according to the formula, you don't need to care about and, the result is False, and if you continue to look at False or 4, you can also get the result of 4 according to the formula.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324978595&siteId=291194637