├── .gitignore
├── LICENSE
├── README.md
├── step00_helloworld
├── .idea
│ ├── misc.xml
│ ├── modules.xml
│ ├── step00_helloworld.iml
│ └── workspace.xml
├── hello_world.py
└── readme.md
├── step01_variables
├── .idea
│ ├── misc.xml
│ ├── modules.xml
│ ├── step01_variables.iml
│ └── workspace.xml
├── readme.md
└── variables.py
├── step02_lists
├── .idea
│ ├── misc.xml
│ ├── modules.xml
│ ├── step02_lists.iml
│ └── workspace.xml
├── lists.py
└── readme.md
├── step03_loops
├── .idea
│ ├── misc.xml
│ ├── modules.xml
│ ├── step03_loops.iml
│ └── workspace.xml
├── loops.py
└── readme.md
├── step04_if
├── .idea
│ ├── misc.xml
│ ├── modules.xml
│ ├── step04_if.iml
│ └── workspace.xml
├── if.py
└── readme.md
├── step05(1)_dictionaries
├── dictionaries.py
└── readme.md
├── step05(2)_looping_dictionaries
├── dictionary.py
└── readme.md
├── step06(1)_user_input
├── readme.md
└── user-input.py
├── step06(2)_boolean_while
├── boolean.py
└── readme.md
├── step07(1)_functions
├── functions01.py
└── readme.md
├── step07(2)_functions
├── functions02.py
└── readme.md
├── step08_modules
├── file1.py
├── file2.py
└── readme.md
├── step09_classes
├── classes.py
└── readme.md
├── step10_inheritance
├── inheritance.py
└── readme.md
├── step11_utility_modules
└── utilities.py
└── step12_reading_file
├── pi_digits.txt
└── reading_file.py
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Panacloud
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Learn Python 3 in Baby Steps
2 |
3 | Install Python 3 Anaconda Python Build from:
4 |
5 | https://www.continuum.io/downloads
6 |
7 | Install PyCharm:
8 |
9 | https://www.jetbrains.com/pycharm/download/
10 |
11 |
12 | Setup in PyCharm:
13 |
14 | https://www.youtube.com/watch?v=9kPe8zWefoI
15 |
16 | http://gowrishankarnath.com/installing-anaconda-python-distribution-and-pycharm-ide-to-setup-a-python-development-environment/
17 |
18 |
19 | Our Text Book:
20 | Python Crash Course
21 |
22 | https://www.amazon.com/Python-Crash-Course-Hands-Project-Based-ebook/dp/B018UXJ9RI
23 |
24 | Install PyCharm IDE:
25 | https://www.jetbrains.com/pycharm/download/
26 |
--------------------------------------------------------------------------------
/step00_helloworld/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/step00_helloworld/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/step00_helloworld/.idea/step00_helloworld.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/step00_helloworld/.idea/workspace.xml:
--------------------------------------------------------------------------------
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 |
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 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 | 1462792281868
284 |
285 |
286 | 1462792281868
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
--------------------------------------------------------------------------------
/step00_helloworld/hello_world.py:
--------------------------------------------------------------------------------
1 | print("hello zia")
2 |
--------------------------------------------------------------------------------
/step00_helloworld/readme.md:
--------------------------------------------------------------------------------
1 | Install Python 3 Anaconda Python Build from:
2 |
3 | https://www.continuum.io/downloads
4 |
5 | Install PyCharm:
6 |
7 | https://www.jetbrains.com/pycharm/download/
8 |
9 |
10 | Setup in PyCharm:
11 |
12 | https://www.youtube.com/watch?v=9kPe8zWefoI
13 |
14 | http://gowrishankarnath.com/installing-anaconda-python-distribution-and-pycharm-ide-to-setup-a-python-development-environment/
15 |
16 |
17 | Read:
18 | Chapter 1 of Python Crash Course Book:
19 |
20 | https://www.amazon.com/Python-Crash-Course-Hands-Project-Based-ebook/dp/B018UXJ9RI
21 |
22 | Install PyCharm:
23 | https://www.jetbrains.com/pycharm/download/
24 |
--------------------------------------------------------------------------------
/step01_variables/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/step01_variables/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/step01_variables/.idea/step01_variables.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/step01_variables/.idea/workspace.xml:
--------------------------------------------------------------------------------
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 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 | 1462795205214
291 |
292 |
293 | 1462795205214
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
--------------------------------------------------------------------------------
/step01_variables/readme.md:
--------------------------------------------------------------------------------
1 | Read:
2 |
3 | Chapter 2 of Python Crash Course Book
4 |
5 | https://www.amazon.com/Python-Crash-Course-Hands-Project-Based-ebook/dp/B018UXJ9RI
6 |
--------------------------------------------------------------------------------
/step01_variables/variables.py:
--------------------------------------------------------------------------------
1 | message = "Hello charm"
2 | print(message)
3 |
4 | # called string methods
5 | print(message.title())
6 | print(message.upper())
7 | print(message.lower())
8 |
9 |
10 | myint1 = 7
11 | myint2 = 20
12 | print(myint1 + myint2)
13 |
14 | myfloat1 = 1.5
15 | myfloat2 = 2.5
16 | print(myfloat1 + myfloat2)
17 |
18 | #convert int to str
19 | print("Happy " + str(myint2) + " birthday")
--------------------------------------------------------------------------------
/step02_lists/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/step02_lists/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/step02_lists/.idea/step02_lists.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/step02_lists/.idea/workspace.xml:
--------------------------------------------------------------------------------
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 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 | 1463120499320
291 |
292 |
293 | 1463120499320
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
--------------------------------------------------------------------------------
/step02_lists/lists.py:
--------------------------------------------------------------------------------
1 | friends = ["Zeeshan", "Hira", "Inam", "Rehan", "Taha"]
2 | print(friends)
3 | print(friends[0])
4 | print(friends[-1])#last element
5 |
6 |
7 | friends[0] = "Hanif"
8 | print(friends)
9 |
10 | friends.append("Gulshan")
11 | print(friends)
12 |
13 | friends.insert(3, "Usuf")
14 | print(friends)
15 |
16 | del friends[3]
17 | print(friends)
18 |
19 | last = friends.pop()
20 | print(friends)
21 | print(last)
22 |
23 | first = friends.pop(0)
24 | print(friends)
25 | print(first)
26 |
27 | friends.remove("Inam")
28 | print(friends)
29 |
30 | friends.insert(0, "Inam")
31 | friends.sort()
32 | print(friends)
33 |
34 | friends.insert(0, "Zeeshan")
35 | print(sorted(friends))
36 |
37 | friends.reverse() #reverse the order
38 | print(friends)
39 |
40 | print(len(friends))
--------------------------------------------------------------------------------
/step02_lists/readme.md:
--------------------------------------------------------------------------------
1 | Read:
2 |
3 | Chapter 3 of Python Crash Course Book
4 |
5 | https://www.amazon.com/Python-Crash-Course-Hands-Project-Based-ebook/dp/B018UXJ9RI
6 |
--------------------------------------------------------------------------------
/step03_loops/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/step03_loops/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/step03_loops/.idea/step03_loops.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/step03_loops/.idea/workspace.xml:
--------------------------------------------------------------------------------
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 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 | 1463136860954
291 |
292 |
293 | 1463136860954
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
--------------------------------------------------------------------------------
/step03_loops/loops.py:
--------------------------------------------------------------------------------
1 | friends = ["zia", "zeeshan", "hira", "inam"]
2 |
3 | for friend in friends:
4 | print(friend)
5 | print(".")
6 | print("End of list")
7 |
8 |
9 | for value in range(1, 5):
10 | print(value)
11 |
12 |
13 | numbers = list(range(20,29))
14 | print(numbers)
15 |
16 |
17 | digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
18 | print(min(digits))
19 | print(max(digits))
20 | print(sum(digits))
21 |
22 | #list comprehension
23 | squares = [value**2 for value in range(1,5)]
24 | print(squares)
25 |
26 |
27 | players = ['charles', 'martina', 'michael', 'florence', 'eli']
28 | print(players[0:3]) #slice from index 0 to index 3
29 | print(players[:1]) #slice from 0
30 | print(players[1:]) #slice from 1 index to last
31 | print(players[-2:]) #slice the last two
32 |
33 | for player in players[:3]:
34 | print(player.title())
35 |
36 | copy = players[:]
37 | print(copy)
38 |
39 |
40 | immutable_tuple = (1, 7, 12)
41 | print(immutable_tuple)
--------------------------------------------------------------------------------
/step03_loops/readme.md:
--------------------------------------------------------------------------------
1 | Read:
2 |
3 | Chapter 4 of Python Crash Course Book
4 |
5 | https://www.amazon.com/Python-Crash-Course-Hands-Project-Based-ebook/dp/B018UXJ9RI
6 |
--------------------------------------------------------------------------------
/step04_if/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/step04_if/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/step04_if/.idea/step04_if.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/step04_if/.idea/workspace.xml:
--------------------------------------------------------------------------------
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 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 | 1463152563531
291 |
292 |
293 | 1463152563531
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
--------------------------------------------------------------------------------
/step04_if/if.py:
--------------------------------------------------------------------------------
1 | cars = ['audi', 'bmw', 'subaru', 'toyota']
2 | for car in cars:
3 | if car == 'bmw':
4 | print(car.upper())
5 | else:
6 | print(car.title())
7 |
8 |
9 | age1 = 12
10 | age2 = 20
11 |
12 | if (age1 > 10) and (age2 > 18):
13 | print("all ok")
14 | else:
15 | print("Not ok")
16 |
17 |
18 | if (age1 > 10) or (age2 > 18):
19 | print("all ok")
20 | else:
21 | print("Not ok")
22 |
23 |
24 | friends = ["Zeeshan", "Taha", "Hira", "Rehan", "Inam"]
25 | if "Zeeshan" in friends:
26 | print("Zeeshan is in the list")
27 |
28 | if "Zia" not in friends:
29 | print("Zia is not in the list")
30 |
31 |
32 | age = 19
33 | if age >= 65:
34 | print("old guy")
35 | elif age >= 40:
36 | print("middle age")
37 | elif age >=20:
38 | print("prime")
39 | else:
40 | print("child")
41 |
42 |
43 | foods = []
44 | if foods:
45 | print("list is not empty")
46 | else :
47 | print("list is empty")
--------------------------------------------------------------------------------
/step04_if/readme.md:
--------------------------------------------------------------------------------
1 | Read:
2 |
3 | Chapter 5 of Python Crash Course Book
4 |
5 | https://www.amazon.com/Python-Crash-Course-Hands-Project-Based-ebook/dp/B018UXJ9RI
6 |
--------------------------------------------------------------------------------
/step05(1)_dictionaries/dictionaries.py:
--------------------------------------------------------------------------------
1 | best_languages = {"ml": "python", "web": "javascript", "enterprise": "java", "webassembly": "rust"}
2 | print(best_languages)
3 | print(best_languages["ml"])
4 |
5 | best_languages["datascience"] = "R"
6 | print(best_languages)
7 |
8 | del best_languages["datascience"]
9 | print(best_languages)
10 |
11 | for key, value in best_languages.items():
12 | print(key)
--------------------------------------------------------------------------------
/step05(1)_dictionaries/readme.md:
--------------------------------------------------------------------------------
1 | Read:
2 |
3 | Chapter 6 of Python Crash Course Book
4 |
5 | https://www.amazon.com/Python-Crash-Course-Hands-Project-Based-ebook/dp/B018UXJ9RI
6 |
--------------------------------------------------------------------------------
/step05(2)_looping_dictionaries/dictionary.py:
--------------------------------------------------------------------------------
1 | alien_0 = {"speed": "slow", "x_position": 0}
2 | alien_1 = {"speed": "medium", "x_position": 0}
3 | alien_2 = {"speed": "fast", "x_position": 0}
4 | Aliens = [alien_0, alien_1, alien_2]
5 | x_increment = 0
6 |
7 | for item in Aliens:
8 | if item['speed'] == 'slow':
9 | x_increment = 1
10 | item['x_position'] = x_increment
11 | print('slow one')
12 | elif item['speed'] == 'medium':
13 | x_increment = 2
14 | item['x_position'] = x_increment
15 | print('medium one')
16 | else:
17 | x_increment = 3
18 | item['x_position'] = x_increment
19 | print('fast one')
20 |
21 | print(Aliens)
22 |
--------------------------------------------------------------------------------
/step05(2)_looping_dictionaries/readme.md:
--------------------------------------------------------------------------------
1 | Read:
2 |
3 | Chapter 6 of Python Crash Course Book
4 |
5 | https://www.amazon.com/Python-Crash-Course-Hands-Project-Based-ebook/dp/B018UXJ9RI
6 |
--------------------------------------------------------------------------------
/step06(1)_user_input/readme.md:
--------------------------------------------------------------------------------
1 | Read:
2 |
3 | Chapter 7 of Python Crash Course Book
4 |
5 | https://www.amazon.com/Python-Crash-Course-Hands-Project-Based-ebook/dp/B018UXJ9RI
6 |
--------------------------------------------------------------------------------
/step06(1)_user_input/user-input.py:
--------------------------------------------------------------------------------
1 | # name = input("Please enter your name: ")
2 | # print("Hello, " + name + "!") # Hello Hammad
3 |
4 | prompt = "Welcome to SMU"
5 | prompt += "\nWhat is your name? " # concatenating strings
6 | name = input(prompt)
7 | print("\nHello, " + name.title() + "!")
8 |
9 |
10 | marks = input("Enter your English marks out of 100:\n")
11 | marks = int(marks) # converting string value in integer value
12 |
13 | if (marks >= 0) and (marks <= 59):
14 | print("Failed")
15 | elif (marks >= 60) and (marks <= 70):
16 | print("B Grade")
17 | elif (marks >= 71) and (marks <= 80):
18 | print("A Grade")
19 | elif (marks >= 81) and (marks <= 100):
20 | print("A-one Grade")
21 | else:
22 | print("Wrong Input")
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/step06(2)_boolean_while/boolean.py:
--------------------------------------------------------------------------------
1 | total_students = 10
2 | students_arr = []
3 | is_present = False # we assign boolean value in capitalize form
4 | index = 0
5 |
6 |
7 | # make students array of dictionaries
8 | while index <= 10:
9 | students_arr.append({"name": "student" + str(index), "present": is_present})
10 | index = index + 1
11 | print(students_arr)
12 |
13 |
14 | # take attendance
15 | student_no = 0
16 | print("Write yes or no if your name is called\n ")
17 | while student_no <= total_students:
18 |
19 | answer = input("student" + str(student_no) + " present?\n")
20 | print("student answer: " + answer)
21 | if answer.lower() == "yes":
22 | students_arr[student_no]["present"] = True
23 | student_no = student_no + 1 #incrementing loop
24 | elif answer.lower() == "no":
25 | students_arr[student_no]["present"] = False
26 | student_no = student_no + 1 #incrementing loop
27 | else:
28 | print("Wrong Input")
29 |
30 | # print result
31 | print("\nAttendence completed!")
32 | print("Students Array \n" + str(students_arr))
--------------------------------------------------------------------------------
/step06(2)_boolean_while/readme.md:
--------------------------------------------------------------------------------
1 | Read:
2 |
3 | Chapter 7 of Python Crash Course Book
4 |
5 | https://www.amazon.com/Python-Crash-Course-Hands-Project-Based-ebook/dp/B018UXJ9RI
6 |
--------------------------------------------------------------------------------
/step07(1)_functions/functions01.py:
--------------------------------------------------------------------------------
1 | def greet_user(user):
2 | print("Hello "+str(user)+"!")
3 | greet_user("Hammad")
4 |
5 |
6 | # arrangement of arguments matter so don't mix them up
7 | def greet_user_fullname(firstname,lastname):
8 | print("Hello "+firstname+" "+lastname)
9 | greet_user_fullname("Hammad","Tariq")
10 |
11 |
12 | # arrangement of params doesn't matter if value assign explicitly
13 | def user_dob(day, month, year):
14 | return str(day)+':'+str(month)+":"+str(year)
15 | birthday = user_dob(day=22, year=1993, month='April')
16 | print(birthday) # prints 22:April:1993
17 |
18 |
19 | # explicitly assigning values to function argument
20 | def greet_user_fullname2(firstname,lastname):
21 | print("Hello "+firstname+" "+lastname)
22 | greet_user_fullname2(firstname="Hammad", lastname="Tariq") # use same names of parameters in the function’s definition.
23 |
24 |
25 | # add optional param by assigning it an empty string.
26 | # optional param can only be listed last in the definition.
27 | def get_formatted_name(first_name, last_name, middle_name=''):
28 | if middle_name:
29 | full_name = first_name + ' ' + middle_name + ' ' + last_name
30 | else:
31 | full_name = first_name + ' ' + last_name
32 | return full_name.title()
33 | fullname = get_formatted_name('hammad', 'tariq')
34 | print(fullname)
35 |
36 |
37 |
--------------------------------------------------------------------------------
/step07(1)_functions/readme.md:
--------------------------------------------------------------------------------
1 | Read:
2 |
3 | Chapter 8 of Python Crash Course Book
4 |
5 | https://www.amazon.com/Python-Crash-Course-Hands-Project-Based-ebook/dp/B018UXJ9RI
6 |
--------------------------------------------------------------------------------
/step07(2)_functions/functions02.py:
--------------------------------------------------------------------------------
1 | # Passing an arbitrary number of arguments
2 | def make_pizza(*toppings):
3 | print(toppings) # print list of arguments
4 | make_pizza('mushrooms', 'green peppers', 'extra cheese')
5 |
6 |
7 | # Preventing a function from modifying original List
8 | num_list = [0, 1, 2, 3, 4]
9 |
10 |
11 | def change_list(my_list):
12 | my_list.append("new element")
13 | print("list from function: "+str(my_list))
14 | change_list(num_list[:]) # passing the copy of the list
15 |
16 | print("original list: "+str(num_list))
17 |
18 |
19 | def build_profile(first, last, **user_info): # double asterisks create an empty dictionary called user_info
20 | profile = {}
21 | profile['first_name'] = first
22 | profile['last_name'] = last
23 | for key, value in user_info.items():
24 | profile[key] = value # explicitly adding properties to my dictionary
25 | return profile
26 | user_profile = build_profile('hammad', 'tariq', location='karachi', field='computer science')
27 | print(user_profile)
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/step07(2)_functions/readme.md:
--------------------------------------------------------------------------------
1 | Read:
2 |
3 | Chapter 8 of Python Crash Course Book
4 |
5 | https://www.amazon.com/Python-Crash-Course-Hands-Project-Based-ebook/dp/B018UXJ9RI
6 |
--------------------------------------------------------------------------------
/step08_modules/file1.py:
--------------------------------------------------------------------------------
1 | def user_name(name):
2 | return name.title()
3 |
4 |
5 | def user_dob(day, month, year):
6 | return str(day)+':'+str(month)+":"+str(year)
7 |
8 |
--------------------------------------------------------------------------------
/step08_modules/file2.py:
--------------------------------------------------------------------------------
1 | # Importing an entire module
2 | import file1
3 |
4 | print(file1.user_name('hammad'))
5 | print(file1.user_dob(day=22, year=1993, month='April'))
6 |
7 |
8 | # Using as to give a Module an Alias
9 | import file1 as my_user
10 |
11 | print(my_user.user_name('hammad'))
12 | print(my_user.user_dob(day=22, year=1993, month='April'))
13 |
14 |
15 | # Importing specific functions
16 | from file1 import user_name, user_dob
17 |
18 | print(user_name('hammad'))
19 | print(user_dob(day=22, year=1993, month='April'))
20 |
21 |
22 | # Using as to give a Function an Alias
23 | from file1 import user_name as u_name, user_dob as u_dob
24 |
25 | print(u_name('hammad'))
26 | print(u_dob(day=22, year=1993, month='April'))
27 |
28 |
29 | # importing all functions
30 | from file1 import *
31 |
32 | print(file1.user_name('hammad'))
33 | print(file1.user_dob(day=22, year=1993, month='April'))
34 |
--------------------------------------------------------------------------------
/step08_modules/readme.md:
--------------------------------------------------------------------------------
1 | Read:
2 |
3 | Chapter 8 of Python Crash Course Book
4 |
5 | https://www.amazon.com/Python-Crash-Course-Hands-Project-Based-ebook/dp/B018UXJ9RI
6 |
--------------------------------------------------------------------------------
/step09_classes/classes.py:
--------------------------------------------------------------------------------
1 |
2 | class Restaurant: # python 2.7 class syntax has object in param e.g "Restaurant(object)"
3 |
4 | # passing self is necessary as first param in functions to access properties of class
5 | # self is equivalent to "this"
6 |
7 | def __init__(self, restaurant_name, cuisine_type): # creating a constructor function
8 | self.restaurant_name = restaurant_name
9 | self.cuisine_type = cuisine_type
10 |
11 | def restaurant_open(self): # methods declaration
12 | print(self.restaurant_name.title()+' is open')
13 |
14 | def restaurant_close(self):
15 | print(self.restaurant_name.title() + ' is close')
16 |
17 |
18 | my_restaurant1 = Restaurant('ginsoy', 'chinese')
19 | my_restaurant2 = Restaurant('burger lab', 'fast food')
20 |
21 | print('instance 1')
22 | print(my_restaurant1.restaurant_open()) # use dot attrib to access properties or methods
23 |
24 | print('instance 2')
25 | print(my_restaurant2.restaurant_close())
26 |
--------------------------------------------------------------------------------
/step09_classes/readme.md:
--------------------------------------------------------------------------------
1 | Read:
2 |
3 | Chapter 9 of Python Crash Course Book
4 |
5 | https://www.amazon.com/Python-Crash-Course-Hands-Project-Based-ebook/dp/B018UXJ9RI
6 |
--------------------------------------------------------------------------------
/step10_inheritance/inheritance.py:
--------------------------------------------------------------------------------
1 | class Animal:
2 |
3 | def __init__(self, name, color):
4 | self.name = name
5 | self.color = color
6 |
7 | def walk(self):
8 | print(self.name+' is walking')
9 |
10 | def eat(self):
11 | print(self.name+' is eating')
12 |
13 |
14 | class Snake(Animal): # creating a child class using inheritance
15 |
16 | def __init__(self, name, color):
17 | super().__init__(name, color) # making connection with parent class
18 |
19 | def walk(self):
20 | print(self.name+' is slithering')
21 |
22 |
23 | my_snake = Snake('Python', 'yellow')
24 |
25 | my_snake.walk() # called from child class
26 | my_snake.eat() # called from parent class
27 |
--------------------------------------------------------------------------------
/step10_inheritance/readme.md:
--------------------------------------------------------------------------------
1 | Read:
2 |
3 | Chapter 9 of Python Crash Course Book
4 |
5 | https://www.amazon.com/Python-Crash-Course-Hands-Project-Based-ebook/dp/B018UXJ9RI
6 |
--------------------------------------------------------------------------------
/step11_utility_modules/utilities.py:
--------------------------------------------------------------------------------
1 | from random import randint
2 | from collections import OrderedDict
3 |
4 | # from collections module
5 | my_dict = OrderedDict() # provide ordered dictionary
6 | my_dict['name'] = 'hammad'
7 | my_dict['gender'] = 'male'
8 | my_dict['age'] = 23
9 | print(my_dict)
10 |
11 |
12 | # from random module
13 | x = randint(1, 9) # random number generator
14 | print(x)
15 |
--------------------------------------------------------------------------------
/step12_reading_file/pi_digits.txt:
--------------------------------------------------------------------------------
1 | i love Pakistan and i love Cricket
--------------------------------------------------------------------------------
/step12_reading_file/reading_file.py:
--------------------------------------------------------------------------------
1 |
2 | file_path = 'step12_reading_file\pi_digits.txt'
3 |
4 | with open(file_path, 'w') as file_object: # overwrite current content
5 | file_object.write("i love Pakistan")
6 |
7 |
8 | with open(file_path, 'a') as file_object: # append new content
9 | file_object.write(" and i love Cricket")
10 |
11 |
12 | with open(file_path, 'r') as file_object:
13 | # contents = file_object.read() # reads content of file char by char
14 | lines = file_object.readlines() # reads content line by line
15 |
16 | for line in lines:
17 | line = line.replace('i', 'I')
18 | print(line.rstrip()) # rstrip() method removes white spaces
--------------------------------------------------------------------------------