Identity operator 03, logical operators

# ### operator status is | is not detected two data in memory is the same whether the address 
 
' '' 
is defined only variable is cached versions before 3.6, 
determined at a range of a value in memory, it will not and then create another one of the same value, in order to save memory space 
no longer scoping after 3.7, as long as you have a cache 
proposed small pool or variable data cache is to improve the efficiency of code execution and reduce the memory footprint 
'' ' 
# int -5 to positive infinity 
var1 =. 19 
var2 =. 19 
RES = var1 var2 IS 
Print (RES) 
 
# non-negative floating point 
var1 = -5.52 
var2 = -5.52 
RES = Not IS var1 var2 
Print (RES) 
 
# real + imaginary complex in such a configuration is never the same, but if only the imaginary number as in the same value or 
var1 =. 3 +. 4J 
var2 =. 3 +. 4J 
RES = var1 iS var2 
var1 = 6J 
var2 = 6J 
RES = var1 iS not var2 
Print (RES) 
 
# BOOL id the same as in the case of a Boolean value 
var1 = True 
var2 = True
IS = var1 var2 RES
# or  逻辑或
Print (RES) 
 
# container type address data is determined 
 
in terms of # str string, the string value in the same case, id consistent 
var1 = "you" 
var2 = "you" 
Print (IS var1 var2) 
 
 
var1 = (1,23) 
var2 = (1,23) 
Print (iS var1 var2) 
# empty tuple exception 
var1 = () 
var2 = () 
Print (iS var1 var2) 
 
# the rest of the container no matter what type of data values are not the same 
var1 = [1,2 ] 
var2 = [1,2] 
Print (IS Not var1 var2) 
 
 
# ### Not or logical operators and 
Print ( "<===>") 
# and logic 
'' 'Bob homework: Mathematics and English are finished written called '' ' 
' '' ***** the whole truth is really a false is false. "" "
= True and True RES 
RES = True and False 
RES = False and True 
RES = False and False 
Print (RES) 
 
"" "Mom reward Xiao Ming: there is a saying passed the test, I will buy you the Bugatti Veyron" ""
'' '***** the whole false false true true then a' '' 
RES = True True or 
RES = True or False 
RES = True or False 
RES = False False or 
Print (RES) 
 
# Not logical NOT (equivalent to inverted) 
RES = Not True 
RES = False Not 
Print (RES) 
 
# logic shorting 
"" " 
next or and or a case where 
(. 1) True or something 
(2) and something False 
" "" 
 
Print ( "<=== > ") 
False or Print (123) 
True and Print (456) 
 
# logic priority 
# ()> Not> and> or 
RES =. 5 or. 6 and. 7 
RES = (. 5 or. 6) and. 7 #. 5 and. 7 
RES = Not (or. 5. 6) and #. 7. 7 = Not. 5 and> = False. 7 and> False 
Print (RES). 5 or #. 7
 
RES =. 1 <2 and. 3>. 4 or. 5 <. 6 # True and False or True => False or True 
RES =. 1 <2 and. 3>. 4 or. 5>. 6 and. 7 <. 8 or. 9> 10 # True and False or = false and True or false> or false false false = or> = false or false> false        
Print (RES) 
 
# special case, up direct short circuit, the latter no longer in accordance with the priority and or calculations (exception) 
RES = and or. 6. 7 or. 5. 8. 9 and 10 or 
# up directly if false, the result is not necessarily true, to sequentially calculate backwards 
# True or false and True 
 
 
# data type determining the isinstance 
"" " 
int a float BOOL Complex STR List tuple dict sET 
 
the isinstance (to determine the type of data, (type 1, type 2, type 3, ......)) 
if the tuple type which returns true 
if the tuple type is not among the false 
"" " 
IntVar = 15 
Print (the isinstance (IntVar, int)) 
strvar = "789" 
Print (the isinstance (strvar,(int,str,list)))

  

Guess you like

Origin www.cnblogs.com/eliwen/p/10968240.html