Lorem

Delete this widget in your dashboard. This is just an example.

Ipsum

Delete this widget in your dashboard. This is just an example.

Dolor

Delete this widget in your dashboard. This is just an example.
 

Python Keywords

 

Python Keywords



Python has a set of keywords that are reserved words that cannot be used as variable names, function names, or any other identifiers:

KeywordDescription
andA logical operator
asTo create an alias
assertFor debugging
breakTo break out of a loop
classTo define a class
continueTo continue to the next iteration of a loop
defTo define a function
delTo delete an object
elifUsed in conditional statements, same as else if
elseUsed in conditional statements
exceptUsed with exceptions, what to do when an exception occurs
FalseBoolean value, result of comparison operations
finallyUsed with exceptions, a block of code that will be executed no matter if there is an exception or not
forTo create a for loop
fromTo import specific parts of a module
globalTo declare a global variable
ifTo make a conditional statement
importTo import a module
inTo check if a value is present in a list, tuple, etc.
isTo test if two variables are equal
lambdaTo create an anonymous function
NoneRepresents a null value
nonlocalTo declare a non-local variable
notA logical operator
orA logical operator
passA null statement, a statement that will do nothing
raiseTo raise an exception
returnTo exit a function and return a value
TrueBoolean value, result of comparison operations
tryTo make a try...except statement
whileTo create a while loop
withUsed to simplify exception handling
yieldTo end a function, returns a generator





Built-in Exceptions

The table below shows built-in exceptions that are usually raised in Python:

ExceptionDescription
ArithmeticErrorRaised when an error occurs in numeric calculations
AssertionErrorRaised when an assert statement fails
AttributeErrorRaised when attribute reference or assignment fails
ExceptionBase class for all exceptions
EOFErrorRaised when the input() method hits an "end of file" condition (EOF)
FloatingPointErrorRaised when a floating point calculation fails
GeneratorExitRaised when a generator is closed (with the close() method)
ImportErrorRaised when an imported module does not exist
IndentationErrorRaised when indendation is not correct
IndexErrorRaised when an index of a sequence does not exist
KeyErrorRaised when a key does not exist in a dictionary
KeyboardInterruptRaised when the user presses Ctrl+c, Ctrl+z or Delete
LookupErrorRaised when errors raised cant be found
MemoryErrorRaised when a program runs out of memory
NameErrorRaised when a variable does not exist
NotImplementedErrorRaised when an abstract method requires an inherited class to override the method
OSErrorRaised when a system related operation causes an error
OverflowErrorRaised when the result of a numeric calculation is too large
ReferenceErrorRaised when a weak reference object does not exist
RuntimeErrorRaised when an error occurs that do not belong to any specific expections
StopIterationRaised when the next() method of an iterator has no further values
SyntaxErrorRaised when a syntax error occurs
TabErrorRaised when indentation consists of tabs or spaces
SystemErrorRaised when a system error occurs
SystemExitRaised when the sys.exit() function is called
TypeErrorRaised when two different types are combined
UnboundLocalErrorRaised when a local variable is referenced before assignment
UnicodeErrorRaised when a unicode problem occurs
UnicodeEncodeErrorRaised when a unicode encoding problem occurs
UnicodeDecodeErrorRaised when a unicode decoding problem occurs
UnicodeTranslateErrorRaised when a unicode translation problem occurs
ValueErrorRaised when there is a wrong value in a specified data type
ZeroDivisionErrorRaised when the second operator in a division is zero



This is a list of all the features explained in the Python Tutorial.


FeatureDescription
IndentationIndentation refers to the spaces at the beginning of a code line
CommentsComments are code lines that will not be executed
Multi Line CommentsHow to insert comments on multiple lines
Creating VariablesVariables are containers for storing data values
Variable NamesHow to name your variables
Assign Values to Multiple VariablesHow to assign values to multiple variables
Output VariablesUse the print statement to output variables
String ConcatenationHow to combine strings
Global VariablesGlobal variables are variables that belongs to the global scope
Built-In Data TypesPython has a set of built-in data types
Getting Data TypeHow to get the data type of an object
Setting Data TypeHow to set the data type of an object
NumbersThere are three numeric types in Python
IntThe integer number type
FloatThe floating number type
ComplexThe complex number type
Type ConversionHow to convert from one number type to another
Random NumberHow to create a random number
Specify a Variable TypeHow to specify a certain data type for a variable
String LiteralsHow to create string literals
Assigning a String to a VariableHow to assign a string value to a variable
Multiline StringsHow to create a multi line string
Strings are ArraysStrings in Python are arrays of bytes representing Unicode characters
Slicing a StringHow to slice a string
Negative Indexing on a StringHow to use negative indexing when accessing a string
String LengthHow to get the length of a string
Check In StringHow to check if a string contains a specified phrase
Format StringHow to combine two strings
Escape CharactersHow to use escape characters
Boolean ValuesTrue or False
Evaluate BooleansEvaluate a value or statement and return either True or False
Return Boolean ValueFunctions that return a Boolean value
OperatorsUse operator to perform operations in Python
Arithmetic OperatorsArithmetic operator are used to perform common mathematical operations
Assignment OperatorsAssignment operators are use to assign values to variables
Comparison OperatorsComparison operators are used to compare two values
Logical OperatorsLogical operators are used to combine conditional statements
Identity OperatorsIdentity operators are used to see if two objects are in fact the same object
Membership OperatorsMembership operators are used to test is a sequence is present in an object
Bitwise OperatorsBitwise operators are used to compare (binary) numbers
ListsA list is an ordered, and changeable, collection
Access List ItemsHow to access items in a list
Change List ItemHow to change the value of a list item
Loop Through List ItemsHow to loop through the items in a list
Check if List Item ExistsHow to check if a specified item is present in a list
List LengthHow to determine the length of a list
Add List ItemsHow to add items to a list
Remove List ItemsHow to remove list items
Copy a ListHow to copy a list
Join Two ListsHow to join two lists
TupleA tuple is an ordered, and unchangeable, collection
Access Tuple ItemsHow to access items in a tuple
Change Tuple ItemHow to change the value of a tuple item
Loop List ItemsHow to loop through the items in a tuple
Check if Tuple Item ExistsHow to check if a specified item is present in a tuple
Tuple LengthHow to determine the length of a tuple
Tuple With One ItemHow to create a tuple with only one item
Remove Tuple ItemsHow to remove tuple items
Join Two TuplesHow to join two tuples
SetA set is an unordered, and unchangeable, collection
Access Set ItemsHow to access items in a set
Add Set ItemsHow to add items to a set
Loop Set ItemsDETTE KAPITTELET MANGLER
Check if Set Item ExistsDETTE KAPITTELET MANGLER
Set LengthHow to determine the length of a set
Remove Set ItemsHow to remove set items
Join Two SetsHow to join two sets
DictionaryA dictionary is an unordered, and changeable, collection
Access Dictionary ItemsHow to access items in a dictionary
Change Dictionary ItemHow to change the value of a dictionary item
Loop Dictionary ItemsHow to loop through the items in a tuple
Check if Dictionary Item ExistsHow to check if a specified item is present in a dictionary
Dictionary LengthHow to determine the length of a dictionary
Add Dictionary ItemHow to add an item to a dictionary
Remove Dictionary ItemsHow to remove dictionary items
Copy DictionaryHow to copy a dictionary
Nested DictionariesA dictionary within a dictionary
If StatementHow to write an if statement
If IndentationIf statemnts in Python relies on indentation (whitespace at the beginning of a line)
Elifelif is the same as "else if" in other programming languages
ElseHow to write an if...else statement
Shorthand IfHow to write an if statement in one line
Shorthand If ElseHow to write an if...else statement in one line
If ANDUse the and keyword to combine if statements
If ORUse the or keyword to combine if statements
Nested IfHow to write an if statement inside an if statement
The pass Keyword in IfUse the pass keyword inside empty if statements
WhileHow to write a while loop
While BreakHow to break a while loop
While ContinueHow to stop the current iteration and continue wit the next
While ElseHow to use an else statement in a while loop
ForHow to write a for loop
Loop Through a StringHow to loop through a string
For BreakHow to break a for loop
For ContinueHow to stop the current iteration and continue wit the next
Looping Through a rangeeHow to loop through a range of values
For ElseHow to use an else statement in a for loop
Nested LoopsHow to write a loop inside a loop
For passUse the pass keyword inside empty for loops
FunctionHow to create a function in Python
Call a FunctionHow to call a function in Python
Function ArgumentsHow to use arguments in a function
*argsTo deal with an unknown number of arguments in a function, use the * symbol before the parameter name
Keyword ArgumentsHow to use keyword arguments in a function
*kwargsTo deal with an unknown number of keyword arguments in a function, use the * symbol before the parameter name
Default Parameter ValueHow to use a default parameter value
Passing a List as an ArgumentHow to pass a list as an argument
Function Return ValueHow to return a value from a function
The pass Statement i FunctionsUse the pass statement in empty functions
Function RecursionFunctions that can call itself is called recursive functions
Lambda FunctionHow to create anonymous functions in Python
Why Use Lambda FunctionsLearn when to use a lambda function or not
ArrayLists can be used as Arrays
What is an ArrayArrays are variables that can hold more than one value
Access ArraysHow to access array items
Array LengthHow to get the length of an array
Looping Array ElementsHow to loop through array elements
Add Array ElementHow to add elements from an array
Remove Array ElementHow to remove elements from an array
Array MethodsPython has a set of Array/Lists methods
ClassA class is like an object constructor
Create ClassHow to create a class
The Class __init__() FunctionThe __init__() function is executed when the class is initiated
Object MethodsMethods in objects are functions that belongs to the object
selfThe self parameter refers to the current instance of the class
Modify Object PropertiesHow to modify properties of an object
Delete Object PropertiesHow to modify properties of an object
Delete ObjectHow to delete an object
Class pass StatementUse the pass statement in empty classes
Create Parent ClassHow to create a parent class
Create Child ClassHow to create a child class
Create the __init__() FunctionHow to create the __init__() function
super FunctionThe super() function make the child class inherit the parent class
Add Class PropertiesHow to add a property to a class
Add Class MethodsHow to add a method to a class
IteratorsAn iterator is an object that contains a countable number of values
Iterator vs IterableWhat is the difference between an iterator and an iterable
Loop Through an IteratorHow to loop through the elements of an iterator
Create an IteratorHow to create an iterator
StopIterationHow to stop an iterator
Global ScopeWhen does a variable belong to the global scope?
Global KeywordThe global keyword makes the variable global
Create a ModuleHow to create a module
Variables in ModulesHow to use variables in a module
Renaming a ModuleHow to rename a module
Built-in ModulesHow to import built-in modules
Using the dir() FunctionList all variable names and function names in a module
Import From ModuleHow to import only parts from a module
Datetime ModuleHow to work with dates in Python
Date OutputHow to output a date
Create a Date ObjectHow to create a date object
The strftime MethodHow to format a date object into a readable string
Date Format CodesThe datetime module has a set of legal format codes
JSONHow to work with JSON in Python
Parse JSONHow to parse JSON code in Python
Convert into JSONHow to convert a Python object in to JSON
Format JSONHow to format JSON output with indentations and line breaks
Sort JSONHow to sort JSON
RegEx ModuleHow to import the regex module
RegEx FunctionsThe re module has a set of functions
Metacharacters in RegExMetacharacters are characters with a special meaning
RegEx Special SequencesA backslash followed by a a character has a special meaning
RegEx SetsA set is a set of characters inside a pair of square brackets with a special meaning
RegEx Match ObjectThe Match Object is an object containing information about the search and the result
Install PIPHow to install PIP
PIP PackagesHow to download and install a package with PIP
PIP Remove PackageHow to remove a package with PIP
Error HandlingHow to handle errors in Python
Handle Many ExceptionsHow to handle more than one exception
Try ElseHow to use the else keyword in a try statement
Try FinallyHow to use the finally keyword in a try statement
raiseHow to raise an exception in Python

0 comments:

Post a Comment

Expressions in python

  Expressions Python Expressions: Expressions are representations of value. They are different from statement in the fact that statements do...

Lorem

Please note: Delete this widget in your dashboard. This is just a widget example.

Ipsum

Please note: Delete this widget in your dashboard. This is just a widget example.

Dolor

Please note: Delete this widget in your dashboard. This is just a widget example.