Skip to content

Commit 734f46e

Browse files
committedOct 23, 2021
First commit
0 parents  commit 734f46e

12 files changed

+3946
-0
lines changed
 

‎.DS_Store

6 KB
Binary file not shown.
+314
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,314 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"## 1. Keywords\n",
8+
"\n",
9+
"- Keywords are the reserved words in Python. \n",
10+
"- Think of keywords as some in-built functionality in Python to achieve a particular task.\n",
11+
"- We cannot use a keyword as a variable name, function name, or any other identifier. They are used to define the syntax and structure of the Python language.\n",
12+
"- In Python, keywords are case-sensitive. There are 33 keywords in Python 3.7. This number can vary slightly over the course of time.\n",
13+
"- All the keywords except `True`, `False`, and `None` are in lowercase and they must be written as they are.\n"
14+
]
15+
},
16+
{
17+
"cell_type": "markdown",
18+
"metadata": {},
19+
"source": [
20+
"<img src=\"img/keywords.png\" alt=\"fishy\" class=\"bg-primary mb-1\">\n",
21+
"<h4><center>List of keywords in Python</center></h4>\n",
22+
"\n",
23+
"-----------"
24+
]
25+
},
26+
{
27+
"cell_type": "markdown",
28+
"metadata": {},
29+
"source": [
30+
"## 2. Identifiers\n",
31+
"\n",
32+
"- An identifier is a name given to entities like class, functions, variables, etc.\n",
33+
"- It helps to differentiate one entity from another.\n",
34+
"\n",
35+
"**Rules for naming identifiers**\n",
36+
"- Python is a case-sensitive language\n",
37+
"- An identifier can be a combination of letters (a/A), digits (0-9) or an underscore(_)\n",
38+
"- An identifier cannot start with a digit\n",
39+
"- Keywords cannot be used as an identifier"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": 4,
45+
"metadata": {},
46+
"outputs": [],
47+
"source": [
48+
"#here name is an identifier as it is used to store a text\n",
49+
"name = \"Ronaldo\"\n",
50+
"\n",
51+
"#here num is an identifier \n",
52+
"num = 23\n",
53+
"\n",
54+
"#list_president is an identifier as it is used to name a list\n",
55+
"list_president = [\"Barack Obama\", \"Donald Trump\", \"Joe Biden\"]"
56+
]
57+
},
58+
{
59+
"cell_type": "markdown",
60+
"metadata": {},
61+
"source": [
62+
"----------"
63+
]
64+
},
65+
{
66+
"cell_type": "markdown",
67+
"metadata": {},
68+
"source": [
69+
"## 3. Comments\n",
70+
"\n",
71+
"- Comments are very important while writing a program. They describe what is going on inside a program, so that a person looking at the source code does not have a hard time figuring it out.\n",
72+
"- You might forget the key details of the program you just wrote in a month's time. So taking the time to explain these concepts in the form of comments is always fruitful.\n",
73+
"- In Python, we use the hash (**#**) symbol to start writing a comment."
74+
]
75+
},
76+
{
77+
"cell_type": "markdown",
78+
"metadata": {},
79+
"source": [
80+
"**Single Line Comment**"
81+
]
82+
},
83+
{
84+
"cell_type": "code",
85+
"execution_count": 13,
86+
"metadata": {},
87+
"outputs": [
88+
{
89+
"name": "stdout",
90+
"output_type": "stream",
91+
"text": [
92+
"Hello\n"
93+
]
94+
}
95+
],
96+
"source": [
97+
"#This is a comment - print out Hello\n",
98+
"print('Hello')"
99+
]
100+
},
101+
{
102+
"cell_type": "markdown",
103+
"metadata": {},
104+
"source": [
105+
"**Multi-Line Comment**"
106+
]
107+
},
108+
{
109+
"cell_type": "code",
110+
"execution_count": 6,
111+
"metadata": {},
112+
"outputs": [],
113+
"source": [
114+
"#This is a long comment\n",
115+
"#and it extends\n",
116+
"#to multiple lines"
117+
]
118+
},
119+
{
120+
"cell_type": "code",
121+
"execution_count": 12,
122+
"metadata": {},
123+
"outputs": [
124+
{
125+
"data": {
126+
"text/plain": [
127+
"'This is also a perfect \\nexample of\\nmulti-line comments'"
128+
]
129+
},
130+
"execution_count": 12,
131+
"metadata": {},
132+
"output_type": "execute_result"
133+
}
134+
],
135+
"source": [
136+
"\"\"\"This is also a perfect \n",
137+
"example of\n",
138+
"multi-line comments\"\"\""
139+
]
140+
},
141+
{
142+
"cell_type": "markdown",
143+
"metadata": {},
144+
"source": [
145+
"----------"
146+
]
147+
},
148+
{
149+
"cell_type": "markdown",
150+
"metadata": {},
151+
"source": [
152+
"## 4. Docstrings\n",
153+
"\n",
154+
"- A docstring is short for documentation string.\n",
155+
"- Python docstrings (documentation strings) are the string literals that appear right after the definition of a function, method, class, or module.\n",
156+
"- Triple quotes are used while writing docstrings. For example:"
157+
]
158+
},
159+
{
160+
"cell_type": "code",
161+
"execution_count": 14,
162+
"metadata": {},
163+
"outputs": [],
164+
"source": [
165+
"def double(num):\n",
166+
" \"\"\"Function to double the value\"\"\"\n",
167+
" return 2*num"
168+
]
169+
},
170+
{
171+
"cell_type": "markdown",
172+
"metadata": {},
173+
"source": [
174+
"- Docstrings appear right after the definition of a function, class, or a module. This separates docstrings from multiline comments using triple quotes.\n",
175+
"- The docstrings are associated with the object as their `__doc__` attribute.\n",
176+
"- So, we can access the docstrings of the above function with the following lines of code:"
177+
]
178+
},
179+
{
180+
"cell_type": "code",
181+
"execution_count": 16,
182+
"metadata": {},
183+
"outputs": [
184+
{
185+
"data": {
186+
"text/plain": [
187+
"'Function to double the value'"
188+
]
189+
},
190+
"execution_count": 16,
191+
"metadata": {},
192+
"output_type": "execute_result"
193+
}
194+
],
195+
"source": [
196+
"#Print the docstring\n",
197+
"double.__doc__"
198+
]
199+
},
200+
{
201+
"cell_type": "markdown",
202+
"metadata": {},
203+
"source": [
204+
"-------------"
205+
]
206+
},
207+
{
208+
"cell_type": "markdown",
209+
"metadata": {},
210+
"source": [
211+
"## 5. Indentation\n",
212+
"\n",
213+
"- Most of the programming languages like C, C++, and Java use braces { } to define a block of code. Python, however, uses indentation.\n",
214+
"- A code block (body of a function, loop, etc.) starts with indentation and ends with the first unindented line.\n",
215+
"- The amount of indentation is up to you, but it must be consistent throughout that block."
216+
]
217+
},
218+
{
219+
"cell_type": "code",
220+
"execution_count": 17,
221+
"metadata": {},
222+
"outputs": [
223+
{
224+
"name": "stdout",
225+
"output_type": "stream",
226+
"text": [
227+
"1\n",
228+
"2\n",
229+
"3\n",
230+
"4\n",
231+
"5\n"
232+
]
233+
}
234+
],
235+
"source": [
236+
"#Generally, four whitespaces are used for indentation and are preferred over tabs. Here is an example.\n",
237+
"for i in range(1,11):\n",
238+
" print(i)\n",
239+
" if i == 5:\n",
240+
" break"
241+
]
242+
},
243+
{
244+
"cell_type": "markdown",
245+
"metadata": {},
246+
"source": [
247+
"------------"
248+
]
249+
},
250+
{
251+
"cell_type": "markdown",
252+
"metadata": {},
253+
"source": [
254+
"## 6. Statements\n",
255+
"\n",
256+
"- Instructions that a Python interpreter can execute are called statements.\n",
257+
"- For example, a = 1 is an assignment statement.\n",
258+
"- if statement, for statement, while statement, etc. are other kinds of statements which will be discussed late"
259+
]
260+
},
261+
{
262+
"cell_type": "code",
263+
"execution_count": 18,
264+
"metadata": {},
265+
"outputs": [],
266+
"source": [
267+
"#This is an explicit line continuation. \n",
268+
"#In Python, line continuation is implied inside parentheses ( ), brackets [ ], and braces { }. \n",
269+
"\n",
270+
"#For instance, we can implement the above multi-line statement as:\n",
271+
"a = 1 + 2 + 3 + \\\n",
272+
" 4 + 5 + 6 + \\\n",
273+
" 7 + 8 + 9\n",
274+
"\n",
275+
"#Here, the surrounding parentheses ( ) do the line continuation implicitly. Same is the case with [ ] and { }. For example:\n",
276+
"colors = ['red',\n",
277+
" 'blue',\n",
278+
" 'green']\n",
279+
"\n",
280+
"\n",
281+
"#We can also put multiple statements in a single line using semicolons, as follows:\n",
282+
"a = 1; b = 2; c = 3"
283+
]
284+
},
285+
{
286+
"cell_type": "code",
287+
"execution_count": null,
288+
"metadata": {},
289+
"outputs": [],
290+
"source": []
291+
}
292+
],
293+
"metadata": {
294+
"kernelspec": {
295+
"display_name": "Python 3",
296+
"language": "python",
297+
"name": "python3"
298+
},
299+
"language_info": {
300+
"codemirror_mode": {
301+
"name": "ipython",
302+
"version": 3
303+
},
304+
"file_extension": ".py",
305+
"mimetype": "text/x-python",
306+
"name": "python",
307+
"nbconvert_exporter": "python",
308+
"pygments_lexer": "ipython3",
309+
"version": "3.8.5"
310+
}
311+
},
312+
"nbformat": 4,
313+
"nbformat_minor": 4
314+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,328 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"## 1. Keywords\n",
8+
"\n",
9+
"- Keywords are the reserved words in Python. \n",
10+
"- Think of keywords as some in-built functionality in Python to achieve a particular task.\n",
11+
"- We cannot use a keyword as a variable name, function name, or any other identifier. They are used to define the syntax and structure of the Python language.\n",
12+
"- In Python, keywords are case-sensitive. There are 33 keywords in Python 3.7. This number can vary slightly over the course of time.\n",
13+
"- All the keywords except `True`, `False`, and `None` are in lowercase and they must be written as they are.\n"
14+
]
15+
},
16+
{
17+
"cell_type": "markdown",
18+
"metadata": {},
19+
"source": [
20+
"<img src=\"../img/keywords.png\" alt=\"fishy\" class=\"bg-primary mb-1\">\n",
21+
"<h4><center>List of keywords in Python</center></h4>\n",
22+
"\n",
23+
"-----------"
24+
]
25+
},
26+
{
27+
"cell_type": "markdown",
28+
"metadata": {},
29+
"source": [
30+
"## 2. Identifiers\n",
31+
"\n",
32+
"- An identifier is a name given to entities like class, functions, variables, etc.\n",
33+
"- It helps to differentiate one entity from another.\n",
34+
"\n",
35+
"**Rules for naming identifiers**\n",
36+
"- Python is a case-sensitive language\n",
37+
"- An identifier can be a combination of letters (a/A), digits (0-9) or an underscore(_)\n",
38+
"- An identifier cannot start with a digit\n",
39+
"- Keywords cannot be used as an identifier"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": 4,
45+
"metadata": {},
46+
"outputs": [],
47+
"source": [
48+
"#here name is an identifier as it is used to store a text\n",
49+
"name = \"Ronaldo\"\n",
50+
"\n",
51+
"#here num is an identifier \n",
52+
"num = 23\n",
53+
"\n",
54+
"#list_president is an identifier as it is used to name a list\n",
55+
"list_president = [\"Barack Obama\", \"Donald Trump\", \"Joe Biden\"]"
56+
]
57+
},
58+
{
59+
"cell_type": "markdown",
60+
"metadata": {},
61+
"source": [
62+
"----------"
63+
]
64+
},
65+
{
66+
"cell_type": "markdown",
67+
"metadata": {},
68+
"source": [
69+
"## 3. Comments\n",
70+
"\n",
71+
"- Comments are very important while writing a program. They describe what is going on inside a program, so that a person looking at the source code does not have a hard time figuring it out.\n",
72+
"- You might forget the key details of the program you just wrote in a month's time. So taking the time to explain these concepts in the form of comments is always fruitful.\n",
73+
"- In Python, we use the hash (**#**) symbol to start writing a comment."
74+
]
75+
},
76+
{
77+
"cell_type": "markdown",
78+
"metadata": {},
79+
"source": [
80+
"**Single Line Comment**"
81+
]
82+
},
83+
{
84+
"cell_type": "code",
85+
"execution_count": 13,
86+
"metadata": {},
87+
"outputs": [
88+
{
89+
"name": "stdout",
90+
"output_type": "stream",
91+
"text": [
92+
"Hello\n"
93+
]
94+
}
95+
],
96+
"source": [
97+
"#This is a comment - print out Hello\n",
98+
"print('Hello')"
99+
]
100+
},
101+
{
102+
"cell_type": "markdown",
103+
"metadata": {},
104+
"source": [
105+
"**Multi-Line Comment**"
106+
]
107+
},
108+
{
109+
"cell_type": "code",
110+
"execution_count": 6,
111+
"metadata": {},
112+
"outputs": [],
113+
"source": [
114+
"#This is a long comment\n",
115+
"#and it extends\n",
116+
"#to multiple lines"
117+
]
118+
},
119+
{
120+
"cell_type": "code",
121+
"execution_count": 12,
122+
"metadata": {},
123+
"outputs": [
124+
{
125+
"data": {
126+
"text/plain": [
127+
"'This is also a perfect \\nexample of\\nmulti-line comments'"
128+
]
129+
},
130+
"execution_count": 12,
131+
"metadata": {},
132+
"output_type": "execute_result"
133+
}
134+
],
135+
"source": [
136+
"\"\"\"This is also a perfect \n",
137+
"example of\n",
138+
"multi-line comments\"\"\""
139+
]
140+
},
141+
{
142+
"cell_type": "markdown",
143+
"metadata": {},
144+
"source": [
145+
"----------"
146+
]
147+
},
148+
{
149+
"cell_type": "markdown",
150+
"metadata": {},
151+
"source": [
152+
"## 4. Docstrings\n",
153+
"\n",
154+
"- A docstring is short for documentation string.\n",
155+
"- Python docstrings (documentation strings) are the string literals that appear right after the definition of a function, method, class, or module.\n",
156+
"- Triple quotes are used while writing docstrings. For example:"
157+
]
158+
},
159+
{
160+
"cell_type": "code",
161+
"execution_count": 14,
162+
"metadata": {},
163+
"outputs": [],
164+
"source": [
165+
"def double(num):\n",
166+
" \"\"\"Function to double the value\"\"\"\n",
167+
" return 2*num"
168+
]
169+
},
170+
{
171+
"cell_type": "markdown",
172+
"metadata": {},
173+
"source": [
174+
"- Docstrings appear right after the definition of a function, class, or a module. This separates docstrings from multiline comments using triple quotes.\n",
175+
"- The docstrings are associated with the object as their `__doc__` attribute.\n",
176+
"- So, we can access the docstrings of the above function with the following lines of code:"
177+
]
178+
},
179+
{
180+
"cell_type": "code",
181+
"execution_count": 16,
182+
"metadata": {},
183+
"outputs": [
184+
{
185+
"data": {
186+
"text/plain": [
187+
"'Function to double the value'"
188+
]
189+
},
190+
"execution_count": 16,
191+
"metadata": {},
192+
"output_type": "execute_result"
193+
}
194+
],
195+
"source": [
196+
"#Print the docstring\n",
197+
"double.__doc__"
198+
]
199+
},
200+
{
201+
"cell_type": "markdown",
202+
"metadata": {},
203+
"source": [
204+
"-------------"
205+
]
206+
},
207+
{
208+
"cell_type": "markdown",
209+
"metadata": {},
210+
"source": [
211+
"## 5. Indentation\n",
212+
"\n",
213+
"- Most of the programming languages like C, C++, and Java use braces { } to define a block of code. Python, however, uses indentation.\n",
214+
"- A code block (body of a function, loop, etc.) starts with indentation and ends with the first unindented line.\n",
215+
"- The amount of indentation is up to you, but it must be consistent throughout that block."
216+
]
217+
},
218+
{
219+
"cell_type": "code",
220+
"execution_count": 17,
221+
"metadata": {},
222+
"outputs": [
223+
{
224+
"name": "stdout",
225+
"output_type": "stream",
226+
"text": [
227+
"1\n",
228+
"2\n",
229+
"3\n",
230+
"4\n",
231+
"5\n"
232+
]
233+
}
234+
],
235+
"source": [
236+
"#Generally, four whitespaces are used for indentation and are preferred over tabs. Here is an example.\n",
237+
"for i in range(1,11):\n",
238+
" print(i)\n",
239+
" if i == 5:\n",
240+
" break"
241+
]
242+
},
243+
{
244+
"cell_type": "markdown",
245+
"metadata": {},
246+
"source": [
247+
"------------"
248+
]
249+
},
250+
{
251+
"cell_type": "markdown",
252+
"metadata": {},
253+
"source": [
254+
"## 6. Statements\n",
255+
"\n",
256+
"- Instructions that a Python interpreter can execute are called statements.\n",
257+
"- For example, a = 1 is an assignment statement.\n",
258+
"- if statement, for statement, while statement, etc. are other kinds of statements which will be discussed late"
259+
]
260+
},
261+
{
262+
"cell_type": "code",
263+
"execution_count": 18,
264+
"metadata": {},
265+
"outputs": [],
266+
"source": [
267+
"#This is an explicit line continuation. \n",
268+
"#In Python, line continuation is implied inside parentheses ( ), brackets [ ], and braces { }. \n",
269+
"\n",
270+
"#For instance, we can implement the above multi-line statement as:\n",
271+
"a = 1 + 2 + 3 + \\\n",
272+
" 4 + 5 + 6 + \\\n",
273+
" 7 + 8 + 9\n",
274+
"\n",
275+
"#Here, the surrounding parentheses ( ) do the line continuation implicitly. Same is the case with [ ] and { }. For example:\n",
276+
"colors = ['red',\n",
277+
" 'blue',\n",
278+
" 'green']\n",
279+
"\n",
280+
"\n",
281+
"#We can also put multiple statements in a single line using semicolons, as follows:\n",
282+
"a = 1; b = 2; c = 3"
283+
]
284+
},
285+
{
286+
"cell_type": "markdown",
287+
"metadata": {},
288+
"source": [
289+
"----------"
290+
]
291+
},
292+
{
293+
"cell_type": "markdown",
294+
"metadata": {},
295+
"source": [
296+
"**End of Document**"
297+
]
298+
},
299+
{
300+
"cell_type": "code",
301+
"execution_count": null,
302+
"metadata": {},
303+
"outputs": [],
304+
"source": []
305+
}
306+
],
307+
"metadata": {
308+
"kernelspec": {
309+
"display_name": "Python 3",
310+
"language": "python",
311+
"name": "python3"
312+
},
313+
"language_info": {
314+
"codemirror_mode": {
315+
"name": "ipython",
316+
"version": 3
317+
},
318+
"file_extension": ".py",
319+
"mimetype": "text/x-python",
320+
"name": "python",
321+
"nbconvert_exporter": "python",
322+
"pygments_lexer": "ipython3",
323+
"version": "3.8.5"
324+
}
325+
},
326+
"nbformat": 4,
327+
"nbformat_minor": 4
328+
}

‎1. Python_Introduction/.ipynb_checkpoints/2. Variables_and_Constants-checkpoint.ipynb

+555
Large diffs are not rendered by default.

‎1. Python_Introduction/.ipynb_checkpoints/3. Data_Types-checkpoint.ipynb

+547
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,328 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"## 1. Keywords\n",
8+
"\n",
9+
"- Keywords are the reserved words in Python. \n",
10+
"- Think of keywords as some in-built functionality in Python to achieve a particular task.\n",
11+
"- We cannot use a keyword as a variable name, function name, or any other identifier. They are used to define the syntax and structure of the Python language.\n",
12+
"- In Python, keywords are case-sensitive. There are 33 keywords in Python 3.7. This number can vary slightly over the course of time.\n",
13+
"- All the keywords except `True`, `False`, and `None` are in lowercase and they must be written as they are.\n"
14+
]
15+
},
16+
{
17+
"cell_type": "markdown",
18+
"metadata": {},
19+
"source": [
20+
"<img src=\"../img/keywords.png\" alt=\"fishy\" class=\"bg-primary mb-1\">\n",
21+
"<h4><center>List of keywords in Python</center></h4>\n",
22+
"\n",
23+
"-----------"
24+
]
25+
},
26+
{
27+
"cell_type": "markdown",
28+
"metadata": {},
29+
"source": [
30+
"## 2. Identifiers\n",
31+
"\n",
32+
"- An identifier is a name given to entities like class, functions, variables, etc.\n",
33+
"- It helps to differentiate one entity from another.\n",
34+
"\n",
35+
"**Rules for naming identifiers**\n",
36+
"- Python is a case-sensitive language\n",
37+
"- An identifier can be a combination of letters (a/A), digits (0-9) or an underscore(_)\n",
38+
"- An identifier cannot start with a digit\n",
39+
"- Keywords cannot be used as an identifier"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": 4,
45+
"metadata": {},
46+
"outputs": [],
47+
"source": [
48+
"#here name is an identifier as it is used to store a text\n",
49+
"name = \"Ronaldo\"\n",
50+
"\n",
51+
"#here num is an identifier \n",
52+
"num = 23\n",
53+
"\n",
54+
"#list_president is an identifier as it is used to name a list\n",
55+
"list_president = [\"Barack Obama\", \"Donald Trump\", \"Joe Biden\"]"
56+
]
57+
},
58+
{
59+
"cell_type": "markdown",
60+
"metadata": {},
61+
"source": [
62+
"----------"
63+
]
64+
},
65+
{
66+
"cell_type": "markdown",
67+
"metadata": {},
68+
"source": [
69+
"## 3. Comments\n",
70+
"\n",
71+
"- Comments are very important while writing a program. They describe what is going on inside a program, so that a person looking at the source code does not have a hard time figuring it out.\n",
72+
"- You might forget the key details of the program you just wrote in a month's time. So taking the time to explain these concepts in the form of comments is always fruitful.\n",
73+
"- In Python, we use the hash (**#**) symbol to start writing a comment."
74+
]
75+
},
76+
{
77+
"cell_type": "markdown",
78+
"metadata": {},
79+
"source": [
80+
"**Single Line Comment**"
81+
]
82+
},
83+
{
84+
"cell_type": "code",
85+
"execution_count": 13,
86+
"metadata": {},
87+
"outputs": [
88+
{
89+
"name": "stdout",
90+
"output_type": "stream",
91+
"text": [
92+
"Hello\n"
93+
]
94+
}
95+
],
96+
"source": [
97+
"#This is a comment - print out Hello\n",
98+
"print('Hello')"
99+
]
100+
},
101+
{
102+
"cell_type": "markdown",
103+
"metadata": {},
104+
"source": [
105+
"**Multi-Line Comment**"
106+
]
107+
},
108+
{
109+
"cell_type": "code",
110+
"execution_count": 6,
111+
"metadata": {},
112+
"outputs": [],
113+
"source": [
114+
"#This is a long comment\n",
115+
"#and it extends\n",
116+
"#to multiple lines"
117+
]
118+
},
119+
{
120+
"cell_type": "code",
121+
"execution_count": 12,
122+
"metadata": {},
123+
"outputs": [
124+
{
125+
"data": {
126+
"text/plain": [
127+
"'This is also a perfect \\nexample of\\nmulti-line comments'"
128+
]
129+
},
130+
"execution_count": 12,
131+
"metadata": {},
132+
"output_type": "execute_result"
133+
}
134+
],
135+
"source": [
136+
"\"\"\"This is also a perfect \n",
137+
"example of\n",
138+
"multi-line comments\"\"\""
139+
]
140+
},
141+
{
142+
"cell_type": "markdown",
143+
"metadata": {},
144+
"source": [
145+
"----------"
146+
]
147+
},
148+
{
149+
"cell_type": "markdown",
150+
"metadata": {},
151+
"source": [
152+
"## 4. Docstrings\n",
153+
"\n",
154+
"- A docstring is short for documentation string.\n",
155+
"- Python docstrings (documentation strings) are the string literals that appear right after the definition of a function, method, class, or module.\n",
156+
"- Triple quotes are used while writing docstrings. For example:"
157+
]
158+
},
159+
{
160+
"cell_type": "code",
161+
"execution_count": 14,
162+
"metadata": {},
163+
"outputs": [],
164+
"source": [
165+
"def double(num):\n",
166+
" \"\"\"Function to double the value\"\"\"\n",
167+
" return 2*num"
168+
]
169+
},
170+
{
171+
"cell_type": "markdown",
172+
"metadata": {},
173+
"source": [
174+
"- Docstrings appear right after the definition of a function, class, or a module. This separates docstrings from multiline comments using triple quotes.\n",
175+
"- The docstrings are associated with the object as their `__doc__` attribute.\n",
176+
"- So, we can access the docstrings of the above function with the following lines of code:"
177+
]
178+
},
179+
{
180+
"cell_type": "code",
181+
"execution_count": 16,
182+
"metadata": {},
183+
"outputs": [
184+
{
185+
"data": {
186+
"text/plain": [
187+
"'Function to double the value'"
188+
]
189+
},
190+
"execution_count": 16,
191+
"metadata": {},
192+
"output_type": "execute_result"
193+
}
194+
],
195+
"source": [
196+
"#Print the docstring\n",
197+
"double.__doc__"
198+
]
199+
},
200+
{
201+
"cell_type": "markdown",
202+
"metadata": {},
203+
"source": [
204+
"-------------"
205+
]
206+
},
207+
{
208+
"cell_type": "markdown",
209+
"metadata": {},
210+
"source": [
211+
"## 5. Indentation\n",
212+
"\n",
213+
"- Most of the programming languages like C, C++, and Java use braces { } to define a block of code. Python, however, uses indentation.\n",
214+
"- A code block (body of a function, loop, etc.) starts with indentation and ends with the first unindented line.\n",
215+
"- The amount of indentation is up to you, but it must be consistent throughout that block."
216+
]
217+
},
218+
{
219+
"cell_type": "code",
220+
"execution_count": 17,
221+
"metadata": {},
222+
"outputs": [
223+
{
224+
"name": "stdout",
225+
"output_type": "stream",
226+
"text": [
227+
"1\n",
228+
"2\n",
229+
"3\n",
230+
"4\n",
231+
"5\n"
232+
]
233+
}
234+
],
235+
"source": [
236+
"#Generally, four whitespaces are used for indentation and are preferred over tabs. Here is an example.\n",
237+
"for i in range(1,11):\n",
238+
" print(i)\n",
239+
" if i == 5:\n",
240+
" break"
241+
]
242+
},
243+
{
244+
"cell_type": "markdown",
245+
"metadata": {},
246+
"source": [
247+
"------------"
248+
]
249+
},
250+
{
251+
"cell_type": "markdown",
252+
"metadata": {},
253+
"source": [
254+
"## 6. Statements\n",
255+
"\n",
256+
"- Instructions that a Python interpreter can execute are called statements.\n",
257+
"- For example, a = 1 is an assignment statement.\n",
258+
"- if statement, for statement, while statement, etc. are other kinds of statements which will be discussed late"
259+
]
260+
},
261+
{
262+
"cell_type": "code",
263+
"execution_count": 18,
264+
"metadata": {},
265+
"outputs": [],
266+
"source": [
267+
"#This is an explicit line continuation. \n",
268+
"#In Python, line continuation is implied inside parentheses ( ), brackets [ ], and braces { }. \n",
269+
"\n",
270+
"#For instance, we can implement the above multi-line statement as:\n",
271+
"a = 1 + 2 + 3 + \\\n",
272+
" 4 + 5 + 6 + \\\n",
273+
" 7 + 8 + 9\n",
274+
"\n",
275+
"#Here, the surrounding parentheses ( ) do the line continuation implicitly. Same is the case with [ ] and { }. For example:\n",
276+
"colors = ['red',\n",
277+
" 'blue',\n",
278+
" 'green']\n",
279+
"\n",
280+
"\n",
281+
"#We can also put multiple statements in a single line using semicolons, as follows:\n",
282+
"a = 1; b = 2; c = 3"
283+
]
284+
},
285+
{
286+
"cell_type": "markdown",
287+
"metadata": {},
288+
"source": [
289+
"----------"
290+
]
291+
},
292+
{
293+
"cell_type": "markdown",
294+
"metadata": {},
295+
"source": [
296+
"**End of Document**"
297+
]
298+
},
299+
{
300+
"cell_type": "code",
301+
"execution_count": null,
302+
"metadata": {},
303+
"outputs": [],
304+
"source": []
305+
}
306+
],
307+
"metadata": {
308+
"kernelspec": {
309+
"display_name": "Python 3",
310+
"language": "python",
311+
"name": "python3"
312+
},
313+
"language_info": {
314+
"codemirror_mode": {
315+
"name": "ipython",
316+
"version": 3
317+
},
318+
"file_extension": ".py",
319+
"mimetype": "text/x-python",
320+
"name": "python",
321+
"nbconvert_exporter": "python",
322+
"pygments_lexer": "ipython3",
323+
"version": "3.8.5"
324+
}
325+
},
326+
"nbformat": 4,
327+
"nbformat_minor": 4
328+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cells": [],
3+
"metadata": {},
4+
"nbformat": 4,
5+
"nbformat_minor": 4
6+
}

‎1. Python_Introduction/.ipynb_checkpoints/Variables_and_Constants-checkpoint.ipynb

+438
Large diffs are not rendered by default.
+328
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,328 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"## 1. Keywords\n",
8+
"\n",
9+
"- Keywords are the reserved words in Python. \n",
10+
"- Think of keywords as some in-built functionality in Python to achieve a particular task.\n",
11+
"- We cannot use a keyword as a variable name, function name, or any other identifier. They are used to define the syntax and structure of the Python language.\n",
12+
"- In Python, keywords are case-sensitive. There are 33 keywords in Python 3.7. This number can vary slightly over the course of time.\n",
13+
"- All the keywords except `True`, `False`, and `None` are in lowercase and they must be written as they are.\n"
14+
]
15+
},
16+
{
17+
"cell_type": "markdown",
18+
"metadata": {},
19+
"source": [
20+
"<img src=\"../img/keywords.png\" alt=\"fishy\" class=\"bg-primary mb-1\">\n",
21+
"<h4><center>List of keywords in Python</center></h4>\n",
22+
"\n",
23+
"-----------"
24+
]
25+
},
26+
{
27+
"cell_type": "markdown",
28+
"metadata": {},
29+
"source": [
30+
"## 2. Identifiers\n",
31+
"\n",
32+
"- An identifier is a name given to entities like class, functions, variables, etc.\n",
33+
"- It helps to differentiate one entity from another.\n",
34+
"\n",
35+
"**Rules for naming identifiers**\n",
36+
"- Python is a case-sensitive language\n",
37+
"- An identifier can be a combination of letters (a/A), digits (0-9) or an underscore(_)\n",
38+
"- An identifier cannot start with a digit\n",
39+
"- Keywords cannot be used as an identifier"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": 4,
45+
"metadata": {},
46+
"outputs": [],
47+
"source": [
48+
"#here name is an identifier as it is used to store a text\n",
49+
"name = \"Ronaldo\"\n",
50+
"\n",
51+
"#here num is an identifier \n",
52+
"num = 23\n",
53+
"\n",
54+
"#list_president is an identifier as it is used to name a list\n",
55+
"list_president = [\"Barack Obama\", \"Donald Trump\", \"Joe Biden\"]"
56+
]
57+
},
58+
{
59+
"cell_type": "markdown",
60+
"metadata": {},
61+
"source": [
62+
"----------"
63+
]
64+
},
65+
{
66+
"cell_type": "markdown",
67+
"metadata": {},
68+
"source": [
69+
"## 3. Comments\n",
70+
"\n",
71+
"- Comments are very important while writing a program. They describe what is going on inside a program, so that a person looking at the source code does not have a hard time figuring it out.\n",
72+
"- You might forget the key details of the program you just wrote in a month's time. So taking the time to explain these concepts in the form of comments is always fruitful.\n",
73+
"- In Python, we use the hash (**#**) symbol to start writing a comment."
74+
]
75+
},
76+
{
77+
"cell_type": "markdown",
78+
"metadata": {},
79+
"source": [
80+
"**Single Line Comment**"
81+
]
82+
},
83+
{
84+
"cell_type": "code",
85+
"execution_count": 13,
86+
"metadata": {},
87+
"outputs": [
88+
{
89+
"name": "stdout",
90+
"output_type": "stream",
91+
"text": [
92+
"Hello\n"
93+
]
94+
}
95+
],
96+
"source": [
97+
"#This is a comment - print out Hello\n",
98+
"print('Hello')"
99+
]
100+
},
101+
{
102+
"cell_type": "markdown",
103+
"metadata": {},
104+
"source": [
105+
"**Multi-Line Comment**"
106+
]
107+
},
108+
{
109+
"cell_type": "code",
110+
"execution_count": 6,
111+
"metadata": {},
112+
"outputs": [],
113+
"source": [
114+
"#This is a long comment\n",
115+
"#and it extends\n",
116+
"#to multiple lines"
117+
]
118+
},
119+
{
120+
"cell_type": "code",
121+
"execution_count": 12,
122+
"metadata": {},
123+
"outputs": [
124+
{
125+
"data": {
126+
"text/plain": [
127+
"'This is also a perfect \\nexample of\\nmulti-line comments'"
128+
]
129+
},
130+
"execution_count": 12,
131+
"metadata": {},
132+
"output_type": "execute_result"
133+
}
134+
],
135+
"source": [
136+
"\"\"\"This is also a perfect \n",
137+
"example of\n",
138+
"multi-line comments\"\"\""
139+
]
140+
},
141+
{
142+
"cell_type": "markdown",
143+
"metadata": {},
144+
"source": [
145+
"----------"
146+
]
147+
},
148+
{
149+
"cell_type": "markdown",
150+
"metadata": {},
151+
"source": [
152+
"## 4. Docstrings\n",
153+
"\n",
154+
"- A docstring is short for documentation string.\n",
155+
"- Python docstrings (documentation strings) are the string literals that appear right after the definition of a function, method, class, or module.\n",
156+
"- Triple quotes are used while writing docstrings. For example:"
157+
]
158+
},
159+
{
160+
"cell_type": "code",
161+
"execution_count": 14,
162+
"metadata": {},
163+
"outputs": [],
164+
"source": [
165+
"def double(num):\n",
166+
" \"\"\"Function to double the value\"\"\"\n",
167+
" return 2*num"
168+
]
169+
},
170+
{
171+
"cell_type": "markdown",
172+
"metadata": {},
173+
"source": [
174+
"- Docstrings appear right after the definition of a function, class, or a module. This separates docstrings from multiline comments using triple quotes.\n",
175+
"- The docstrings are associated with the object as their `__doc__` attribute.\n",
176+
"- So, we can access the docstrings of the above function with the following lines of code:"
177+
]
178+
},
179+
{
180+
"cell_type": "code",
181+
"execution_count": 16,
182+
"metadata": {},
183+
"outputs": [
184+
{
185+
"data": {
186+
"text/plain": [
187+
"'Function to double the value'"
188+
]
189+
},
190+
"execution_count": 16,
191+
"metadata": {},
192+
"output_type": "execute_result"
193+
}
194+
],
195+
"source": [
196+
"#Print the docstring\n",
197+
"double.__doc__"
198+
]
199+
},
200+
{
201+
"cell_type": "markdown",
202+
"metadata": {},
203+
"source": [
204+
"-------------"
205+
]
206+
},
207+
{
208+
"cell_type": "markdown",
209+
"metadata": {},
210+
"source": [
211+
"## 5. Indentation\n",
212+
"\n",
213+
"- Most of the programming languages like C, C++, and Java use braces { } to define a block of code. Python, however, uses indentation.\n",
214+
"- A code block (body of a function, loop, etc.) starts with indentation and ends with the first unindented line.\n",
215+
"- The amount of indentation is up to you, but it must be consistent throughout that block."
216+
]
217+
},
218+
{
219+
"cell_type": "code",
220+
"execution_count": 17,
221+
"metadata": {},
222+
"outputs": [
223+
{
224+
"name": "stdout",
225+
"output_type": "stream",
226+
"text": [
227+
"1\n",
228+
"2\n",
229+
"3\n",
230+
"4\n",
231+
"5\n"
232+
]
233+
}
234+
],
235+
"source": [
236+
"#Generally, four whitespaces are used for indentation and are preferred over tabs. Here is an example.\n",
237+
"for i in range(1,11):\n",
238+
" print(i)\n",
239+
" if i == 5:\n",
240+
" break"
241+
]
242+
},
243+
{
244+
"cell_type": "markdown",
245+
"metadata": {},
246+
"source": [
247+
"------------"
248+
]
249+
},
250+
{
251+
"cell_type": "markdown",
252+
"metadata": {},
253+
"source": [
254+
"## 6. Statements\n",
255+
"\n",
256+
"- Instructions that a Python interpreter can execute are called statements.\n",
257+
"- For example, a = 1 is an assignment statement.\n",
258+
"- if statement, for statement, while statement, etc. are other kinds of statements which will be discussed late"
259+
]
260+
},
261+
{
262+
"cell_type": "code",
263+
"execution_count": 18,
264+
"metadata": {},
265+
"outputs": [],
266+
"source": [
267+
"#This is an explicit line continuation. \n",
268+
"#In Python, line continuation is implied inside parentheses ( ), brackets [ ], and braces { }. \n",
269+
"\n",
270+
"#For instance, we can implement the above multi-line statement as:\n",
271+
"a = 1 + 2 + 3 + \\\n",
272+
" 4 + 5 + 6 + \\\n",
273+
" 7 + 8 + 9\n",
274+
"\n",
275+
"#Here, the surrounding parentheses ( ) do the line continuation implicitly. Same is the case with [ ] and { }. For example:\n",
276+
"colors = ['red',\n",
277+
" 'blue',\n",
278+
" 'green']\n",
279+
"\n",
280+
"\n",
281+
"#We can also put multiple statements in a single line using semicolons, as follows:\n",
282+
"a = 1; b = 2; c = 3"
283+
]
284+
},
285+
{
286+
"cell_type": "markdown",
287+
"metadata": {},
288+
"source": [
289+
"----------"
290+
]
291+
},
292+
{
293+
"cell_type": "markdown",
294+
"metadata": {},
295+
"source": [
296+
"**End of Document**"
297+
]
298+
},
299+
{
300+
"cell_type": "code",
301+
"execution_count": null,
302+
"metadata": {},
303+
"outputs": [],
304+
"source": []
305+
}
306+
],
307+
"metadata": {
308+
"kernelspec": {
309+
"display_name": "Python 3",
310+
"language": "python",
311+
"name": "python3"
312+
},
313+
"language_info": {
314+
"codemirror_mode": {
315+
"name": "ipython",
316+
"version": 3
317+
},
318+
"file_extension": ".py",
319+
"mimetype": "text/x-python",
320+
"name": "python",
321+
"nbconvert_exporter": "python",
322+
"pygments_lexer": "ipython3",
323+
"version": "3.8.5"
324+
}
325+
},
326+
"nbformat": 4,
327+
"nbformat_minor": 4
328+
}

‎1. Python_Introduction/2. Variables_and_Constants.ipynb

+555
Large diffs are not rendered by default.

‎1. Python_Introduction/3. Data_Types.ipynb

+547
Large diffs are not rendered by default.

‎img/keywords.png

34.3 KB
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.