β° Menu
Home
Python
HTML
Guide-css
JarvaScript
User Account
Admin
Python
π
Welcome to python.
Keywords
False β Boolean false value
None β Represents βno valueβ / null
True β Boolean true value
and β Logical AND
as β Creates an alias (mainly for imports & exceptions)
assert β Debug check; raises error if condition is false
async β Marks asynchronous function block
await β Waits for an async operation
break β Exits the nearest loop
class β Defines a class
continue β Skips to next loop iteration
def β Defines a function
del β Deletes a reference, variable, attribute, or list element
elif β βElse ifβ condition
else β Default branch in conditionals or loops
except β Catches exceptions
finally β Always runs after try/except (cleanup)
for β Loop over an iterable
from β Imports specific items from a module
global β Declares that a variable in a function refers to a global variable
if β Conditional branching
import β Imports a module
in β Membership test; also used in loops
is β Identity comparison (same object in memory)
lambda β Defines anonymous functions
nonlocal β Accesses outer-scope variable (not global)
not β Logical NOT
or β Logical OR
pass β Placeholder statement that does nothing
raise β Raises an exception
return β Returns a value from a function
try β Begins exception-handling block
while β Loop that runs while condition is true
with β Context manager block (safe resource handling)
yield β Returns a generator value from a generator function
Functions
abs() β Absolute value
aiter() β Returns async iterator
all() β True if all elements are truthy
anext() β Returns next value of async iterator
any() β True if any element is truthy
ascii() β ASCII-safe representation
bin() β Convert integer to binary string
bool() β Convert to boolean
breakpoint() β Enter debugger
bytearray() β Mutable byte sequence
bytes() β Immutable byte sequence
callable() β Checks if object is callable
chr() β Unicode char from code point
classmethod() β Class-level method wrapper
compile() β Compiles source to code object
complex() β Creates complex number
delattr() β Deletes attribute from object
dict() β Creates dictionary
dir() β Lists attributes of an object
divmod() β Returns quotient and remainder
enumerate() β Index-value iterator
eval() β Evaluates Python expression
exec() β Executes Python code
filter() β Filters iterable by function
float() β Converts to floating-point number
format() β Formats value
frozenset() β Immutable set
getattr() β Gets attribute of object
globals() β Returns global namespace
hasattr() β Returns True if object has attribute
hash() β Hash value
help() β Shows help text
hex() β Converts integer to hex string
id() β Memory identity
input() β User input
int() β Integer conversion
isinstance() β Instance check
issubclass() β Subclass check
iter() β Returns iterator
len() β Length of object
list() β Creates list
locals() β Local namespace
map() β Applies function to iterable
max() β Maximum value
memoryview() β Memory view object
min() β Minimum value
next() β Gets next iterator value
object() β Base object class
oct() β Octal string
open() β Opens file
ord() β Unicode code point from character
pow() β Exponentiation
print() β Prints to console
property() β Property accessor
range() β Integer sequence object
repr() β Official string representation
reversed() β Reverse iterator
round() β Round number
set() β Creates set
setattr() β Sets attribute
slice() β Slice object
sorted() β Returns sorted list
staticmethod() β Static method wrapper
str() β Converts to string
sum() β Sums iterables
super() β Access parent class
tuple() β Creates tuple
type() β Type of object
vars() β Object namespace
zip() β Pairs elements
Operators
Arithmetic
+ β Addition
- β Subtraction
* β Multiplication
/ β Division
// β Floor division
% β Modulo
** β Exponentiation
Comparison
== β Equal
!= β Not equal
> β Greater than
< β Less than
>= β Greater or equal
<= β Less or equal
Assignment
= β Assignment
+= β Add and assign
-= β Subtract and assign
*= β Multiply and assign
/= β Divide and assign
//= β Floor-divide and assign
%= β Modulo-assign
**= β Power-assign
Logical
and β Logical AND
or β Logical OR
not β Logical NOT
identify
is β Same object
is not β Not same object
Membership
in β In sequence
not in β Not in sequence
Bitwise
& β Bitwise AND
| β Bitwise OR
^ β Bitwise XOR
~ β Bitwise NOT
<< β Shift left
> β Shift right
Important Python Syntax and Instructions
List comprehension β [expr for item in iterable]
Dict comprehension β {key: value for item in iterable}
Set comprehension β {item for item in iterable}
Generator expression β (expr for item in iterable)
Context managers β with open(...) as f:
Decorators β @decorator modifies functions/classes
F-strings β f"Hello {name}" formatted expressions
Type hints β x: int = 10
Walrus operator β (x := value) assignment inside expression
Slice syntax β a[start:stop:step]
Function definition β def name(params):
Class definition β class Name:
Import module β import module
Import specific names β from module import name
Try/Except β error handling blocks
Async function β async def func():
Await expression β await something
Return β send value back from function
Yield β produce generator value
Lambda β inline function: lambda x: x+1
Docstrings β """Function documentation"""
Shebang β #!/usr/bin/env python3
Annotations β type information in functions and variables
β Back to HOME