Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1b66c5a

Browse files
Initial Commit
0 parents commit 1b66c5a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1988
-0
lines changed

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.ipynb_checkpoints/

‎0. intro.pdf‎

1.4 MB
Binary file not shown.

‎1. Basics.ipynb‎

Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {
6+
"deletable": true,
7+
"editable": true
8+
},
9+
"source": [
10+
"# Basics"
11+
]
12+
},
13+
{
14+
"cell_type": "markdown",
15+
"metadata": {
16+
"deletable": true,
17+
"editable": true
18+
},
19+
"source": [
20+
"## Let's write our first \"Hello world!\" program :)\n",
21+
"\n",
22+
"- Run on interactive shell\n",
23+
"\n",
24+
"- Run as python script\n",
25+
"\n",
26+
"[Let's solve our first challenge!](https://www.hackerrank.com/challenges/py-hello-world)"
27+
]
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": null,
32+
"metadata": {
33+
"collapsed": true,
34+
"deletable": true,
35+
"editable": true
36+
},
37+
"outputs": [],
38+
"source": []
39+
},
40+
{
41+
"cell_type": "markdown",
42+
"metadata": {
43+
"deletable": true,
44+
"editable": true
45+
},
46+
"source": [
47+
"## Putting comments\n",
48+
"\n",
49+
"\n",
50+
"![](images/comments.jpg)\n",
51+
"\n",
52+
"> Code tells you how, comments should tell you why.\n"
53+
]
54+
},
55+
{
56+
"cell_type": "code",
57+
"execution_count": null,
58+
"metadata": {
59+
"collapsed": true,
60+
"deletable": true,
61+
"editable": true
62+
},
63+
"outputs": [],
64+
"source": []
65+
},
66+
{
67+
"cell_type": "markdown",
68+
"metadata": {
69+
"deletable": true,
70+
"editable": true
71+
},
72+
"source": [
73+
"## Literal constants\n",
74+
"\n",
75+
"- Numbers\n",
76+
" - Integers\n",
77+
" - Floats\n",
78+
"- Strings\n",
79+
" - Single quotes\n",
80+
" - Double quotes\n",
81+
" - Triple quotes\n",
82+
" - Escape sequences (\\n, \\t, \\r)\n",
83+
" - Explicit line joining"
84+
]
85+
},
86+
{
87+
"cell_type": "code",
88+
"execution_count": null,
89+
"metadata": {
90+
"collapsed": true,
91+
"deletable": true,
92+
"editable": true
93+
},
94+
"outputs": [],
95+
"source": []
96+
},
97+
{
98+
"cell_type": "markdown",
99+
"metadata": {
100+
"deletable": true,
101+
"editable": true
102+
},
103+
"source": [
104+
"## Variables\n",
105+
"\n",
106+
"A type of **identifier**.\n",
107+
"\n",
108+
"Rules for naming identifiers:\n",
109+
"\n",
110+
"- The first character of the identifier must be a letter of the alphabet (uppercase ASCII or lowercase ASCII or Unicode character) or an underscore (_).\n",
111+
" \n",
112+
"- The rest of the identifier name can consist of letters (uppercase ASCII or lowercase ASCII or Unicode character), underscores (_) or digits (0-9).\n",
113+
" \n",
114+
"- Identifier names are case-sensitive. For example, myname and myName are not the same. Note the lowercase n in the former and the uppercase N in the latter.\n",
115+
" \n",
116+
"Examples of valid identifier names are i, name_2_3. \n",
117+
"\n",
118+
"\n",
119+
"Examples of invalid identifier names are 2things, this is spaced out, my-name and >a1b2_c3."
120+
]
121+
},
122+
{
123+
"cell_type": "code",
124+
"execution_count": null,
125+
"metadata": {
126+
"collapsed": true,
127+
"deletable": true,
128+
"editable": true
129+
},
130+
"outputs": [],
131+
"source": []
132+
},
133+
{
134+
"cell_type": "markdown",
135+
"metadata": {
136+
"deletable": true,
137+
"editable": true
138+
},
139+
"source": [
140+
"## Data Types\n",
141+
"\n",
142+
"Variables can hold values of different types called data types. \n",
143+
"\n",
144+
"The basic types:\n",
145+
"- numbers\n",
146+
"- strings"
147+
]
148+
},
149+
{
150+
"cell_type": "code",
151+
"execution_count": null,
152+
"metadata": {
153+
"collapsed": true,
154+
"deletable": true,
155+
"editable": true
156+
},
157+
"outputs": [],
158+
"source": []
159+
},
160+
{
161+
"cell_type": "markdown",
162+
"metadata": {
163+
"deletable": true,
164+
"editable": true
165+
},
166+
"source": [
167+
"## Indentation\n",
168+
"\n",
169+
"![](images/indent.jpg)\n",
170+
"\n",
171+
"- Whitespace is important in Python. \n",
172+
"\n",
173+
"- Actually, whitespace at the beginning of the line is important. This is called indentation. \n",
174+
"\n",
175+
"- Leading whitespace (spaces and tabs) at the beginning of the logical line is used to determine the indentation level of the logical line, which in turn is used to determine the grouping of statements.\n",
176+
"\n",
177+
"- This means that statements which go together must have the same indentation. Each such set of statements is called a block."
178+
]
179+
},
180+
{
181+
"cell_type": "code",
182+
"execution_count": null,
183+
"metadata": {
184+
"collapsed": true,
185+
"deletable": true,
186+
"editable": true
187+
},
188+
"outputs": [],
189+
"source": []
190+
},
191+
{
192+
"cell_type": "markdown",
193+
"metadata": {
194+
"deletable": true,
195+
"editable": true
196+
},
197+
"source": [
198+
"## Issue with indentation\n",
199+
"\n",
200+
"### Tabs vs spaces\n",
201+
"\n",
202+
"![](images/tabs_vs_spaces.jpg)\n",
203+
"\n",
204+
"### The solution...\n",
205+
"\n",
206+
"![](images/usetabs.jpeg)"
207+
]
208+
},
209+
{
210+
"cell_type": "markdown",
211+
"metadata": {
212+
"deletable": true,
213+
"editable": true
214+
},
215+
"source": [
216+
"## Something more about print function...\n",
217+
"\n",
218+
"- format method\n",
219+
"\n",
220+
"- **end** and **sep**"
221+
]
222+
},
223+
{
224+
"cell_type": "code",
225+
"execution_count": null,
226+
"metadata": {
227+
"collapsed": true,
228+
"deletable": true,
229+
"editable": true
230+
},
231+
"outputs": [],
232+
"source": []
233+
},
234+
{
235+
"cell_type": "markdown",
236+
"metadata": {
237+
"deletable": true,
238+
"editable": true
239+
},
240+
"source": [
241+
"## Taking user input\n",
242+
"\n",
243+
"- input() function\n",
244+
"\n",
245+
"- concept of typecasting"
246+
]
247+
},
248+
{
249+
"cell_type": "code",
250+
"execution_count": null,
251+
"metadata": {
252+
"collapsed": true,
253+
"deletable": true,
254+
"editable": true
255+
},
256+
"outputs": [],
257+
"source": []
258+
}
259+
],
260+
"metadata": {
261+
"kernelspec": {
262+
"display_name": "Python 3",
263+
"language": "python",
264+
"name": "python3"
265+
},
266+
"language_info": {
267+
"codemirror_mode": {
268+
"name": "ipython",
269+
"version": 3
270+
},
271+
"file_extension": ".py",
272+
"mimetype": "text/x-python",
273+
"name": "python",
274+
"nbconvert_exporter": "python",
275+
"pygments_lexer": "ipython3",
276+
"version": "3.5.2+"
277+
}
278+
},
279+
"nbformat": 4,
280+
"nbformat_minor": 0
281+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /