Skip to content

Latest commit

 

History

History
64 lines (57 loc) · 2.23 KB

python.md

File metadata and controls

64 lines (57 loc) · 2.23 KB

Python notes & commands

Key Words

KEYWORDS KEYWORDS KEYWORDS KEYWORDS KEYWORDS
and del from not while
as elif global or with
assert else if pass yield
break except import print
class exec in raise
continue finally is return
def for lambda try

Comparisons

SYMBOL MEANING
'<' strictly less than
'<=' less than or equal
'>' strictly greater than
'>=' greater than or equal
'==' equal
'!=' not equal
'is' object identity
'is not' negated object identity

Operations

SYMBOL MEANING
'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
'long(x)' x converted to long 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. (Identity on real numbers)
'divmod(x, y)' the pair (x // y, x % y)
'pow(x, y)' x to the power y
'x ** y' x to the power y

if statements

for statements

break/continue statements

functions

lambda expressions

data structures

lists

stacks

dictionaries

tuples

sets

loops

modules

classes

input/output