-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpython_syntax.html
46 lines (46 loc) · 2.32 KB
/
python_syntax.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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>python_syntax</title>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
</head>
<body>
<h1 id="python-syntax">Python Syntax</h1>
<p><strong>Python Syntax compared to other programming languages</strong></p>
<ul>
<li>Python was designed to for readability, and has some similarities to the English language with influence from mathematics.</li>
<li>Python uses new lines to complete a command, as opposed to other programming languages which often use semicolons or parentheses.</li>
<li>Python relies on indentation, using whitespace, to define scope; such as the scope of loops, functions and classes. Other programming languages often use curly-brackets for this purpose.</li>
</ul>
<h2 id="python-indentations">Python Indentations</h2>
<p>Where in other programming languages the indentation in code is for readability only, in Python the indentation is very important.</p>
<p>Python uses indentation to indicate a block of code.</p>
<pre><code>if 5 > 2:
print("Five is greater than two!")</code></pre>
<p>Python will give you an error if you skip the indentation.</p>
<h2 id="comments">Comments</h2>
<p>Python has commenting capability for the purpose of in-code documentation.</p>
<p>Comments start with a <code>#</code>, and Python will render the rest of the line as a comment:</p>
<pre><code>#This is a comment.
print("Hello, World!")</code></pre>
<h2 id="docstrings">Docstrings</h2>
<p>Python also has extended documentation capability, called docstrings.</p>
<p>Docstrings can be one line, or multiline. Docstrings are also comments:</p>
<p>Python uses triple quotes at the beginning and end of the docstring:</p>
<pre><code>"""This is a
multiline docstring."""
print("Hello, World!")</code></pre>
<h2 id="references">References</h2>
<ul>
<li><a href="https://www.w3schools.com/python/python_syntax.asp">w3schools.com</a></li>
</ul>
</body>
</html>