tools:python
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tools:python [2024/06/03 05:53] – Humphrey Boa-Gart | tools:python [2025/10/12 10:56] (current) – Humphrey Boa-Gart | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | {{wst> | + | #redirect tools:languages:python |
| - | + | ||
| - | ====== Python ====== | + | |
| - | + | ||
| - | Below applies to Python 2.6 or lower, Python 3 is a good bit different. | + | |
| - | + | ||
| - | Python is an object oriented, interpreted language. It is unique in that it requires a user to indent in place of using curly brackets ({..}). | + | |
| - | + | ||
| - | Note: that most *nix distributions come with Python by default. | + | |
| - | + | ||
| - | ===== Basics ===== | + | |
| - | + | ||
| - | //Basic// python syntax | + | |
| - | + | ||
| - | ==== Hello World! ==== | + | |
| - | + | ||
| - | >>> | + | |
| - | HELLO WORLD! | + | |
| - | + | ||
| - | ==== Variables ==== | + | |
| - | + | ||
| - | Variable names DO NOT need to begin with a special character, unlike PHP. Variable names CAN, however, be any combination, | + | |
| - | + | ||
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | [' | + | |
| - | >>> | + | |
| - | ' | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | 3.528 | + | |
| - | >>> | + | |
| - | 3 | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | <type ' | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | <type ' | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | + | ||
| - | ===== Statements ===== | + | |
| - | + | ||
| - | ==== Comparison ==== | + | |
| - | + | ||
| - | < Less than | + | |
| - | > | + | |
| - | == Equal to | + | |
| - | != Not equal | + | |
| - | is Identical | + | |
| - | is not Not identical | + | |
| - | <= Less than or equal to | + | |
| - | >= Greater than or equal to | + | |
| - | + | ||
| - | === If === | + | |
| - | + | ||
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | print " | + | |
| - | + | ||
| - | + | ||
| - | No! | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | print " | + | |
| - | + | ||
| - | + | ||
| - | Yes! | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | print " | + | |
| - | + | ||
| - | + | ||
| - | Yes! | + | |
| - | + | ||
| - | ==== Loops ==== | + | |
| - | + | ||
| - | === While === | + | |
| - | + | ||
| - | >>> | + | |
| - | >>> | + | |
| - | print a | + | |
| - | a += 1; | + | |
| - | + | ||
| - | 1 | + | |
| - | 2 | + | |
| - | 3 | + | |
| - | 4 | + | |
| - | >>> | + | |
| - | >>> | + | |
| - | print " | + | |
| - | a = True; | + | |
| - | + | ||
| - | + | ||
| - | False | + | |
| - | + | ||
| - | === For === | + | |
| - | + | ||
| - | >>> | + | |
| - | print x | + | |
| - | + | ||
| - | + | ||
| - | 0 | + | |
| - | 1 | + | |
| - | 2 | + | |
| - | 3 | + | |
| - | 4 | + | |
| - | 5 | + | |
| - | 6 | + | |
| - | 7 | + | |
| - | 8 | + | |
| - | 9 | + | |
| - | + | ||
| - | //consider using xrange when dealing with larger lists, as it creates an iterator, rather than constructing the full list in memory// | + | |
| - | + | ||
| - | >>> | + | |
| - | print x | + | |
| - | + | ||
| - | + | ||
| - | Hello | + | |
| - | world | + | |
| - | ,this | + | |
| - | is | + | |
| - | a | + | |
| - | list | + | |
| - | + | ||
| - | {{tag> | + | |
tools/python.1717394033.txt.gz · Last modified: (external edit)
Find this page online at: https://bestpoint.institute/tools/python
Find this page online at: https://bestpoint.institute/tools/python