I read Qiita's article about pythongolf, and I was unable to understand it. In the code below, why is b assigned when a
Applicable source code
What you could see and understand
c = a<b and a or b
And and or can be used for other than Boolean values. And and or can be used even if not in an if statement.
-If the left of or is "true", return the left value.-If the left of or is "false", return the right value.
・ If the left side of "and" is "true", the right value is returned. ・ If the left side of "and" is "false", the left value is returned.
- Compare a and b (False)
- If the left of "and" is "false", the left value is returned, so False is assigned
Answer # 1
2.If the left of and is "false", the left value is returned, so False is assigned
It's a little different.
c = a For
c = (((a
(a Furthermore, if bool (a) is True, c = a, and if False, c = b.If
(a Furthermore, False or b becomes b and c = b.
Be careful when bool (a) is false.
>>>True and 1 or 2 1 >>>True and 0 or 2 2 >>>False and 1 or 2 2 >>>False and 0 or 2 2
- i have a question about basic python problems
- python - about downloading youtube videos by youtube-dl
- python - about hamiltonian neural networks
- python - about write loop to csv
- about python argument and data definition
- about the behavior of the centos routing table
- python 3x - about downloading anaconda
- python - about the optimum angle of rotation matrix
- about processing to exclude the character string group specified from list in python
- python - about "" "of" "" select === = "" "
- python - what i don't understand about yolo9000 (v2)
- about batch change of file name using python
- about the python speedtest code
- about the implementation of combinations in python
- c # - about the behavior of variable height control in template of listview of xamarinforms (ios)
- please tell me about the role of python tag = "mychr"
- about python def issues
- python, about the fire spread step of forest fire simulation
- python - about x-axis adjustment in matplotlib
- pythonista - [python] questions about line splitting in dataframe