-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
171 lines (137 loc) · 6.38 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="robots" content="index, follow">
<meta name="theme-color" content="#f4f5f6">
<title>Computer Class.</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300italic,700,700italic">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.css">
<link rel="stylesheet" href="css/milligram.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<main class="wrapper">
<section class="container">
<h1 class="title">Computer Class</h5>
<p>Learing computer programming at the Shishvan Computer Club</p>
</section>
<section class="container">
<h2 class="title">Class 1: Introduction To Python</h2>
<h5>Python</h5>
<p>Install and run "python" to start the interpreter. Try basic math statements.</p>
<p><pre class='code prettyprint'><code class='code-content'>>>> 2+2
4
>>> 5 * 20
100
>>> 10 / 3
3</code></pre></p>
<h5>Variables</h5>
<p>Values can be given names (Variables) and can be used instead of numbers.</p>
<p><pre class='code prettyprint'><code class='code-content'>>>> my_marks / total_marks * 100</code></pre></p>
<h5>Lists</h5>
<p>Values can be maintained in a list and accessed by its "index".</p>
<p><pre class='code prettyprint'><code class='code-content'>>>> my_list = [23, 4, 6, 'harry']
>>> my_list[0]
23</code></pre></p>
<h5>Functions</h5>
<p>A function is <b>def</b>ined to run a group of statements and return a value.</p>
<p><pre class='code prettyprint'><code class='code-content'>>>> def what_is_my_percent(my_marks, total_marks):
return my_marks / total_marks * 100
>>> what_is_my_percent(273.0, 300)
91.0</code></pre></p>
</section>
<section class="container">
<h2 class="title">Class 2: Loops and Modules</h2>
<h5>Loops</h5>
<p>A loop can run a group of statements many times.</p>
<p><pre class='code prettyprint'><code class='code-content'>>>> def add_marks(marks):
total_marks = 0
for mark in marks:
total_marks = total_marks + mark
return total_marks
>>> add_marks([20, 30, 40, 10])
100</code></pre></p>
<h5>String Concatenation</h5>
<p>Letters (strings) can be joined to make sentences.</p>
<p><pre class='code prettyprint'><code class='code-content'>>>> def say_hello(students):
student_names = ''
for student in students:
student_names = student_names + ' ' + student + ','
return 'Hello' + student_names[:-1] + '. How are you?'
>>> say_hello(['Harry', 'Hermione', 'Ron'])
Hello Harry, Hermione, Ron. How are you?</code></pre></p>
<h5>Modules</h5>
<p>Functions and variables can be put in files called "modules". The can be imported using the <code>import</code> statement.</p>
<p><pre class='code prettyprint'><code class='code-content'>>>> import wizard
>>> wizard.add_marks([20, 30, 40])</code></pre></p>
</section>
<section class="container">
<h2 class="title">Class 3: Classes and Conditions</h2>
<h5>Classes</h5>
<p>Classes can be used to define concepts with many properties. Concepts can then be made into objects.</p>
<p><pre class='code prettyprint'><code class='code-content'>class House:
ability = None
class Student:
ability = None
gryffindor = House()
gryffindor.ability = 'bravery'
harry = Student()
harry.ability = 'bravery'</code></pre></p>
<h5>Inspection</h5>
<p>Modules, objects, classes can be inspected to discover its inner properties.</p>
<p><pre class='code prettyprint'><code class='code-content'>>>> import sortinghat
>>> dir(sortinghat)
['House', 'Student', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 'gryffindor', 'harry']</code></pre></p>
<h5>Conditions</h5>
<p><code>if</code> statement can run a group of statements based on a condition.</p>
<p><pre class='code prettyprint'><code class='code-content'>def sort(student):
for house in all_houses:
if house.ability == student.ability:
if house.students is None:
house.students = []
house.students.append(student)
print student.name + ' goes to ' + house.name + '!'</code></pre></p>
</section>
<section class="container">
<h2 class="title">Class 4: Practice!</h2>
<h5>Calling functions and Loops</h5>
<p>Magic is created by calling functions inside loops (among other things!).</p>
<p><pre class='code prettyprint'><code class='code-content'>def sort_everyone():
for student in all_students:
sort(student)</code></pre></p>
</section>
<section class="container">
<h2 class="title">Class 5: HTML</h2>
<h5>index.html</h5>
<p>HTML is a file with text that is decorated with tags like <code><h1></code> etc.</p>
<p><pre class='code prettyprint'><code class='code-content'><html>
<h1>Shishuvan Computer Club</h1>
<p>Welcome to the Shishuvan Computer Club</p>
</html></code></pre></p>
<h5>Style</h5>
<p>Tags can have <code>style</code> attribute that sets its spacing, font, color etc.</p>
<p><pre class='code prettyprint'><code class='code-content'><html class='font-family: Joker; background-color: yellow; padding: 30px;'>
<h1 style='color: red'>Shishuvan Computer Club</h1>
<p>Welcome to the Shishuvan Computer Club</p>
</html></code></pre></p>
<h5><code><div></code> Block</h5>
<p>Rectangular blocks can be defined using the <code><div></code> tag.</p>
<p><pre class='code prettyprint'><code class='code-content'><html class='font-family: Joker; background-color: yellow'>
<h1 style='color: red'>Shishuvan Computer Club</h1>
<p>Welcome to the Shishuvan Computer Club</p>
<div style='height: 10px; color: blue;'></div>
</html></code></pre></p>
</section>
<!--<p><pre class='code prettyprint'><code class='code-content'></code></pre></p>-->
<footer class="footer">
<section class="container">
<p>Made with ♥ by Rushabh Mehta. Licensed under the Creative Commons BY-CC-NA.</p>
</section>
</footer>
</main>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/run_prettify.js"></script>
<script src="js/script.js"></script>
</body>
</html>