python Python :: Notes&Tricks

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python Python :: Notes&Tricks相关的知识,希望对你有一定的参考价值。


## NUMERIC OPERATORS

"""
	Operation         |   Result                             
	----------------- + -------------------------------------
	x + y             |   sum of x and y                     
	----------------- + -------------------------------------
	x - y             |   difference of x and y              
	----------------- + -------------------------------------
	x * y             |   product of x and y                 
	----------------- + -------------------------------------
	x / y             |   quotient of x and y                
	----------------- + -------------------------------------
	x // y            |   floored quotient of x and y        
	----------------- + -------------------------------------
	x % y             |   remainder of x / y                 
	----------------- + -------------------------------------
	-x                |   x negated                          
	----------------- + -------------------------------------
	+x                |   x unchanged                        
	----------------- + -------------------------------------
	abs(x)            |   absolute value or magnitude of x   
	----------------- + -------------------------------------
	int(x)            |   x converted to integer             
	----------------- + -------------------------------------
	float(x)          |   x converted to floating point      
	----------------- + -------------------------------------
	complex(re, im)   |   a complex number with real part    
	                  |     re, imaginary part im.           
	                  |     im defaults to zero.             
	----------------- + -------------------------------------
	c.conjugate()     |   conjugate of the complex number c  
	----------------- + -------------------------------------
	divmod(x, y)      |   the pair (x // y, x % y)           
	----------------- + -------------------------------------
	pow(x, y)         |   x to the power y                   
	----------------- + -------------------------------------
	x ** y            |   x to the power y                   
	----------------- + -------------------------------------
"""


""" Odd & Even numbers """

def int_is_odd(n):
  """ int_is_odd(int n) """
  return n % 2 != 0

def int_is_even(n):
  """ int_is_even(int n) """
  return n % 2 == 0

以上是关于python Python :: Notes&Tricks的主要内容,如果未能解决你的问题,请参考以下文章

Meet Python: little notes

[Python Study Notes]cpu信息

Python_notes_02

[Python Study Notes]内存信息

Python_notes_01

[Python Study Notes]计算器