-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
179 lines (154 loc) · 25 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, intitial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>Python Documentation</title>
</head>
<body>
<header id="heading">
<h1>Python Documentation</h1>
<p><em>Content Culled from Official Wikipedia Page</em></p>
</header>
<nav id="navbar">
<header><h2>Python Documentation</h2></header>
<a class="nav-link" href="#introduction"><p>Introduction</p></a>
<a class="nav-link" href="#history"><p>History</p></a>
<a class="nav-link" href="#design_philosophy_and_features"><p>Design Philosophy and features</p></a>
<a class="nav-link" href="#syntax_and_semantics"><p>Syntax and Semantics</p></a>
<ul>
<li><a class="nav-link" href="#indentation"><p>Indentation</p></a></li>
<li><a class="nav-link" href="#statements_and_control_flow"><p>Statements and control flow</p></a></li>
<li><a class="nav-link" href="#expressions"><p>Expressions</p></a></li>
</ul>
<a class="nav-link" href="#arithmetic_operations"><p>Arithmetic operations</p></a>
<a class="nav-link" href="#development_environments"><p>Development Environments</p></a>
<a class="nav-link" href="#development"><p>Development</p></a>
</nav>
<main id="main-doc">
<section class="main-section" id="introduction">
<header><h2>Introduction</h2></header>
<p>Python is a high-level, interpreted, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation.</p>
<p>Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms, including structured (particularly procedural), object-oriented and functional programming. It is often described as a "batteries included" language due to its comprehensive standard library.</p>
<p><a class="inner_a" href="https://en.wikipedia.org/wiki/Guido_van_Rossum">Guido van Rossum</a> began working on Python in the late 1980s as a successor to the ABC programming language and first released it in 1991 as Python 0.9.0. Python 2.0 was released in 2000 and introduced new features such as list comprehensions, cycle-detecting garbage collection, reference counting, and Unicode support. Python 3.0, released in 2008, was a major revision that is not completely backward-compatible with earlier versions. Python 2 was discontinued with version 2.7.18 in 2020.</p>
Python consistently ranks as one of the most popular programming languages.</p>
</section>
<section class="main-section" id="history">
<header><h2>History</h2></header>
<p>Python was conceived in the late 1980s by Guido van Rossum at Centrum Wiskunde & Informatica (CWI) in the Netherlands as a successor to the ABC programming language, which was inspired by SETL, capable of exception handling and interfacing with the Amoeba operating system. Its implementation began in December 1989. Van Rossum shouldered sole responsibility for the project, as the lead developer, until 12 July 2018, when he announced his "permanent vacation" from his responsibilities as Python's "benevolent dictator for life", a title the Python community bestowed upon him to reflect his long-term commitment as the project's chief decision-maker. In January 2019, active Python core developers elected a five-member Steering Council to lead the project.</p>
<p>Python 2.0 was released on 16 October 2000, with many major new features. Python 3.0, released on 3 December 2008, with many of its major features backported to Python 2.6.x and 2.7.x. Releases of Python 3 include the <code>2to3</code> utility, which automates the translation of Python 2 code to Python 3.</p>
<p>Python 2.7's end-of-life was initially set for 2015, then postponed to 2020 out of concern that a large body of existing code could not easily be forward-ported to Python 3. No further security patches or other improvements will be released for it. With Python 2's end-of-life, only Python 3.6.x and later were supported. Later, support for 3.6 was also discontinued. In 2021, Python 3.9.2 and 3.8.8 were expedited as all versions of Python (including 2.7) had security issues leading to possible remote code execution and web cache poisoning.</p>
<p>In 2022, Python 3.10.4 and 3.9.12 were expedited and so were older releases including 3.8.13, and 3.7.13 because of many security issues. Python 3.9.13 is the latest 3.9 version, and from now on 3.9 (and older; 3.8 and 3.7) will only get security updates</p>
</section>
<section class="main-section" id="design_philosophy_and_features">
<header><h2>Design Philosophy and features</h2></header>
<p>Python is a multi-paradigm programming language. Object-oriented programming and structured programming are fully supported, and many of its features support functional programming and aspect-oriented programming (including metaprogramming and metaobjects [magic methods] ). Many other paradigms are supported via extensions, including design by contract and logic programming.</p>
<p>Python uses dynamic typing and a combination of reference counting and a cycle-detecting garbage collector for memory management. It uses dynamic name resolution (late binding), which binds method and variable names during program execution.</p>
<p>Its design offers some support for functional programming in the Lisp tradition. It has <code>filter</code>,<code>map</code> and <code>reduce</code> functions; list comprehensions, dictionaries, sets, and generator expressions. The standard library has two modules (<code>itertools</code> and <code>functools</code>) that implement functional tools borrowed from Haskell and Standard ML.</p>
<p>Its core philosophy is summarized in the document <a class="inner_a" href="https://en.wikipedia.org/wiki/Zen_of_Python">The Zen of Python</a> (PEP 20), which includes aphorisms such as:</p>
<ul>
<li>Beautiful is better than ugly.</li>
<li>Explicit is better than implicit.</li>
<li>Simple is better than complex.</li>
<li>Complex is better than complicated.</li>
<li>Readability counts.</li>
</ul>
<p>Rather than building all of its functionality into its core, Python was designed to be highly extensible via modules. This compact modularity has made it particularly popular as a means of adding programmable interfaces to existing applications. Van Rossum's vision of a small core language with a large standard library and easily extensible interpreter stemmed from his frustrations with ABC, which espoused the opposite approach.</p>
<p>Python strives for a simpler, less-cluttered syntax and grammar while giving developers a choice in their coding methodology. In contrast to Perl's "there is more than one way to do it" motto, Python embraces a "there should be one—and preferably only one—obvious way to do it" philosophy. Alex Martelli, a Fellow at the Python Software Foundation and Python book author, wrote: "To describe something as 'clever' is not considered a compliment in the Python culture."</p>
<p>Python's developers strive to avoid premature optimization and reject patches to non-critical parts of the CPython reference implementation that would offer marginal increases in speed at the cost of clarity. When speed is important, a Python programmer can move time-critical functions to extension modules written in languages such as C; or use PyPy, a just-in-time compiler. Cython is also available, which translates a Python script into C and makes direct C-level API calls into the Python interpreter.</p>
<p>Python's developers aim for it to be fun to use. This is reflected in its name—a tribute to the British comedy group Monty Python—and in occasionally playful approaches to tutorials and reference materials, such as examples that refer to spam and eggs (a reference to a Monty Python sketch) instead of the standard foo and bar.</p>
<p>The programming language's name 'Python' came from a BBC Comedy series in the 1970's named Monty Python's Flying Circus. Guido van Rossum thought he needed a name that was short, unique and slightly mysterious, And so, he decided to name the programming language 'Python'.</p>
<p>A common neologism in the Python community is pythonic, which has a wide range of meanings related to program style. "Pythonic" code may use Python idioms well, be natural or show fluency in the language, or conform with Python's minimalist philosophy and emphasis on readability. Code that is difficult to understand or reads like a rough transcription from another programming language is called unpythonic.</p>
<p>Python users and admirers, especially those considered knowledgeable or experienced, are often referred to as Pythonistas.</p>
</section>
<section class="main-section" id="syntax_and_semantics">
<header><h2>Syntax and Semantics</h2></header>
<p>Python is meant to be an easily readable language. Its formatting is visually uncluttered and often uses English keywords where other languages use punctuation. Unlike many other languages, it does not use curly brackets to delimit blocks, and semicolons after statements are allowed but rarely used. It has fewer syntactic exceptions and special cases than C or Pascal.</p>
</section>
<section class="main-section" id="indentation">
<header><h3>Indentation</h3></header>
<p>Python uses whitespace indentation, rather than curly brackets or keywords, to delimit blocks. An increase in indentation comes after certain statements; a decrease in indentation signifies the end of the current block.Thus, the program's visual structure accurately represents its semantic structure. This feature is sometimes termed the off-side rule. Some other languages use indentation this way; but in most, indentation has no semantic meaning. The recommended indent size is four spaces</p>
</section>
<section class="main-section" id="statements_and_control_flow">
<header><h3>Statements and control flow</h3></header>
<p>Python's statements include:</p>
<ul>
<li>The assignment statement, using a single equals sign <code>=</code></li>
<li>The <code>if</code> statement, which conditionally executes a block of code, along with <code>else</code> and <code>elif</code> (a contraction of <code>else-if</code>)</li>
<li>The <code>for</code> statement, which iterates over an iterable object, capturing each element to a local variable for use by the attached block</li>
<li>The <code>while</code> statement, which executes a block of code as long as its condition is true</li>
<li>The <code>try</code> statement, which allows exceptions raised in its attached code block to be caught and handled by <code>except</code> clauses (or new syntax <code>except*</code> in Python 3.11 for exception groups); it also ensures that clean-up code in a <code>finally</code> block is always run regardless of how the block exits</li>
<li>The <code>raise</code> statement, used to raise a specified exception or re-raise a caught exception</li>
<li>The <code>class</code> statement, which executes a block of code and attaches its local namespace to a class, for use in object-oriented programming</li>
<li>The <code>def</code> statement, which defines a function or method</li>
<li>The <code>with</code> statement, which encloses a code block within a context manager (for example, acquiring a lock before it is run, then releasing the lock; or opening and closing a file), allowing resource-acquisition-is-initialization (RAII)-like behavior and replacing a common try/finally idiom</li>
<li>The <code>break</code> statement, which exits a loop</li>
<li>The <code>continue</code> statement, which skips the current iteration and continues with the next</li>
<li>The <code>del</code> statement, which removes a variable — deleting the reference from the name to the value, and producing an error if the variable is referred to before it is redefined</li>
<li>The <code>pass</code> statement, serving as a NOP, syntactically needed to create an empty code block</li>
<li>The <code>assert</code> statement, used in debugging to check for conditions that should apply</li>
<li>The <code>yield</code> statement, which returns a value from a generator function (and also an operator); used to implement coroutines</li>
<li>The <code>return</code> statement, used to return a value from a function</li>
<li>The <code>import</code> statement, used to import modules whose functions or variables can be used in the current program</li>
</ul>
<p>The assignment statement (<code>=</code>) binds a name as a reference to a separate, dynamically-allocated object. Variables may subsequently be rebound at any time to any object. In Python, a variable name is a generic reference holder without a fixed data type; however, it always refers to some object with a type. This is called dynamic typing — in contrast to statically-typed languages, where each variable may contain only a value of a certain type.</p>
<p>Python does not support tail call optimization or first-class continuations, and, according to van Rossum, it never will. However, better support for coroutine-like functionality is provided by extending Python's generators. Before 2.5, generators were lazy iterators; data was passed unidirectionally out of the generator. From Python 2.5 on, it is possible to pass data back into a generator function; and from version 3.3, it can be passed through multiple stack levels.</p>
</section>
<section class="main-section" id="expressions">
<header><h3>Expressions</h3></header>
<p>Some Python expressions are similar to those in languages such as C and Java, while some are not:</p>
<ul>
<li>Addition, subtraction, and multiplication are the same, but the behavior of division differs. There are two types of divisions in Python: floor division (or integer division) <code>//</code> and floating-point <code>/</code> division. Python also uses the <code>**</code> operator for exponentiation.</li>
<li>The <code>@</code> infix operator. It is intended to be used by libraries such as NumPy for matrix multiplication</li>
<li>The syntax <code>:=</code>, called the "walrus operator", was introduced in Python 3.8. It assigns values to variables as part of a larger expression.</li>
<li>In Python, <code>==</code> compares by value, versus Java, which compares numerics by value and objects by reference. Python's <code>is</code> operator may be used to compare object identities (comparison by reference), and comparisons may be chained—for example, <code>a <= b <= c.</code></li>
<li>Python uses <code>and</code>, <code>or</code>, and <code>not</code> as boolean operators rather than the symbolic <code>&&</code>, <code>||</code>, <code>!</code> in Java and C.</li>
<li>Python has a type of expression called a list comprehension, as well as a more general expression called a generator expression.</li>
<li>Anonymous functions are implemented using lambda expressions; however, there may be only one expression in each body.</li>
<li>Conditional expressions are written as <code>x <span class="green">if</span> c <span class="green">else</span> y</code> (different in order of operands from the <code class="blue">c ? x : y</code> operator common to many other languages).</li>
<li>Python makes a distinction between lists and tuples. Lists are written as <code>[1, 2, 3]</code>, are mutable, and cannot be used as the keys of dictionaries (dictionary keys must be immutable in Python). Tuples, written as <code>(1, 2, 3)</code>, are immutable and thus can be used as keys of dictionaries, provided all of the tuple's elements are immutable. The <code>+</code> operator can be used to concatenate two tuples, which does not directly modify their contents, but produces a new tuple containing the elements of both. Thus, given the variable <code>t</code> initially equal to <code>(1, 2, 3)</code>, executing <code>t = t + (4, 5)</code> first evaluates <code>t + (4, 5)</code>, which yields <code>(1, 2, 3, 4, 5)</code>, which is then assigned back to <code>t</code>—thereby effectively "modifying the contents" of <code>t</code> while conforming to the immutable nature of tuple objects. Parentheses are optional for tuples in unambiguous contexts</li>
<li>Python features sequence unpacking where multiple expressions, each evaluating to anything that can be assigned (to a variable, writable property, etc.) are associated in an identical manner to that forming tuple literals—and, as a whole, are put on the left-hand side of the equal sign in an assignment statement. The statement expects an iterable object on the right-hand side of the equal sign that produces the same number of values as the provided writable expressions; when iterated through them, it assigns each of the produced values to the corresponding expression on the left.</li>
<li>Python has a "string format" operator <code>%</code> that functions analogously to <code class="blue">printf</code> format strings in C—e.g. <code>"<span class="red">spam</span><span class="purple">=</span><span class="red">%s</span> eggs=%d" % ("blah", 2)</code> evaluates to "spam=blah eggs=2". In Python 2.6+ and 3+, this was supplemented by the format() method of the str class, e.g. "spam={0} eggs={1}".format("blah", 2). Python 3.6 added "f-strings": spam = "blah"; eggs = 2; f'spam={spam} eggs={eggs}'</li>
</ul>
</section>
<section class="main-section" id="arithmetic_operations">
<header><h2>Arithmetic Operations</h2></header>
<p>Python has the usual symbols for arithmetic operators <code>(+, -, *, /)</code>, the floor division operator <code>//</code> and the modulo operation <code>%</code> (where the remainder can be negative, e.g. <code>4 % -3 == -2</code>). It also has <code>**</code> for exponentiation, e.g. <code>5**3 == 125</code> and <code>9**0.5 == 3.0</code>, and a matrix‑multiplication operator <code>@</code> . These operators work like in traditional math; with the same precedence rules, the operators infix (<code>+</code> and <code>-</code> can also be unary to represent positive and negative numbers respectively).</p>
<p>The division between integers produces floating-point results. The behavior of division has changed significantly over time:</p>
<p>Current Python (i.e. since 3.0) changed <code>/</code> to always be floating-point division, e.g. <code>5/2 == 2.5</code>.</p>
<p>The floor division <code>//</code> operator was introduced. So <code>7//3 == 2</code>, <code>-7//3 == -3</code>, <code>7.5//3 == 2.0</code> and <code>-7.5//3 == -3.0</code>. Adding <code>from __future__ import division</code> causes a module used in Python 2.7 to use Python 3.0 rules for division (see above).</p>
<p>In Python terms, <code>/</code> is true division (or simply division), and <code>//</code> is floor division. <code>/</code> before version 3.0 is classic division.</p>
<p>Rounding towards negative infinity, though different from most languages, adds consistency. For instance, it means that the equation <code>(a + b)//b == a//b + 1</code> is always true. It also means that the equation <code>b*(a//b) + a%b == a</code> is valid for both positive and negative values of <code>a</code>.</p>
<p>However, maintaining the validity of this equation means that while the result of <code>a%b</code> is, as expected, in the half-open interval <code>[0, b)</code>, where <code>b</code> is a positive integer, it has to lie in the interval (<code>b, 0</code>] when <code>b</code> is negative.</p>
<p>Python provides a round function for rounding a float to the nearest integer. For tie-breaking, Python 3 uses round to even: <code>round(1.5)</code> and <code>round(2.5)</code> both produce <code>2</code>. Versions before 3 used round-away-from-zero: <code>round(0.5)</code> is <code>1.0</code>, <code>round(-0.5)</code> is <code>−1.0</code>.</p>
<p>Python allows boolean expressions with multiple equality relations in a manner that is consistent with general use in mathematics. For example, the expression <code>a < b < c</code> tests whether <code>a</code> is less than <code>b</code> and <code>b</code> is less than <code>c</code>.</p>
<p>C-derived languages interpret this expression differently: in C, the expression would first evaluate a <code>< b</code>, resulting in <code>0</code> or <code>1</code>, and that result would then be compared with <code>c</code>.</p>
<p>Python uses arbitrary-precision arithmetic for all integer operations. The Decimal type/class in the decimal module provides decimal floating-point numbers to a pre-defined arbitrary precision and several rounding modes. The Fraction class in the fractions module provides arbitrary precision for rational numbers.</p>
<p>Due to Python's extensive mathematics library, and the third-party library <code>NumPy</code> that further extends the native capabilities, it is frequently used as a scientific scripting language to aid in problems such as numerical data processing and manipulation.</p>
</section>
<section class="main-section" id="development_environments">
<header><h2>Development Environments</h2></header>
<p>Most Python implementations (including CPython) include a <code>read–eval–print</code> loop (REPL), permitting them to function as a command line interpreter for which users enter statements sequentially and receive results immediately.</p>
<p>Python also comes with an Integrated development environment (IDE) called IDLE, which is more beginner-oriented.</p>
<p>Other shells, including IDLE and IPython, add further abilities such as improved auto-completion, session state retention and syntax highlighting.</p>
<p>As well as standard desktop integrated development environments, there are Web browser-based IDEs, including SageMath, for developing science- and math-related programs; PythonAnywhere, a browser-based IDE and hosting environment; and Canopy IDE, a commercial IDE emphasizing scientific computing</p>
</section>
<section class="main-section" id="development">
<header><h2>Development</h2></header>
<p>Python's development is conducted largely through the Python Enhancement Proposal (PEP) process, the primary mechanism for proposing major new features, collecting community input on issues, and documenting Python design decisions. Python coding style is covered in PEP 8. Outstanding PEPs are reviewed and commented on by the Python community and the steering council.</p>
<p>Enhancement of the language corresponds with the development of the CPython reference implementation. The mailing list python-dev is the primary forum for the language's development.</p>
<p>Specific issues are discussed in the Roundup bug tracker hosted at bugs.python.org. Development originally took place on a self-hosted source-code repository running Mercurial, until Python moved to GitHub in January 2017.</p>
<p>CPython's public releases come in three types, distinguished by which part of the version number is incremented:</p>
<ul>
<li>Backward-incompatible versions, where code is expected to break and needs to be manually ported. The first part of the version number is incremented. These releases happen infrequently—version 3.0 was released 8 years after 2.0. According to Guido van Rossum, a version 4.0 is very unlikely to ever happen.</li>
<li>Major or "feature" releases are largely compatible with the previous version but introduce new features. The second part of the version number is incremented. Starting with Python 3.9, these releases are expected to happen annually. Each major version is supported by bug fixes for several years after its release</li>
<li>Bugfix releases, which introduce no new features, occur about every 3 months and are made when a sufficient number of bugs have been fixed upstream since the last release. Security vulnerabilities are also patched in these releases. The third and final part of the version number is incremented.</li>
</ul>
<p>Many alpha, beta, and release-candidates are also released as previews and for testing before final releases. Although there is a rough schedule for each release, they are often delayed if the code is not ready. Python's development team monitors the state of the code by running the large unit test suite during development.</p>
<p>The major academic conference on Python is PyCon. There are also special Python mentoring programmes, such as Pyladies.</p>
<p>Python 3.10 deprecated <code>wstr</code> (to be removed in Python 3.12; meaning Python extensions need to be modified by then), and added pattern matching to the language.</p>
</section>
</main>
<footer>A Project by Philip Oyedoyin. In continuation of freeCodeCamp's Responsive Web Design Certification Course.</footer>
</body>
</html>