Int python3 common method of class exercises

Int common method of exercise class

. 1  # Coding: UTF-. 8 
2  # conventional method int class 
. 3  
. 4 num1 = 18 is
 . 5 num2 = -15
 . 6  
. 7  # Query class num1 used 
. 8  Print (type (num1))
 . 9  
10  # minimum bit num1 occupied number 
. 11  Print (num1.bit_length ())
 12 is  
13 is  # num1 binary values in memory, built-in non-int 
14  Print (bin (num1))
 15  
16  # adder, corresponds to "+": 
. 17  Print (num1. __add__ ( 15 ))
 18  
19  #Absolute value, execution ABS (num2) for creating num2 object and then call __abs __ () Method 
20 is  Print (num2. __Abs__ ())
 21 is  Print (ABS (num2))
 22 is  
23 is  # operational corresponds num1 & num2 
24  Print (num1. __and__ (num2))
 25  
26 is  # returns the quotient and remainder tuple% higher than the region 
27  Print (divmod (95,10 ))
 28  
29  # comparison value, equivalent to == num2 num1 
30  Print ( . num1 __eq__ (num2))
 31 is  
32  # floor addition, down to the nearest integer, equivalent // 18 is - 15 
33 is  Print . (num1 __floordiv__(Num2))

Guess you like

Origin www.cnblogs.com/exception999/p/12078038.html