Difference between revisions of "Python Keywords, Concepts, Functions"
(→Python Keywords) |
(→Python Keywords) |
||
Line 3: | Line 3: | ||
Following are terse descriptions for Python3 keywords and commonly used functions. For more information, see [https://www.w3schools.com/python/python_ref_keywords.asp w3schools] for a bit more explanation and [https://docs.python.org/3/reference/ python.org] for the language reference. | Following are terse descriptions for Python3 keywords and commonly used functions. For more information, see [https://www.w3schools.com/python/python_ref_keywords.asp w3schools] for a bit more explanation and [https://docs.python.org/3/reference/ python.org] for the language reference. | ||
− | = | + | =Keywords= |
+ | The following are heavily used in all levels of Python programming. This is a minimum set of keywords to know how to use. | ||
* <code>break</code> - exit the current loop | * <code>break</code> - exit the current loop | ||
+ | * <code>continue</code> - in a loop, go to next iteration of the loop | ||
* <code>print</code> - function to write to the screen | * <code>print</code> - function to write to the screen | ||
− | * <code></code> - | + | * <code>is</code> - determine whether two objects are the same object(not just value) |
− | + | * <code>import, from</code> - to load a module | |
− | + | * <code>def</code> - declare a function | |
− | + | * <code>while</code> - loop with only condition | |
− | * <code></code> - | + | * <code>if, elif, else</code> - conditional statements (three keywords) |
− | * <code></code> - | + | * <code>for</code> - loop with that iterates through a list |
− | * <code></code> - | + | * <code>return</code> - keyword to send a value back from a function |
− | * <code></code> - | + | * <code>and</code> - boolean operator, True only if both sides are True |
− | * <code></code> - | + | * <code>or</code> - boolean operator, True if either side is True |
− | + | * <code>not</code> - boolean operator, negates | |
− | * <code></code> - | + | * <code>True, False</code> - boolean values (two keywords) |
− | * <code></code> - | + | * <code>del</code> - remove from a list by position |
− | * <code></code> - | + | * <code>try, except</code> - handle an exception, basic use (2 keywords) |
− | * <code></code> - | + | * <code>raise, assert</code> - raise/indicate an exception (2 keywords) |
− | * <code></code> - | + | * <code>in</code> - test if something is inside of a list/string/tuple/dictionary |
− | * <code></code> - | + | * <code>None</code> - special value for a variable that has no value |
− | * <code></code> - | + | * <code>pass</code> - empty statement that does not do anything |
− | * <code></code> - | ||
− | * <code></code> - | ||
+ | ==More Keywords== | ||
+ | These keywords are often not introduced or heavily used until the second Python course. | ||
+ | * <code>as, finally, with, else</code> - exception handling, more keywords (4 keywords) | ||
+ | * <code>class</code> - defining new class data type (for object-oriented programming) | ||
+ | * <code>lambda</code> - create unnamed / anonymous function | ||
+ | * <code>global, nonlocal</code> - access variables outside of current scope (2 keywords) | ||
+ | * <code>async, await</code> - for writing asynchronous code with asynchio package (2 keywords) | ||
+ | * <code>yield</code> - for creating generator functions | ||
+ | |||
+ | =Concepts= | ||
+ | These are terms that we use to describe programs. These are terms that have a precise meaning when talking about programs. | ||
+ | * <code>string</code> - text data type | ||
* <code>boolean</code> - data type for True and False | * <code>boolean</code> - data type for True and False | ||
=Python Commonly Used Functions= | =Python Commonly Used Functions= |
Revision as of 21:20, 31 December 2019
See also Python Programming - Getting Started
Following are terse descriptions for Python3 keywords and commonly used functions. For more information, see w3schools for a bit more explanation and python.org for the language reference.
Keywords
The following are heavily used in all levels of Python programming. This is a minimum set of keywords to know how to use.
break
- exit the current loopcontinue
- in a loop, go to next iteration of the loopprint
- function to write to the screenis
- determine whether two objects are the same object(not just value)import, from
- to load a moduledef
- declare a functionwhile
- loop with only conditionif, elif, else
- conditional statements (three keywords)for
- loop with that iterates through a listreturn
- keyword to send a value back from a functionand
- boolean operator, True only if both sides are Trueor
- boolean operator, True if either side is Truenot
- boolean operator, negatesTrue, False
- boolean values (two keywords)del
- remove from a list by positiontry, except
- handle an exception, basic use (2 keywords)raise, assert
- raise/indicate an exception (2 keywords)in
- test if something is inside of a list/string/tuple/dictionaryNone
- special value for a variable that has no valuepass
- empty statement that does not do anything
More Keywords
These keywords are often not introduced or heavily used until the second Python course.
as, finally, with, else
- exception handling, more keywords (4 keywords)class
- defining new class data type (for object-oriented programming)lambda
- create unnamed / anonymous functionglobal, nonlocal
- access variables outside of current scope (2 keywords)async, await
- for writing asynchronous code with asynchio package (2 keywords)yield
- for creating generator functions
Concepts
These are terms that we use to describe programs. These are terms that have a precise meaning when talking about programs.
string
- text data typeboolean
- data type for True and False