-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
118 lines (118 loc) · 6.24 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset ="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="technical documentation page">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Quicksand:[email protected]&display=swap" rel="stylesheet">
<link rel="stylesheet" href="styles.css">
<title>Technical Documentation Page</title>
</head>
<body>
<nav id="navbar">
<header>Python Documentation</header>
<ul>
<li><a class="nav-link" href="#What_Is_Python?">What Is Python?</a>
</li>
<li><a class="nav-link" href="#Comments">Comments</a></li>
<li><a class="nav-link" href="#Variables">Variables</a></li>
<li><a class="nav-link" href="#If...Else_Statements">If...Else Statements</a></li>
<li><a class="nav-link" href="#While_Loops">While Loops</a></li>
<li><a class="nav-link" href="#For_Loops">For Loops</a></li>
<li><a class="nav-link" href="#Functions">Functions</a></li>
<li><a class="nav-link" href="#Reference">Reference</a></li>
</ul>
</nav>
<main id="main-doc">
<section class="main-section" id="What_Is_Python?">
<header>What is Python?</header>
<p>Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.</p>
<p>It is used for:</p>
<ul>
<li>web development (server side),</li>
<li>software development,</li>
<li>mathematics,</li>
<li>system scripting</li>
</ul>
</section>
<section class="main-section" id="Comments">
<header>Comments</header>
<p>Comments can be used to explain Python code, make the code more readable, or prevent execution when testing code.</p>
<p>Comments start with a <code>#</code>, and Python will ignore them.</p>
<div class="code-block">
<code># This is a comment</code>
</div>
</section>
<section class="main-section" id="Variables">
<header>Variables</header>
<p>Variables are containers for storing variables.</p>
<p>A variable is created the moment you first assign a value to it.</p>
<div class="code-block">
<code>x = 5 <br> y = "Josh"</code>
</div>
<p>Variables do not need to be declared with any particular type, and can even change type after they have been set.</p>
<div class="code-block">
<code>x = 4 <br>x = "Sally"</code>
</div>
</section>
<section class="main-section" id="If...Else_Statements">
<header>If...Else Statements</header>
<p>Python supports the usual logical conditions from mathematics:</p>
<ul>
<li>Equals: <code>a == b</code></li>
<li>Not Equals: <code>a != b</code></li>
<li>Less than: <code>a < b</code></li>
<li>Less than or equal to: <code>a <= b</code></li>
<li>Greater than: <code>a > b</code></li>
<li>Greater than or equal to: <code>a >= b</code></li>
</ul>
<p>These conditions can be used in several ways, most commonly in "if statements" and loops.</p>
<p>An "if statement" is written by using the <code>if</code> keyword.</p>
<div class="code-block">
<code>a = 33<br>b = 200<br>if b > a:<br><span class="indent">print("b is greater than a")</span></code>
</div>
<p>The <code>elif</code> keyword is Python's way of saying "if the previous conditions were not true, then try this condition".</p>
<div class="code-block">
<code>a = 33<br>b = 33<br>if b > a:<br><span class="indent">print("b is greater than a")</span><br>elif a == b:<br><span class="indent">print("a and b are equal")</span></code>
</div>
<p>The <code>else</code> keyword catches anything which isn't caught by the preceding conditions.</p>
<div class="code-block">
<code>a = 200<br>b = 33<br>if b > a:<br><span class="indent">print("b is greater than a")</span><br>elif a == b:<br><span class="indent">print("a and b are equal")</span><br>else:<br><span class="indent">print("a is greater than b")</span></code>
</div>
</section>
<section class="main-section" id="While_Loops">
<header>While Loops</header>
<p>With the <code>while</code> loop we can execute a set of statements as long as a condition is true.</p>
<div class="code-block">
<code>i = 1<br>while i < 6:<br><span class="indent">print(i)<br>i += 1</span></code>
</div>
</section>
<section class="main-section" id="For_Loops">
<header>For Loops</header>
<p>A <code>for</code> loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string).</p>
<p>This is less like the <code>for</code> keyword in other programming languages, and works more like an iterator method as found in other object-orientated programming languages.</p>
<p>With the <code>for</code> loop we can execute a set of statements, once for each item in a list, tuple, set etc.</p>
<div class="code-block">
<code>fruits = ["apple", "banana", "cherry"]<br>for x in fruits:<br><span class="indent">print(x)</span></code>
</div>
</section>
<section class="main-section" id="Functions">
<header>Functions</header>
<p>In Python a function is defined using the <code>def</code> keyword:</p>
<div class="code-block">
<code>def my_function():<br><span class="indent">print("Hello from a function")</span></code>
</div>
<p>To call a function, use the function name followed by parenthesis:</p>
<div class="code-block">
<code>def my_function():<br><span class="indent">print("Hello from a function")</span><br><br>my_function()</code>
</div>
</section>
<section class="main-section" id="Reference">
<header>Reference</header>
<p class="reference">all documentation in this page is taken from <a href="https://www.w3schools.com/python/default.asp" target="_blank">w3schools.</a></p>
</section>
</main>
</body>
</html>