├── .ipynb_checkpoints
├── CE103-Figures-checkpoint.drawio
├── CE103-Week00-Info-checkpoint.ipynb
├── CE103-Week01-checkpoint.ipynb
├── CE103-Week02-checkpoint.ipynb
├── CE103-Week03-checkpoint.ipynb
├── CE103-Week04-checkpoint.ipynb
├── CE103-Week05-checkpoint.ipynb
├── CE103-Week06-checkpoint.ipynb
├── CE103-Week07-checkpoint.ipynb
├── CE103-Week08-checkpoint.ipynb
├── CE103-Week09-checkpoint.ipynb
├── CE103-Week10-checkpoint.ipynb
├── CE103-Week11-checkpoint.ipynb
├── CE103-Week12-checkpoint.ipynb
├── CE103-Week13-checkpoint.ipynb
├── CE103-Week14-checkpoint.ipynb
└── README-checkpoint.md
├── CE103-Figures.drawio
├── CE103-Week00-Info.ipynb
├── CE103-Week01.ipynb
├── CE103-Week02.ipynb
├── CE103-Week03.ipynb
├── CE103-Week04.ipynb
├── CE103-Week05.ipynb
├── CE103-Week06.ipynb
├── CE103-Week07.ipynb
├── CE103-Week08.ipynb
├── CE103-Week09.ipynb
├── CE103-Week10.ipynb
├── CE103-Week11.ipynb
├── CE103-Week12.ipynb
├── CE103-Week13.ipynb
├── CE103-Week14.ipynb
├── Data_Input
├── .ipynb_checkpoints
│ ├── Hello-checkpoint.txt
│ ├── Kusma-GyadiBridge_Nepal-checkpoint.png
│ ├── civil_abb-checkpoint.txt
│ ├── class-checkpoint.json
│ ├── eventlist-checkpoint.json
│ ├── filename-checkpoint
│ ├── merged-checkpoint.txt
│ ├── tuik-checkpoint.csv
│ ├── tuik_new-checkpoint.csv
│ └── write-checkpoint.txt
├── Hello.txt
├── Kusma-GyadiBridge_Nepal.png
├── ZipDir.zip
├── ZipDir
│ └── pic.png
├── aaa.xlsx
├── civil_abb.txt
├── civil_abb_out.csv
├── civil_abb_out.json
├── class.json
├── eventlist.json
├── filename
├── merged
├── merged.txt
├── narrow.zip
├── sales.xlsx
├── tuik.csv
├── tuik.xlsx
├── tuik_new.csv
└── write.txt
├── Examples
├── .ipynb_checkpoints
│ └── example-checkpoint.py
└── example.py
├── Figures
├── .ipynb_checkpoints
│ ├── algorithm2-checkpoint.png
│ ├── grading-checkpoint.png
│ ├── slope-int-checkpoint.png
│ └── travel-time-checkpoint.png
├── 3d-array.png
├── GTU_LOGO_1200X768_JPG_EN.jpg
├── GTU_LOGO_1200X768_JPG_EN_Small.jpg
├── Z_TravelTimeCurve.mp4
├── algorithm.png
├── algorithm2.png
├── arithmetic-operators.png
├── array-sum.png
├── array.png
├── array_vs_list.png
├── assignmentoparetor.png
├── blackwidow.jpg
├── captainamerica.jpg
├── class.png
├── color.png
├── comparisonoperator.png
├── def_func.png
├── earth-dist.png
├── elif-else-statement.png
├── error-messages.pdf
├── figure-exp.png
├── for-loop.png
├── grading.png
├── grading2.jpg
├── guido.png
├── homework10.png
├── hulk.jpg
├── hw6_screenshot.png
├── hw6_screenshot2.png
├── hw7-ibb.png
├── hw7.png
├── hw_11.png
├── hw_11_2.png
├── if-else-statement.png
├── if-statement.png
├── inclass_II.png
├── ironman.png
├── ironman2.jpg
├── keywords.png
├── lin-reg-fig.png
├── lin-reg-formula.png
├── plaka.jpg
├── regression-curve.png
├── scipy-submodules.png
├── sensorrecord.png
├── slope-int.png
├── spoon.jpg
├── string-sequence.png
├── subplot.png
├── swinging_arm.png
├── travel-time.png
└── while-loop.png
└── README.md
/.ipynb_checkpoints/CE103-Figures-checkpoint.drawio:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/.ipynb_checkpoints/CE103-Week00-Info-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "\n",
8 | "\n",
9 | "## GEBZE TECHNICAL UNIVERSITY - DEPARTMENT OF CIVIL ENGINEERING\n",
10 | "\n",
11 | "### CE 103 Introduction to Computers and Programming \n",
12 | "##### _2019-2020 Spring_\n",
13 | "\n",
14 | "This lecture meant to serve as an introduction to the Python programming for Civil Engineering undergraduate students. It has enriched content with solved examples based on specific Civil Engineering problems.\n",
15 | "\n",
16 | "---\n",
17 | "### Instructor : \n",
18 | "##### Dr. Ahu Kömeç Mutlu --> _ahumutlu@gtu.edu.tr_\n",
19 | "\n",
20 | "---\n",
21 | "### Teaching Assistants :\n",
22 | "##### Fırat Bezir --> _fbezir@gtu.edu.tr_\n",
23 | "\n",
24 | "##### Sezgin Sarak --> _sezginsarak@gtu.edu.tr_\n",
25 | "\n",
26 | "---\n",
27 | "\n",
28 | "### Textbook and Resources :\n",
29 | "_Introduction to Python for Science and Engineering, David J. Pine, CRC Press, 2019._\n",
30 | "\n",
31 | "_https://docs.python.org/3/tutorial/index.html_\n",
32 | "\n",
33 | "_https://docs.python.org/3/reference/index.html_\n",
34 | "\n",
35 | "---\n"
36 | ]
37 | },
38 | {
39 | "cell_type": "markdown",
40 | "metadata": {},
41 | "source": [
42 | "## Grading and Attendance\n",
43 | ""
44 | ]
45 | },
46 | {
47 | "cell_type": "markdown",
48 | "metadata": {},
49 | "source": [
50 | "## Syllabus\n",
51 | "-\n",
52 | "\n",
53 | "\n",
54 | "**Week 1 Theory :** Introduction to Python, launching Python, learning Github, Azure and Algorithm\n",
55 | "\n",
56 | "**Week 1 Lab :** Github - Jupyter settings \n",
57 | "\n",
58 | "---\n",
59 | "**Week 2 Theory :** Strings, Lists, Arrays and Dictionaries\n",
60 | "\n",
61 | "**Week 2 Lab :** _Coding applications_\n",
62 | "\n",
63 | "---\n",
64 | "**Week 3 Theory :** Numerical Routines NumPy\n",
65 | "\n",
66 | "**Wek 3 Lab :** _Coding applications_\n",
67 | "\n",
68 | "---\n",
69 | "**Week 4 Theory :** Conditionals ad Loops\n",
70 | "\n",
71 | "**Week 4 Lab :** _Coding applications_\n",
72 | "\n",
73 | "---\n",
74 | "**Week 5 Theory :** Plotting\n",
75 | "\n",
76 | "**Week 5 Lab :** _Coding applications_\n",
77 | "\n",
78 | "---\n",
79 | "**Week 6 Theory :** Functions\n",
80 | "\n",
81 | "**Week 6 Lab :** _Coding applications_\n",
82 | "\n",
83 | "---\n",
84 | "**Week 7 Theory :** Curve Fitting\n",
85 | "\n",
86 | "**Week 7 Lab :** _Coding applications_\n",
87 | "\n",
88 | "---\n",
89 | "**Week 8 Theory :** Numerical Routines SciPy\n",
90 | "\n",
91 | "**Week 8 Lab :** _Coding applications_\n",
92 | "\n",
93 | "---\n",
94 | "**Week 9 Theory :** File input and output\n",
95 | "\n",
96 | "**Week 9 Lab :** _Coding applications_\n",
97 | "\n",
98 | "---\n",
99 | "**Week 10 Theory :** Data manipulation and Analysis Pandas\n",
100 | "\n",
101 | "**Week 10 Lab :** _Coding applications_\n",
102 | "\n",
103 | "---\n",
104 | "**Week 11 Theory :** Getting Data from the Web\n",
105 | "\n",
106 | "**Week 11 Lab :** _Coding applications_\n",
107 | "\n",
108 | "---\n",
109 | "**Week 12 Theory :** Python Classes\n",
110 | "\n",
111 | "**Week 12 Lab :** _Coding applications_\n",
112 | "\n",
113 | "---\n",
114 | "**Week 13 Theory :** InClass Project - I \n",
115 | "\n",
116 | "**Week 13 Lab :** _Coding applications_\n",
117 | "\n",
118 | "---\n",
119 | "**Week 14 Theory :** InClass Project - II\n",
120 | "\n",
121 | "**Week 14 Lab :** _Coding applications_\n",
122 | "\n",
123 | "---\n",
124 | "**Week 15 Theory :** No class\n",
125 | "\n",
126 | "---\n",
127 | "**Week 16 Theory :** Final Exam\n",
128 | "\n",
129 | "---"
130 | ]
131 | },
132 | {
133 | "cell_type": "code",
134 | "execution_count": null,
135 | "metadata": {},
136 | "outputs": [],
137 | "source": []
138 | }
139 | ],
140 | "metadata": {
141 | "kernelspec": {
142 | "display_name": "Python 3",
143 | "language": "python",
144 | "name": "python3"
145 | },
146 | "language_info": {
147 | "codemirror_mode": {
148 | "name": "ipython",
149 | "version": 3
150 | },
151 | "file_extension": ".py",
152 | "mimetype": "text/x-python",
153 | "name": "python",
154 | "nbconvert_exporter": "python",
155 | "pygments_lexer": "ipython3",
156 | "version": "3.6.8"
157 | }
158 | },
159 | "nbformat": 4,
160 | "nbformat_minor": 4
161 | }
162 |
--------------------------------------------------------------------------------
/.ipynb_checkpoints/CE103-Week01-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### CE 103- INTRODUCTION TO COMPUTERS and PROGRAMMING"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "### _The topics of the week !_\n",
15 | "\n",
16 | "- Programming Algorithm\n",
17 | "- Launching Python, Variable, List\n",
18 | "- Interactive Python as a Calculator\n",
19 | "- Homework #1 assignment"
20 | ]
21 | },
22 | {
23 | "cell_type": "markdown",
24 | "metadata": {},
25 | "source": [
26 | "---\n",
27 | "## Programming Algorithm\n",
28 | "\n",
29 | "Algorithms tell the programmers how to code the program. It is important editting to a strong algorithm than coding a program. Flowchart represents a diagram that graphically depicts the steps in a program.An algorithm steps basically be like as below.\n",
30 | "\n",
31 | " \n",
32 | "\n",
33 | "Figure 1 : Flowchart diagram of basic programming seps. Ovals are terminal symbols, Parallelograms are input and output symbols, Rectangles are processing symbols, Symbols are connected by arrows that represent the flow of the program, Statements in a program execute in the order that they appear\n",
34 | "\n",
35 | "\n",
36 | "### Typical steps of programming:\n",
37 | "\n",
38 | ">Design the program\n",
39 | "\n",
40 | ">>Write the code\n",
41 | "\n",
42 | ">>>Correct syntax errors\n",
43 | "\n",
44 | ">>>>Test the program\n",
45 | "\n",
46 | ">>>>>Correct logic errors"
47 | ]
48 | },
49 | {
50 | "cell_type": "markdown",
51 | "metadata": {},
52 | "source": [
53 | "---\n",
54 | "## Introduction to Python\n",
55 | "\n",
56 | "Python is a open source general-purpose programming language. It is available across many platforms including Windows, Linux and Mac OS.\n",
57 | "\n",
58 | "The history of the Python programming language dates back to the late 1980s and its implementation was started in December 1989 by Guido van Rossum. \n",
59 | "\n",
60 | "The version of Python (i.e., Python 1.0) was introduced in 1991 and its eveluation has reached up to Version 3.x (till 2019).\n",
61 | "\n",
62 | "\n",
63 | "Figure 2 : Photograph of Guido van Rossum—Creator. (Image courtesy of Wikipedia.org)."
64 | ]
65 | },
66 | {
67 | "cell_type": "markdown",
68 | "metadata": {},
69 | "source": [
70 | "---\n",
71 | "## Scientific Tools of Python\n",
72 | "\n",
73 | "The Python ecosystem consists of these core scientific tools which are essential for analysing and simulating complex systems, these packages are SciPy library,SciPy, NumPy, Sympy and Matplotlib. **SciPy** library is mainly used for numerical integration and optimization. **NumPy** provides N-dimensional array objects which can be used to perform linear algebra, Fourier transform and other mathematical operations. **SymPy** library is used to generate symbolic mathematics. **Matplotlib** is the oldest and most popular plotting library available for Python. These tools are usefull for solving scientific problems.\n"
74 | ]
75 | },
76 | {
77 | "cell_type": "markdown",
78 | "metadata": {},
79 | "source": [
80 | "---\n",
81 | "## Launching Python \n",
82 | "\n"
83 | ]
84 | },
85 | {
86 | "cell_type": "markdown",
87 | "metadata": {},
88 | "source": [
89 | "There are several interfaces that allows us to use Python interactively. IPython, jupyter notebooks, anaconda spyder are some of them. But in this lecture we will use notebook.azure.com.\n",
90 | "\n",
91 | "You do not have to install Python on to your computer, all you need is internet accesss. "
92 | ]
93 | },
94 | {
95 | "cell_type": "markdown",
96 | "metadata": {},
97 | "source": [
98 | "---\n",
99 | "## Installing and Using Jupyter Notebook\n",
100 | "Jupyter Notebook is an open source web application that uses a browserbased interface and it is one of the many possible ways to interact with Python and the scientific libraries. \n",
101 | "\n",
102 | "You can :\n",
103 | "\n",
104 | "• create and share documents,\n",
105 | "\n",
106 | "• write and execute Python code,\n",
107 | "\n",
108 | "• include tables, figures, equation, visualizations, etc. with Jupyter which is fast processor in the scientific computing algorithms."
109 | ]
110 | },
111 | {
112 | "cell_type": "markdown",
113 | "metadata": {},
114 | "source": [
115 | "---\n",
116 | "## Python Programming Fundamentals\n",
117 | "\n",
118 | "Lets discuss the fundamentals of Python Programming language that we need to know to start writing basic Python codes. These are identifiers, keywords, variables and operators.\n",
119 | "\n",
120 | "### Identifiers\n",
121 | "An identifier is a name given to a variable, function, class or module. Here are the rules that we should know to set an identifier.\n",
122 | "\n",
123 | "• Can begin with an alphabet (A – Z and a – z and _) and be a combination of lowercase or uppercase or digits.\n",
124 | "\n",
125 | "• Do not start with a digit but can used in anywhere else such as legend1 can allow but 1legend is invalid.\n",
126 | "\n",
127 | "• Keywords cannot be used as identifiers.\n",
128 | "\n",
129 | "• Do not use spaces and special symbols like !, @, #, $, % etc. as identifiers.\n",
130 | "\n",
131 | "• Identifier can be of any length.\n",
132 | "\n",
133 | "### Keywords\n",
134 | "\n",
135 | "Keywords are a list of reserved words that have predefined meaning. They are special vocabulary and should not be use as an identifier name which will cause an error.\n",
136 | "\n",
137 | "\n",
138 | "\n",
139 | "### Variables\n",
140 | "\n",
141 | "Variable is a placeholder to hold any type of data.\n",
142 | "\n",
143 | "• Can consist of any number of letters, underscores and digits.\n",
144 | "\n",
145 | "• Should not start with a number.\n",
146 | "\n",
147 | "• Keywords are not assigned as variables\n",
148 | "\n",
149 | "• They are case-sensitive.\n",
150 | "\n",
151 | "***variable_name = expression***\n"
152 | ]
153 | },
154 | {
155 | "cell_type": "code",
156 | "execution_count": null,
157 | "metadata": {},
158 | "outputs": [],
159 | "source": [
160 | "# set a variable name\n",
161 | "number = 3\n",
162 | "road = \"D100\"\n",
163 | "name = 'Python'\n",
164 | "century = \"hundred\"\n",
165 | "\n",
166 | "# print them on to the screen\n",
167 | "number, road, name, century"
168 | ]
169 | },
170 | {
171 | "cell_type": "markdown",
172 | "metadata": {},
173 | "source": [
174 | "You can assign a single value to several variables simultaneously."
175 | ]
176 | },
177 | {
178 | "cell_type": "code",
179 | "execution_count": null,
180 | "metadata": {},
181 | "outputs": [],
182 | "source": [
183 | "a = b = c = 4\n",
184 | "a, b, c"
185 | ]
186 | },
187 | {
188 | "cell_type": "markdown",
189 | "metadata": {},
190 | "source": [
191 | "---\n",
192 | "### Operators\n",
193 | "\n",
194 | "Operators are symbols, such as +, –, =, >, and <. Python allows you to perform mathematical or logical operations to manipulate data values. and produce a result based on some rules.\n",
195 | "\n",
196 | "Python language supports a wide range of operators. \n",
197 | "\n",
198 | "\n",
199 | "#### 1. Arithmetic Operators\n",
200 | "\n",
201 | "\n",
202 | "Arithmetic operators are used to execute arithmetic operations such as addition, subtraction, division, multiplication etc.\n",
203 | "\n",
204 | " "
205 | ]
206 | },
207 | {
208 | "cell_type": "code",
209 | "execution_count": null,
210 | "metadata": {},
211 | "outputs": [],
212 | "source": [
213 | " 4 + 5"
214 | ]
215 | },
216 | {
217 | "cell_type": "code",
218 | "execution_count": null,
219 | "metadata": {},
220 | "outputs": [],
221 | "source": [
222 | "a = 3\n",
223 | "b = 5 \n",
224 | "c = 7\n",
225 | "\n",
226 | "a + b * c"
227 | ]
228 | },
229 | {
230 | "cell_type": "code",
231 | "execution_count": null,
232 | "metadata": {},
233 | "outputs": [],
234 | "source": [
235 | "# find answer of the equations below\n",
236 | "\n",
237 | "apple = a ** b\n",
238 | "orange = a / b * c + 3\n",
239 | "d = apple // orange\n",
240 | "\n",
241 | "apple, orange, d"
242 | ]
243 | },
244 | {
245 | "cell_type": "code",
246 | "execution_count": null,
247 | "metadata": {},
248 | "outputs": [],
249 | "source": [
250 | "# find the remainder of the \"apple/orange\"\n",
251 | "\n"
252 | ]
253 | },
254 | {
255 | "cell_type": "markdown",
256 | "metadata": {},
257 | "source": [
258 | "#### 2. Assignment Operators\n",
259 | "\n",
260 | "Assignment operators are used for assigning the values to a variable.\n",
261 | "\n"
262 | ]
263 | },
264 | {
265 | "cell_type": "code",
266 | "execution_count": null,
267 | "metadata": {},
268 | "outputs": [],
269 | "source": [
270 | "x = 5\n",
271 | "y = 8\n",
272 | "x + y"
273 | ]
274 | },
275 | {
276 | "cell_type": "markdown",
277 | "metadata": {},
278 | "source": [
279 | ""
280 | ]
281 | },
282 | {
283 | "cell_type": "code",
284 | "execution_count": null,
285 | "metadata": {},
286 | "outputs": [],
287 | "source": [
288 | "# run the operator below and recognize how x changec in each run\n",
289 | "x += 1\n",
290 | "x\n"
291 | ]
292 | },
293 | {
294 | "cell_type": "markdown",
295 | "metadata": {},
296 | "source": [
297 | "#### 3. Comparison Operators\n",
298 | "\n",
299 | "They are used to compare the values of two operands and output is always a Boolean value, either True or False\n",
300 | "\n",
301 | ""
302 | ]
303 | },
304 | {
305 | "cell_type": "code",
306 | "execution_count": null,
307 | "metadata": {},
308 | "outputs": [],
309 | "source": [
310 | "5 == 7"
311 | ]
312 | },
313 | {
314 | "cell_type": "markdown",
315 | "metadata": {},
316 | "source": [
317 | "---\n",
318 | "## Data Types\n",
319 | "\n",
320 | "Definition of the data type classifies and categorize data items. Its a way to understand which kind of value determines what operatoins can be performed. Different types of variable can do different things.\n",
321 | "\n",
322 | " - int (integers) (ex: 5,98,28829382983) \n",
323 | " - float (real numbers) (ex: 3.7)\n",
324 | " - bool (boolean values) (True or False)\n",
325 | " - NoneType (special) (None; has one value)\n",
326 | "\n",
327 | "You can check the type of your ariable by clling \"type\" command. Python allows you to convert your data from one type to another. "
328 | ]
329 | },
330 | {
331 | "cell_type": "code",
332 | "execution_count": null,
333 | "metadata": {},
334 | "outputs": [],
335 | "source": [
336 | "type(3)"
337 | ]
338 | },
339 | {
340 | "cell_type": "code",
341 | "execution_count": null,
342 | "metadata": {},
343 | "outputs": [],
344 | "source": [
345 | "type('hi')"
346 | ]
347 | },
348 | {
349 | "cell_type": "code",
350 | "execution_count": null,
351 | "metadata": {},
352 | "outputs": [],
353 | "source": [
354 | "# type conversion\n",
355 | "float(5)"
356 | ]
357 | },
358 | {
359 | "cell_type": "code",
360 | "execution_count": null,
361 | "metadata": {},
362 | "outputs": [],
363 | "source": [
364 | "# type conversion\n",
365 | "int(3.1)"
366 | ]
367 | },
368 | {
369 | "cell_type": "markdown",
370 | "metadata": {},
371 | "source": [
372 | "Lets go in detail with the basic data types below;\n",
373 | "\n",
374 | "### 1. Numbers\n",
375 | "\n",
376 | "Integers, floating point numbers and complex numbers are defined as int, float and complex class in Python. \n",
377 | "\n",
378 | "### 2. Boolean\n",
379 | "\n",
380 | "They are essential to set conditional statements which could be either True or False (treated as reserved words).\n",
381 | "\n",
382 | "### 3. String\n",
383 | "\n",
384 | "A string may consists letters, numbers, and other types of characters with spaces.\n",
385 | "\n",
386 | "You can check the type of your ariable by clling \"type\" command."
387 | ]
388 | },
389 | {
390 | "cell_type": "code",
391 | "execution_count": null,
392 | "metadata": {},
393 | "outputs": [],
394 | "source": [
395 | "x = [3.14]\n",
396 | "y = False\n",
397 | "\n",
398 | "print(type(x))\n",
399 | "print(type(y))"
400 | ]
401 | },
402 | {
403 | "cell_type": "markdown",
404 | "metadata": {},
405 | "source": [
406 | "---\n",
407 | "### 1. Types of numbers\n",
408 | "\n",
409 | "There ara basically three different types of numbers that we can use in Python.\n",
410 | "\n",
411 | "#### 1.1. Integers\n",
412 | "They can be positive or negative numbers which are written without decimals."
413 | ]
414 | },
415 | {
416 | "cell_type": "code",
417 | "execution_count": null,
418 | "metadata": {},
419 | "outputs": [],
420 | "source": [
421 | "(5 + 2) * 3 / 4"
422 | ]
423 | },
424 | {
425 | "cell_type": "code",
426 | "execution_count": null,
427 | "metadata": {},
428 | "outputs": [],
429 | "source": [
430 | "13 // 2"
431 | ]
432 | },
433 | {
434 | "cell_type": "code",
435 | "execution_count": null,
436 | "metadata": {},
437 | "outputs": [],
438 | "source": [
439 | "3828374649983 / 298374"
440 | ]
441 | },
442 | {
443 | "cell_type": "markdown",
444 | "metadata": {},
445 | "source": [
446 | "#### 1.2. Floats\n",
447 | "\n",
448 | "They are rational numbers with fractional parts."
449 | ]
450 | },
451 | {
452 | "cell_type": "code",
453 | "execution_count": null,
454 | "metadata": {},
455 | "outputs": [],
456 | "source": [
457 | "8.0 * 4"
458 | ]
459 | },
460 | {
461 | "cell_type": "code",
462 | "execution_count": null,
463 | "metadata": {},
464 | "outputs": [],
465 | "source": [
466 | "19. / 3"
467 | ]
468 | },
469 | {
470 | "cell_type": "code",
471 | "execution_count": null,
472 | "metadata": {},
473 | "outputs": [],
474 | "source": [
475 | "13. // 2"
476 | ]
477 | },
478 | {
479 | "cell_type": "code",
480 | "execution_count": null,
481 | "metadata": {},
482 | "outputs": [],
483 | "source": [
484 | "11. % 3"
485 | ]
486 | },
487 | {
488 | "cell_type": "code",
489 | "execution_count": null,
490 | "metadata": {},
491 | "outputs": [],
492 | "source": [
493 | "3.98e32 * 222"
494 | ]
495 | },
496 | {
497 | "cell_type": "markdown",
498 | "metadata": {},
499 | "source": [
500 | "#### 1.3. Complex Numbers\n",
501 | "\n",
502 | "Numbers with sum of real and imaginery parts. Use j instead of i which equals square root of -1. \n"
503 | ]
504 | },
505 | {
506 | "cell_type": "code",
507 | "execution_count": null,
508 | "metadata": {},
509 | "outputs": [],
510 | "source": [
511 | "(3 + 2j) * (4 - 2j)"
512 | ]
513 | },
514 | {
515 | "cell_type": "markdown",
516 | "metadata": {},
517 | "source": [
518 | "---\n",
519 | "## Homework #1\n",
520 | "\n",
521 | "1 - Design an algorithm for question 2 in Homework #1.\n",
522 | "\n",
523 | "2 - Write your first code that calculates your monthly budget for transportation. \n",
524 | " \n",
525 | " a ) Assume you are using Marmaray and paying 2.6 turkish liras for one way. \n",
526 | " \n",
527 | " b ) Assume that you are traveling by your own car and the gasoline costs 0.7 turkish liras per kilometer.\n",
528 | " \n",
529 | " c ) Calculate the differance between traveling by car and by Marmaray.\n",
530 | " \n",
531 | " PS: Please use your home location and GTU Civil Engineering Department building locations for distance calculations."
532 | ]
533 | },
534 | {
535 | "cell_type": "markdown",
536 | "metadata": {},
537 | "source": [
538 | "---"
539 | ]
540 | },
541 | {
542 | "cell_type": "code",
543 | "execution_count": null,
544 | "metadata": {},
545 | "outputs": [],
546 | "source": []
547 | }
548 | ],
549 | "metadata": {
550 | "kernelspec": {
551 | "display_name": "Python 3",
552 | "language": "python",
553 | "name": "python3"
554 | },
555 | "language_info": {
556 | "codemirror_mode": {
557 | "name": "ipython",
558 | "version": 3
559 | },
560 | "file_extension": ".py",
561 | "mimetype": "text/x-python",
562 | "name": "python",
563 | "nbconvert_exporter": "python",
564 | "pygments_lexer": "ipython3",
565 | "version": "3.6.8"
566 | }
567 | },
568 | "nbformat": 4,
569 | "nbformat_minor": 4
570 | }
571 |
--------------------------------------------------------------------------------
/.ipynb_checkpoints/CE103-Week04-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### CE 103- INTRODUCTION TO COMPUTERS and PROGRAMMING"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "### _The topics of the week !_\n",
15 | "\n",
16 | "- Conditionals and Loops\n",
17 | "\n",
18 | " - The **_\" if \"_** statement\n",
19 | " - The **_\" if else / elif\"_** statement\n",
20 | " - The **_\" for \"_** loop\n",
21 | " - **_\" break \"_**, **_\" continue \"_**, **_\" pass \"_** statements\n",
22 | " - The **_\" while \"_** statement\n",
23 | " - Nested Loops"
24 | ]
25 | },
26 | {
27 | "cell_type": "markdown",
28 | "metadata": {},
29 | "source": [
30 | "---\n",
31 | "\n",
32 | "In programming world, suc as in real world, sometimes we need to make decisions to move with next step. In Python, when we make a decision, so we can execute the next step of the code. This week we will learn to use decision makeing statements in Python programming language. \n",
33 | "\n",
34 | "In the code we use _conditionals_ to execute different lines of the code, as a way to repeat something, especially to say if its True or not. If the conditional is True, the loop will be infine, otherwise, if the code starts with False, means it will never run.\n",
35 | "\n",
36 | "\n",
37 | "### The **_\" if \"_** statement\n",
38 | "\n",
39 | "\" if \" statement is one of the most simple decision making statement. It is used to decide whether a certain statement is True or False. \n",
40 | "\n",
41 | "\n",
42 | "\n",
43 | "---\n",
44 | "\n",
45 | "Lets remember that Python supports the logical conditions listed below;\n",
46 | "\n",
47 | "\n",
48 | " Equal: a == b\n",
49 | " Not Equal: a != b\n",
50 | " Less than: a < b\n",
51 | " Less than or equal to: a <= b\n",
52 | " Greater than: a > b\n",
53 | " Greater than or equal to: a >= b\n",
54 | "\n"
55 | ]
56 | },
57 | {
58 | "cell_type": "code",
59 | "execution_count": null,
60 | "metadata": {},
61 | "outputs": [],
62 | "source": [
63 | "# write your first \"if\" statement\n",
64 | "# The colon (:) is required to seprarate the condition from the body. The line after the colon is also required and it stands for four spaces for indenting.\n",
65 | "\n",
66 | "a = 5\n",
67 | "b = 15\n",
68 | "if b > a:\n",
69 | " print('I\\'m bigger than you')"
70 | ]
71 | },
72 | {
73 | "cell_type": "code",
74 | "execution_count": null,
75 | "metadata": {},
76 | "outputs": [],
77 | "source": [
78 | "# using TABS and spaces make differences, such as:\n",
79 | "\n",
80 | "condition = False\n",
81 | "if condition:\n",
82 | " print('condition is True')\n",
83 | " print('condition is False') # this code will skip both print lines as long as acondition is False.\n",
84 | " \n",
85 | " \n",
86 | "condition = False\n",
87 | "if condition:\n",
88 | " print('condition is True')\n",
89 | "print('condition is False') # will print 'condition is False' regardless of whether condition is True or False\n",
90 | "\n",
91 | "condition = False\n",
92 | "if condition:\n",
93 | " print('condition is True')\n",
94 | " print('condition is False') # will appear \"IndentationError: unexpected indent\" error message"
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": null,
100 | "metadata": {},
101 | "outputs": [],
102 | "source": [
103 | "# lets try it with boolean expression\n",
104 | "\n",
105 | "action = 'jump'\n",
106 | "\n",
107 | "if action == 'jump':\n",
108 | " print('I would like to ', 5 * (action + '! '))"
109 | ]
110 | },
111 | {
112 | "cell_type": "code",
113 | "execution_count": null,
114 | "metadata": {},
115 | "outputs": [],
116 | "source": [
117 | "# make a decision about a number if its positive or not,\n",
118 | "\n",
119 | "A = 5\n",
120 | "if A > 0:\n",
121 | " print(A, \"is a positive number.\")\n",
122 | "\n",
123 | "A = -3\n",
124 | "if A < 0:\n",
125 | " print(A, \"is a negative number.\")"
126 | ]
127 | },
128 | {
129 | "cell_type": "markdown",
130 | "metadata": {},
131 | "source": [
132 | "---\n",
133 | "\n",
134 | "### The **_\" if else / elif \"_** statement\n",
135 | "\n",
136 | "\" if else\" statement is stands for a decision with two possible conclusion. If the statement is True follow 1st path, else follow the 2nd path. \n",
137 | "\n",
138 | ""
139 | ]
140 | },
141 | {
142 | "cell_type": "code",
143 | "execution_count": null,
144 | "metadata": {},
145 | "outputs": [],
146 | "source": [
147 | "# Lets write a very basic if else statement;\n",
148 | "\n",
149 | "a = 15\n",
150 | "b = 5\n",
151 | "if b > a:\n",
152 | " print('I\\'m bigger than you')\n",
153 | "else:\n",
154 | " print('No you are NOT !')"
155 | ]
156 | },
157 | {
158 | "cell_type": "code",
159 | "execution_count": null,
160 | "metadata": {},
161 | "outputs": [],
162 | "source": [
163 | "# lets try it with boolean expression\n",
164 | "\n",
165 | "#action = 'jump'\n",
166 | "action = 'walk'\n",
167 | "\n",
168 | "if action == 'jump':\n",
169 | " print('I would like to ', 5 * (action + '! '))\n",
170 | "else:\n",
171 | " print('Don\\'t want to', action, 'any more :(')"
172 | ]
173 | },
174 | {
175 | "cell_type": "code",
176 | "execution_count": null,
177 | "metadata": {},
178 | "outputs": [],
179 | "source": [
180 | "# Lets simplify the \" if \" statement above by using \"if else\" statement\n",
181 | "\n",
182 | "A = 5\n",
183 | "\n",
184 | "if A >= 0:\n",
185 | " print(A, \"is a positive number.\")\n",
186 | "else:\n",
187 | " print(A, \"is a negative number.\")"
188 | ]
189 | },
190 | {
191 | "cell_type": "markdown",
192 | "metadata": {},
193 | "source": [
194 | "---\n",
195 | "In order to chain conditions to each other to simplify/solve more complex logics \"elif\" can be used as a concentration version of else and if. \n",
196 | "If the _\" if \"_ statement condition is False, then the code will check the _\" elif \"_ condition on the next block, and so on. Even all of them are False, _\" else \"_ will be executed.\n",
197 | "\n",
198 | "\n"
199 | ]
200 | },
201 | {
202 | "cell_type": "code",
203 | "execution_count": null,
204 | "metadata": {},
205 | "outputs": [],
206 | "source": [
207 | "A = 5\n",
208 | "B = 8\n",
209 | "\n",
210 | "if A > 7:\n",
211 | " print(A, \"is greater than 7\")\n",
212 | "elif B > 7:\n",
213 | " print(B, \"is greater than 7.\")\n",
214 | "else:\n",
215 | " print('what is going on!!')"
216 | ]
217 | },
218 | {
219 | "cell_type": "markdown",
220 | "metadata": {},
221 | "source": [
222 | "Or, we can set more complex chain;"
223 | ]
224 | },
225 | {
226 | "cell_type": "code",
227 | "execution_count": null,
228 | "metadata": {},
229 | "outputs": [],
230 | "source": [
231 | "A = 4\n",
232 | "B = 8\n",
233 | "\n",
234 | "if A > 7 and B > 7 :\n",
235 | " print(\"Everything is awsome\")\n",
236 | "elif B > 7 or A < 5 :\n",
237 | " print(\"Confusing\")\n",
238 | "else:\n",
239 | " print('Nothing to do')"
240 | ]
241 | },
242 | {
243 | "cell_type": "markdown",
244 | "metadata": {},
245 | "source": [
246 | "---\n",
247 | "#### _Short hand statements;_"
248 | ]
249 | },
250 | {
251 | "cell_type": "code",
252 | "execution_count": null,
253 | "metadata": {},
254 | "outputs": [],
255 | "source": [
256 | "if a > b: print(\"a is greater than b\")"
257 | ]
258 | },
259 | {
260 | "cell_type": "code",
261 | "execution_count": null,
262 | "metadata": {},
263 | "outputs": [],
264 | "source": [
265 | "a = 3\n",
266 | "b = 5\n",
267 | "print(\"bigger a\") if a > b else print(\"smaller a\") "
268 | ]
269 | },
270 | {
271 | "cell_type": "code",
272 | "execution_count": null,
273 | "metadata": {},
274 | "outputs": [],
275 | "source": [
276 | "a = 5\n",
277 | "b = 5\n",
278 | "print(\"bigger a\") if a > b else print(\"a = b\") if a == b else print(\"smaller a\") "
279 | ]
280 | },
281 | {
282 | "cell_type": "code",
283 | "execution_count": null,
284 | "metadata": {},
285 | "outputs": [],
286 | "source": [
287 | "a = 6\n",
288 | "b = 5\n",
289 | "c = 8\n",
290 | "if a > b and c > a:\n",
291 | " print(\"c > a > b\")"
292 | ]
293 | },
294 | {
295 | "cell_type": "code",
296 | "execution_count": null,
297 | "metadata": {},
298 | "outputs": [],
299 | "source": [
300 | "a = 5\n",
301 | "b = 3\n",
302 | "c = 8\n",
303 | "if a > b or a > c:\n",
304 | " print(\"At least one of the conditions is True\")"
305 | ]
306 | },
307 | {
308 | "cell_type": "markdown",
309 | "metadata": {},
310 | "source": [
311 | "---\n",
312 | "### The **_\" for \"_** loop\n",
313 | "\n",
314 | "Loops are another type of flow control structure in programming language. By using loop conditions, a code can be repeated multiple times under specific conditions.\n",
315 | "\n",
316 | "\n"
317 | ]
318 | },
319 | {
320 | "cell_type": "code",
321 | "execution_count": null,
322 | "metadata": {},
323 | "outputs": [],
324 | "source": [
325 | "# define a list of values and iterate each of the values\n",
326 | "\n",
327 | "spring_semester = ['CE 102', 'CE 103', 'CE 105']\n",
328 | "\n",
329 | "for lectures in spring_semester: # searches for \"lecture\" variable in the list assigned to \"spring_semester\"\n",
330 | " print(lectures)"
331 | ]
332 | },
333 | {
334 | "cell_type": "code",
335 | "execution_count": null,
336 | "metadata": {},
337 | "outputs": [],
338 | "source": [
339 | "# Find the summation of the numbers in a list\n",
340 | "\n",
341 | "sum = 0 # what if I dit not define it?? \n",
342 | "\n",
343 | "digit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # create the list\n",
344 | "\n",
345 | "for i in digit:\n",
346 | " sum = sum + i\n",
347 | "\n",
348 | "print(\"Sum = \", sum)"
349 | ]
350 | },
351 | {
352 | "cell_type": "code",
353 | "execution_count": null,
354 | "metadata": {},
355 | "outputs": [],
356 | "source": [
357 | "# for loop with else statement \n",
358 | "\n",
359 | "digits = [1, 3, 5, 7, 9, 11, 13]\n",
360 | "\n",
361 | "for i in digits:\n",
362 | " print(i)\n",
363 | "else:\n",
364 | " print(\"Listed them all\")"
365 | ]
366 | },
367 | {
368 | "cell_type": "code",
369 | "execution_count": null,
370 | "metadata": {},
371 | "outputs": [],
372 | "source": [
373 | "# create two column list output with for loop\n",
374 | "\n",
375 | "for x in range(8): # Generate numbers 0 to 8\n",
376 | " print(x, '\\t', x**2) # ('\\t') character makes the output align with tab between values "
377 | ]
378 | },
379 | {
380 | "cell_type": "markdown",
381 | "metadata": {},
382 | "source": [
383 | "---\n",
384 | "#### _**.keys( )**_ function"
385 | ]
386 | },
387 | {
388 | "cell_type": "code",
389 | "execution_count": null,
390 | "metadata": {},
391 | "outputs": [],
392 | "source": [
393 | "# do the same iteration in a dictionary using \".keys()\" function, which goes through each item in the dictionary.\n",
394 | "\n",
395 | "credits = {'CE 102': 2, 'CE 103': 3, 'CE 105': 3}\n",
396 | "\n",
397 | "for x in credits.keys(): # allows to iterate over each entry\n",
398 | " print(credits[x])"
399 | ]
400 | },
401 | {
402 | "cell_type": "markdown",
403 | "metadata": {},
404 | "source": [
405 | "---\n",
406 | "#### _**range( )**_ function"
407 | ]
408 | },
409 | {
410 | "cell_type": "code",
411 | "execution_count": null,
412 | "metadata": {},
413 | "outputs": [],
414 | "source": [
415 | "# range() function can be used to create basic loop as below;\n",
416 | "\n",
417 | "print(range(8))\n",
418 | "\n",
419 | "for i in range(8):\n",
420 | " print('count', i)"
421 | ]
422 | },
423 | {
424 | "cell_type": "code",
425 | "execution_count": null,
426 | "metadata": {},
427 | "outputs": [],
428 | "source": [
429 | "spring_semester = ['CE 102', 'CE 103', 'CE 105']\n",
430 | "\n",
431 | "for lectures in range(len(spring_semester)): # combine range() and len() functions, tries the range() function to the length of a list\n",
432 | " print(lectures)"
433 | ]
434 | },
435 | {
436 | "cell_type": "markdown",
437 | "metadata": {},
438 | "source": [
439 | "---\n",
440 | "#### _**enumerate( )**_ function"
441 | ]
442 | },
443 | {
444 | "cell_type": "code",
445 | "execution_count": null,
446 | "metadata": {},
447 | "outputs": [],
448 | "source": [
449 | "# enumerate() function is another way to access a a list and returns both item and index\n",
450 | "\n",
451 | "spring_semester = ['CE 102', 'CE 103', 'CE 105']\n",
452 | "\n",
453 | "for i, lectures in enumerate(spring_semester): # takes in a list and returns both the item and its index\n",
454 | " print(lectures + 'is a spring semester lecture' + str(i))"
455 | ]
456 | },
457 | {
458 | "cell_type": "markdown",
459 | "metadata": {},
460 | "source": [
461 | "---\n",
462 | "### The **_\" while \"_** statement\n",
463 | "\n",
464 | "A while loop statement is used to repeatedly iterate a block of target statement as long as the given expression is True. If the condition becomes False, the code will pass that line and will follow the loop. The while loop generally prefers for the conditions that we don't know the number of times to iterate.\n",
465 | "\n",
466 | ""
467 | ]
468 | },
469 | {
470 | "cell_type": "code",
471 | "execution_count": null,
472 | "metadata": {},
473 | "outputs": [],
474 | "source": [
475 | "a = 0\n",
476 | "while (a < 5): \n",
477 | " a = a + 1\n",
478 | " print(\"pisi\") # will print \"pisi\" as long as a < 5"
479 | ]
480 | },
481 | {
482 | "cell_type": "code",
483 | "execution_count": null,
484 | "metadata": {},
485 | "outputs": [],
486 | "source": [
487 | "a = [1, 3, 5, 7] \n",
488 | "while a: \n",
489 | " print(a.pop()) # will print items in a, till they exist"
490 | ]
491 | },
492 | {
493 | "cell_type": "code",
494 | "execution_count": null,
495 | "metadata": {},
496 | "outputs": [],
497 | "source": [
498 | "# Lets use \"else\" with \"while\" loop\n",
499 | "\n",
500 | "a = 0\n",
501 | "while a < 3:\n",
502 | " print(a, \" is less than 3\")\n",
503 | " a = a + 1\n",
504 | "else:\n",
505 | " print(a, \" is not less than 3\") "
506 | ]
507 | },
508 | {
509 | "cell_type": "code",
510 | "execution_count": null,
511 | "metadata": {},
512 | "outputs": [],
513 | "source": [
514 | "digit = 10\n",
515 | "\n",
516 | "sum = 0 # set sum as summation variable\n",
517 | "i = 1 # set \" i \" as a counter\n",
518 | " \n",
519 | "while i <= digit:\n",
520 | " sum = sum + i\n",
521 | " i = i+1 # increase counter\n",
522 | "\n",
523 | "print(\"The sum is\", sum) # calculate the summation of all numbers between 0 and 'digit', till 'digit' = 10. "
524 | ]
525 | },
526 | {
527 | "cell_type": "markdown",
528 | "metadata": {},
529 | "source": [
530 | "---\n",
531 | "### The **_\" break \"_** loop\n",
532 | "\n",
533 | "This statement terminates the current loop and proceed with next statement. It can be used with both for and while loops. \n"
534 | ]
535 | },
536 | {
537 | "cell_type": "code",
538 | "execution_count": null,
539 | "metadata": {},
540 | "outputs": [],
541 | "source": [
542 | "for numbers in '1234567890': \n",
543 | " if numbers == '5':\n",
544 | " break\n",
545 | " print('Current number is :', numbers) # will print out all the numbers till its equal 5"
546 | ]
547 | },
548 | {
549 | "cell_type": "code",
550 | "execution_count": null,
551 | "metadata": {},
552 | "outputs": [],
553 | "source": [
554 | "a = 6\n",
555 | "while a > 0: \n",
556 | " print('Current variable value :', a)\n",
557 | " a = a -1\n",
558 | " if a == 5:\n",
559 | " break\n",
560 | "print(\"That\\'s all!\") # will break the code when the condition \"a = 5\""
561 | ]
562 | },
563 | {
564 | "cell_type": "markdown",
565 | "metadata": {},
566 | "source": [
567 | "---\n",
568 | "### The **_\" continue \"_** loop\n",
569 | "\n",
570 | "This statement returns the control to the beginning of the loop and skip all the remaining statements. And, control moves to the beginning of the loop. It can be used with both for and while loops. "
571 | ]
572 | },
573 | {
574 | "cell_type": "code",
575 | "execution_count": null,
576 | "metadata": {},
577 | "outputs": [],
578 | "source": [
579 | "for numbers in '1234567890': \n",
580 | " if numbers == '5':\n",
581 | " continue\n",
582 | " print('Current number is :', numbers) # will not print out the '5'"
583 | ]
584 | },
585 | {
586 | "cell_type": "code",
587 | "execution_count": null,
588 | "metadata": {},
589 | "outputs": [],
590 | "source": [
591 | "a = 6\n",
592 | "while a > 0: \n",
593 | " print('Current variable value :', a)\n",
594 | " a = a -1\n",
595 | " if a == 5:\n",
596 | " continue\n",
597 | "print(\"That\\'s all!\") # will keep doing the condition again as long as \"a > 0\""
598 | ]
599 | },
600 | {
601 | "cell_type": "markdown",
602 | "metadata": {},
603 | "source": [
604 | "---\n",
605 | "### The **_\" pass \"_** loop\n",
606 | "\n",
607 | "The pass statement is used to write empty statements, functions or classes. It is a \"null\" opretion which means nothing happens when its executed. "
608 | ]
609 | },
610 | {
611 | "cell_type": "code",
612 | "execution_count": null,
613 | "metadata": {},
614 | "outputs": [],
615 | "source": [
616 | "for numbers in '1234567890': \n",
617 | " if numbers == '5':\n",
618 | " pass\n",
619 | " print('5 is my favorite number')\n",
620 | " print('Current number is :', numbers) # will not print out the '5'"
621 | ]
622 | },
623 | {
624 | "cell_type": "markdown",
625 | "metadata": {},
626 | "source": [
627 | "---\n",
628 | "### The Nested Loops\n",
629 | "\n",
630 | "A loop inside another loop is called _\"Nested Loop\"_, which is allowed in Python. If you have while/for loop inside any loop, this is also allowed."
631 | ]
632 | },
633 | {
634 | "cell_type": "markdown",
635 | "metadata": {},
636 | "source": [
637 | "---\n",
638 | "#### _Nested If_\n",
639 | "\n",
640 | "If you have if statement inside if statement, this is called nested if statements.\n"
641 | ]
642 | },
643 | {
644 | "cell_type": "code",
645 | "execution_count": null,
646 | "metadata": {},
647 | "outputs": [],
648 | "source": [
649 | "a = 300\n",
650 | "\n",
651 | "if a > 10:\n",
652 | " print(\"Above ten,\")\n",
653 | " if a > 50:\n",
654 | " print(\"and also above 100!\")\n",
655 | " else:\n",
656 | " print(\"but not above 50.\") "
657 | ]
658 | },
659 | {
660 | "cell_type": "code",
661 | "execution_count": null,
662 | "metadata": {},
663 | "outputs": [],
664 | "source": [
665 | "a = -5\n",
666 | "if a >= 0:\n",
667 | " if a == 0:\n",
668 | " print(\"Zero\")\n",
669 | " else:\n",
670 | " print(\"Positive number\")\n",
671 | "else:\n",
672 | " print(\"Negative number\")"
673 | ]
674 | },
675 | {
676 | "cell_type": "markdown",
677 | "metadata": {},
678 | "source": [
679 | "---\n",
680 | "#### _Nested while/for_\n",
681 | "\n",
682 | "\n"
683 | ]
684 | },
685 | {
686 | "cell_type": "code",
687 | "execution_count": null,
688 | "metadata": {},
689 | "outputs": [],
690 | "source": [
691 | "# Lets find prime numbers between 1 to 50\n",
692 | "i = 1\n",
693 | "while(i < 50):\n",
694 | " j = 2\n",
695 | " while(j <= (i/j)):\n",
696 | " if not(i%j): \n",
697 | " break\n",
698 | " j = j + 1\n",
699 | " if (j > i/j) : \n",
700 | " print(i, \" is prime\")\n",
701 | " i = i + 1"
702 | ]
703 | },
704 | {
705 | "cell_type": "code",
706 | "execution_count": null,
707 | "metadata": {},
708 | "outputs": [],
709 | "source": []
710 | },
711 | {
712 | "cell_type": "markdown",
713 | "metadata": {},
714 | "source": [
715 | "## Homework #4\n",
716 | "---\n",
717 | "\n",
718 | "Will be announced later :)\n",
719 | "\n",
720 | "PS: Do not forget to upload your pdf files to http://derskutusu.gtu.edu.tr/\n",
721 | "\n",
722 | "---"
723 | ]
724 | },
725 | {
726 | "cell_type": "code",
727 | "execution_count": null,
728 | "metadata": {},
729 | "outputs": [],
730 | "source": []
731 | }
732 | ],
733 | "metadata": {
734 | "kernelspec": {
735 | "display_name": "Python 3",
736 | "language": "python",
737 | "name": "python3"
738 | },
739 | "language_info": {
740 | "codemirror_mode": {
741 | "name": "ipython",
742 | "version": 3
743 | },
744 | "file_extension": ".py",
745 | "mimetype": "text/x-python",
746 | "name": "python",
747 | "nbconvert_exporter": "python",
748 | "pygments_lexer": "ipython3",
749 | "version": "3.6.8"
750 | }
751 | },
752 | "nbformat": 4,
753 | "nbformat_minor": 4
754 | }
755 |
--------------------------------------------------------------------------------
/.ipynb_checkpoints/CE103-Week06-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### CE 103- INTRODUCTION TO COMPUTERS and PROGRAMMING"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "### _The topics of the week !_\n",
15 | "\n",
16 | "- Functions\n",
17 | " \n",
18 | "A function is a code block written to carry out a specified task, which similar with modules. Functions define in the code body, no need to import. They are generally not predefined modules. \n",
19 | "\n",
20 | "You can install a new module you need by simply using \"pip\" and call it by using \"import\" command. But you may need more complicated or specific problem to solve, than you may need your own module. \n",
21 | "\n",
22 | "With the help of **\"Functions\"**, a program break into smaller codes. So, as your program becomes longer, \"Functions\" help you to manage and organize a readable code. You can all a function more than once.\n",
23 | "\n",
24 | ""
25 | ]
26 | },
27 | {
28 | "cell_type": "code",
29 | "execution_count": 1,
30 | "metadata": {},
31 | "outputs": [],
32 | "source": [
33 | "## SYNTAX ##\n",
34 | "\n",
35 | "def function_name( arguments ):\n",
36 | " \"function_docstring\"\n",
37 | " function_body\n",
38 | " return [expression]"
39 | ]
40 | },
41 | {
42 | "cell_type": "markdown",
43 | "metadata": {},
44 | "source": [
45 | "## _How Functions work in Python?_\n",
46 | "\n",
47 | "There are three types of functions in Python;\n",
48 | "\n",
49 | "**1. Built-in Functions :** \n",
50 | " These functions are always available. No need to import any module. Such as: abs(), bool(), eval(), max(), print(), help(), sum(), type().\n",
51 | "For the full list of Built-in functions, visit --> https://docs.python.org/3/library/functions.html"
52 | ]
53 | },
54 | {
55 | "cell_type": "code",
56 | "execution_count": 2,
57 | "metadata": {},
58 | "outputs": [
59 | {
60 | "data": {
61 | "text/plain": [
62 | "10"
63 | ]
64 | },
65 | "execution_count": 2,
66 | "metadata": {},
67 | "output_type": "execute_result"
68 | }
69 | ],
70 | "source": [
71 | "sum([4,6])"
72 | ]
73 | },
74 | {
75 | "cell_type": "markdown",
76 | "metadata": {},
77 | "source": [
78 | "**2. Anonymous Functions :**\n",
79 | " They are also called \"lambda\" functions, they do not use \"def\" keyword. It has no name.\n",
80 | " "
81 | ]
82 | },
83 | {
84 | "cell_type": "code",
85 | "execution_count": 3,
86 | "metadata": {},
87 | "outputs": [
88 | {
89 | "name": "stdout",
90 | "output_type": "stream",
91 | "text": [
92 | "Value of total : 8\n"
93 | ]
94 | }
95 | ],
96 | "source": [
97 | "# Syntax --> lambda [arg1 [,arg2,.....argn]]:expression\n",
98 | "\n",
99 | "sum = lambda arg1, arg2: arg1 + arg2;\n",
100 | "\n",
101 | "print(\"Value of total : \", sum( 3, 5 )) # call sum as a function"
102 | ]
103 | },
104 | {
105 | "cell_type": "code",
106 | "execution_count": 4,
107 | "metadata": {},
108 | "outputs": [
109 | {
110 | "data": {
111 | "text/plain": [
112 | "81"
113 | ]
114 | },
115 | "execution_count": 4,
116 | "metadata": {},
117 | "output_type": "execute_result"
118 | }
119 | ],
120 | "source": [
121 | "square = lambda x:x**2 # x is argument, x**2 is expression\n",
122 | "\n",
123 | "square(9)"
124 | ]
125 | },
126 | {
127 | "cell_type": "markdown",
128 | "metadata": {},
129 | "source": [
130 | "**3. Used-Defined Functions (UDFs) :**\n",
131 | " These are functions that users create by using **_\" def \"_** command. Functions name should be unique. A Function starts with **_\" def \"_** keyword and a colon **_\" (:) \"_** marks the end of header line. They might or might not need multiple inputs, which are called Parameters or Arguments: information that are passed into a function. A parameter is the variable listed inside the paranthesis and Argument is the value that sent to the function. A function should execute the statement defined by user. It ends with **_\" return \"_** statement if it should output something, otherwise, it will return an object None. The **_\" return \"_** statement is also used to exit a function. "
132 | ]
133 | },
134 | {
135 | "cell_type": "code",
136 | "execution_count": 5,
137 | "metadata": {},
138 | "outputs": [],
139 | "source": [
140 | "def function_name(parameters): \n",
141 | " statement(s) # is called the body of the function\n",
142 | " return"
143 | ]
144 | },
145 | {
146 | "cell_type": "code",
147 | "execution_count": 6,
148 | "metadata": {},
149 | "outputs": [],
150 | "source": [
151 | "# Lets define a square function with UDFs to see the difference between the \"lambda function\".\n",
152 | "\n",
153 | "def square(x):\n",
154 | " return x**2"
155 | ]
156 | },
157 | {
158 | "cell_type": "markdown",
159 | "metadata": {},
160 | "source": [
161 | "---\n",
162 | "## _Define a Function_\n",
163 | "\n",
164 | "*** _In this lecture, from know on, all the words called \"Functions\", refers to the \"used-defined functions (UDFs)\"._"
165 | ]
166 | },
167 | {
168 | "cell_type": "code",
169 | "execution_count": 7,
170 | "metadata": {},
171 | "outputs": [],
172 | "source": [
173 | "def welcome(name):\n",
174 | " print(\"Welcome \" + name + \" !\")\n",
175 | " return"
176 | ]
177 | },
178 | {
179 | "cell_type": "code",
180 | "execution_count": 8,
181 | "metadata": {},
182 | "outputs": [],
183 | "source": [
184 | "# A function could be more complex: for example; contain for loops\n",
185 | "\n",
186 | "def order():\n",
187 | " name = str(input(\"What would you like to eat as dessert?: \"))\n",
188 | " if name:\n",
189 | " print (\"You ordered: \" + str(name))\n",
190 | " else:\n",
191 | " print(\"St Sebastian Cheese-Cake\") \n",
192 | " return # return command is not necessery here."
193 | ]
194 | },
195 | {
196 | "cell_type": "markdown",
197 | "metadata": {},
198 | "source": [
199 | "---\n",
200 | "## _Call a Function_\n",
201 | "\n",
202 | "Use the function name and parenthesis as shown in the example below, to call a function."
203 | ]
204 | },
205 | {
206 | "cell_type": "markdown",
207 | "metadata": {},
208 | "source": [
209 | "### function_name([arguments])"
210 | ]
211 | },
212 | {
213 | "cell_type": "code",
214 | "execution_count": 9,
215 | "metadata": {},
216 | "outputs": [
217 | {
218 | "data": {
219 | "text/plain": [
220 | "25"
221 | ]
222 | },
223 | "execution_count": 9,
224 | "metadata": {},
225 | "output_type": "execute_result"
226 | }
227 | ],
228 | "source": [
229 | "square(5)"
230 | ]
231 | },
232 | {
233 | "cell_type": "code",
234 | "execution_count": 10,
235 | "metadata": {},
236 | "outputs": [
237 | {
238 | "name": "stdout",
239 | "output_type": "stream",
240 | "text": [
241 | "Welcome Home !\n"
242 | ]
243 | }
244 | ],
245 | "source": [
246 | "welcome(\"Home\")"
247 | ]
248 | },
249 | {
250 | "cell_type": "code",
251 | "execution_count": 11,
252 | "metadata": {},
253 | "outputs": [
254 | {
255 | "name": "stdin",
256 | "output_type": "stream",
257 | "text": [
258 | "What would you like to eat as dessert?: \n"
259 | ]
260 | },
261 | {
262 | "name": "stdout",
263 | "output_type": "stream",
264 | "text": [
265 | "St Sebastian Cheese-Cake\n"
266 | ]
267 | }
268 | ],
269 | "source": [
270 | "order()"
271 | ]
272 | },
273 | {
274 | "cell_type": "code",
275 | "execution_count": 12,
276 | "metadata": {},
277 | "outputs": [
278 | {
279 | "name": "stdin",
280 | "output_type": "stream",
281 | "text": [
282 | "Write a number: -5\n"
283 | ]
284 | },
285 | {
286 | "name": "stdout",
287 | "output_type": "stream",
288 | "text": [
289 | "The number you entered is NEGATIVE\n"
290 | ]
291 | }
292 | ],
293 | "source": [
294 | "# Lets define a function that checks even a number is positive or negative\n",
295 | "\n",
296 | "def test():\n",
297 | " num = int(input(\"Write a number: \"))\n",
298 | " if (num >= 0):\n",
299 | " print(\"The number you entered is POSITIVE\")\n",
300 | " else:\n",
301 | " print(\"The number you entered is NEGATIVE\")\n",
302 | " return\n",
303 | "test()"
304 | ]
305 | },
306 | {
307 | "cell_type": "markdown",
308 | "metadata": {},
309 | "source": [
310 | "---\n",
311 | "## _Arguments_\n",
312 | "\n",
313 | "We already learned what is \"Argument\" stands for above. Its important to call function with correct number of arguments. Meaning that; the number of the arguments that function expects should be equal to the number of arguments that you call in function. "
314 | ]
315 | },
316 | {
317 | "cell_type": "code",
318 | "execution_count": 13,
319 | "metadata": {},
320 | "outputs": [
321 | {
322 | "name": "stdout",
323 | "output_type": "stream",
324 | "text": [
325 | "Jelly+fish = Jellyfish\n"
326 | ]
327 | }
328 | ],
329 | "source": [
330 | "# Lets define a function expects 2 arguments and gets 2 arguments;\n",
331 | "\n",
332 | "def compound(first,second):\n",
333 | " print(first + '+' + second + \" = \" + first + \"\" + second)\n",
334 | "\n",
335 | "compound(\"Jelly\",\"fish\")\n"
336 | ]
337 | },
338 | {
339 | "cell_type": "markdown",
340 | "metadata": {},
341 | "source": [
342 | "#### There are four types of Arguments;\n",
343 | "**1. Default Arguments**\n",
344 | " Assumes a default value if a value is not provided in the function.\n",
345 | " "
346 | ]
347 | },
348 | {
349 | "cell_type": "code",
350 | "execution_count": 14,
351 | "metadata": {},
352 | "outputs": [
353 | {
354 | "data": {
355 | "text/plain": [
356 | "8"
357 | ]
358 | },
359 | "execution_count": 14,
360 | "metadata": {},
361 | "output_type": "execute_result"
362 | }
363 | ],
364 | "source": [
365 | "def defarg(x, y=5): # two argument is given one of them is \"default\", function asks for only one \n",
366 | " return (x * y)\n",
367 | "\n",
368 | "defarg(4, y=2) "
369 | ]
370 | },
371 | {
372 | "cell_type": "markdown",
373 | "metadata": {},
374 | "source": [
375 | "**2. Required Arguments** (also called \"Positional Arguments\")\n",
376 | " the number of arguments in the function has to be in correct positional order and should match with the function definition."
377 | ]
378 | },
379 | {
380 | "cell_type": "code",
381 | "execution_count": 15,
382 | "metadata": {},
383 | "outputs": [
384 | {
385 | "data": {
386 | "text/plain": [
387 | "3.0"
388 | ]
389 | },
390 | "execution_count": 15,
391 | "metadata": {},
392 | "output_type": "execute_result"
393 | }
394 | ],
395 | "source": [
396 | "def div(x,y): \n",
397 | " return x / y # change in order will effect the result\n",
398 | "\n",
399 | "div(9,3)"
400 | ]
401 | },
402 | {
403 | "cell_type": "markdown",
404 | "metadata": {},
405 | "source": [
406 | "**3. Keyword Arguments**\n",
407 | " If you don't want to keep the right order of parameters in your mind, its easy way to identify arguments by using parameter names."
408 | ]
409 | },
410 | {
411 | "cell_type": "code",
412 | "execution_count": 16,
413 | "metadata": {},
414 | "outputs": [
415 | {
416 | "data": {
417 | "text/plain": [
418 | "2.5"
419 | ]
420 | },
421 | "execution_count": 16,
422 | "metadata": {},
423 | "output_type": "execute_result"
424 | }
425 | ],
426 | "source": [
427 | "# lets call the \"div()\" function again\n",
428 | "\n",
429 | "div(x=5, y=2) # Call function with keyword arguments"
430 | ]
431 | },
432 | {
433 | "cell_type": "code",
434 | "execution_count": 17,
435 | "metadata": {},
436 | "outputs": [
437 | {
438 | "data": {
439 | "text/plain": [
440 | "2.5"
441 | ]
442 | },
443 | "execution_count": 17,
444 | "metadata": {},
445 | "output_type": "execute_result"
446 | }
447 | ],
448 | "source": [
449 | "div(y=2, x=5) # with keyword arguments, parameters do not have t be in ordered"
450 | ]
451 | },
452 | {
453 | "cell_type": "code",
454 | "execution_count": 18,
455 | "metadata": {},
456 | "outputs": [
457 | {
458 | "name": "stdout",
459 | "output_type": "stream",
460 | "text": [
461 | "The first mounth of summer is June\n"
462 | ]
463 | }
464 | ],
465 | "source": [
466 | "# if you send the arguments with the key = value syntax, the order of the arguments doesn't matter.\n",
467 | "\n",
468 | "def summer(second, third, first):\n",
469 | " print(\"The first mounth of summer is \" + first)\n",
470 | "\n",
471 | "summer(first = \"June\", second = \"July\", third = \"August\") "
472 | ]
473 | },
474 | {
475 | "cell_type": "markdown",
476 | "metadata": {},
477 | "source": [
478 | "**4. Arbitrary Arguments**\n",
479 | " If you don't have any idea about the exact number of arguments to call the function, then you can use **\" *args \"** syntax."
480 | ]
481 | },
482 | {
483 | "cell_type": "code",
484 | "execution_count": 19,
485 | "metadata": {},
486 | "outputs": [
487 | {
488 | "name": "stdout",
489 | "output_type": "stream",
490 | "text": [
491 | "Keep\n",
492 | " your\n",
493 | " social\n",
494 | " distance\n",
495 | " !\n"
496 | ]
497 | }
498 | ],
499 | "source": [
500 | "def message(*argv): \n",
501 | " for arg in argv: \n",
502 | " print(arg) \n",
503 | "\n",
504 | "message(\"Keep\",\" your\",\" social\",\" distance\",\" !\")"
505 | ]
506 | },
507 | {
508 | "cell_type": "markdown",
509 | "metadata": {},
510 | "source": [
511 | "---\n",
512 | "## _The \"return\" Statement_\n",
513 | "\n",
514 | "Simply it prints the result to the console. But, if you want to assign the result to a variable, the return statement sends a result back to the caller and exist the function."
515 | ]
516 | },
517 | {
518 | "cell_type": "code",
519 | "execution_count": 20,
520 | "metadata": {},
521 | "outputs": [
522 | {
523 | "name": "stdout",
524 | "output_type": "stream",
525 | "text": [
526 | "15\n"
527 | ]
528 | }
529 | ],
530 | "source": [
531 | "# lets define a total function which calculates the summation of numbers between two specific numbers\n",
532 | "\n",
533 | "def total(num1, num2):\n",
534 | " sum = 0\n",
535 | " for i in range(num1, num2 + 1):\n",
536 | " sum += i\n",
537 | " return sum\n",
538 | "\n",
539 | "t = total(1, 5)\n",
540 | "print(t)\n"
541 | ]
542 | },
543 | {
544 | "cell_type": "markdown",
545 | "metadata": {},
546 | "source": [
547 | "---\n",
548 | "## _Recursive Function_"
549 | ]
550 | },
551 | {
552 | "cell_type": "markdown",
553 | "metadata": {},
554 | "source": [
555 | "A function can call other functions or can call itself either. These type of functions are called _recursive functions_.\n",
556 | "\n",
557 | "These functions make the code look elegant but its hard to follow the logic behind."
558 | ]
559 | },
560 | {
561 | "cell_type": "code",
562 | "execution_count": 25,
563 | "metadata": {},
564 | "outputs": [
565 | {
566 | "name": "stdout",
567 | "output_type": "stream",
568 | "text": [
569 | "5 * 4 * 3 * 2 * n = 1\n"
570 | ]
571 | },
572 | {
573 | "data": {
574 | "text/plain": [
575 | "120"
576 | ]
577 | },
578 | "execution_count": 25,
579 | "metadata": {},
580 | "output_type": "execute_result"
581 | }
582 | ],
583 | "source": [
584 | "def factorial(n): # define recursive function\n",
585 | " if n == 1: \n",
586 | " print(\"n = \", n)\n",
587 | " return n \n",
588 | " else:\n",
589 | " print (n,'*', end = \" \") \n",
590 | " return n * factorial(n-1)\n",
591 | "\n",
592 | "factorial(5)"
593 | ]
594 | },
595 | {
596 | "cell_type": "code",
597 | "execution_count": 22,
598 | "metadata": {},
599 | "outputs": [
600 | {
601 | "name": "stdout",
602 | "output_type": "stream",
603 | "text": [
604 | "12 10 8 6 4 2 2 4 6 8 10 12 "
605 | ]
606 | }
607 | ],
608 | "source": [
609 | "def mirror(x):\n",
610 | " if (x < 1):\n",
611 | " return\n",
612 | " else:\n",
613 | " print( x,end = \" \")\n",
614 | " mirror(x-2)\n",
615 | " print(x,end = \" \")\n",
616 | " return\n",
617 | "x = 12\n",
618 | "mirror(x)"
619 | ]
620 | },
621 | {
622 | "cell_type": "markdown",
623 | "metadata": {},
624 | "source": [
625 | "---\n",
626 | "## _Global and Local Variables_\n",
627 | "\n",
628 | "A variable declared inside a function is called **_local variable_**, while a variable not bound to any function but can be accessed outside the function is called **_global variable_**."
629 | ]
630 | },
631 | {
632 | "cell_type": "code",
633 | "execution_count": 23,
634 | "metadata": {},
635 | "outputs": [
636 | {
637 | "name": "stdout",
638 | "output_type": "stream",
639 | "text": [
640 | "15\n"
641 | ]
642 | }
643 | ],
644 | "source": [
645 | "global_var = 3\n",
646 | "\n",
647 | "def cool():\n",
648 | " local_var = 5 # local variable\n",
649 | " print(global_var * local_var) # both variables are accessible from inside\n",
650 | "\n",
651 | "cool() \n",
652 | " # when function ends, local_var is destroyed\n",
653 | "#print(local_var) # but you can't access local_var outside the function"
654 | ]
655 | },
656 | {
657 | "cell_type": "markdown",
658 | "metadata": {},
659 | "source": [
660 | "---\n",
661 | "## _BONUS_ function\n",
662 | "\n",
663 | "#### **map() function**"
664 | ]
665 | },
666 | {
667 | "cell_type": "code",
668 | "execution_count": 24,
669 | "metadata": {},
670 | "outputs": [
671 | {
672 | "data": {
673 | "text/plain": [
674 | "[1.0, 2.0, 3.0, 4.0, 5.0]"
675 | ]
676 | },
677 | "execution_count": 24,
678 | "metadata": {},
679 | "output_type": "execute_result"
680 | }
681 | ],
682 | "source": [
683 | "# map() function; applies a function to every item in the array, if you have \"list\" of values\n",
684 | "# Lets define \"div()\" function again\n",
685 | "\n",
686 | "def div(x,y=2): \n",
687 | " return x / y\n",
688 | "\n",
689 | "data = [2, 4, 6, 8, 10] # declare an array of numbers\n",
690 | "list(map(div,data)) # no need to write a loop "
691 | ]
692 | },
693 | {
694 | "cell_type": "markdown",
695 | "metadata": {},
696 | "source": [
697 | "---\n",
698 | "## Homework #6\n",
699 | "\n",
700 | "Please visit https://covid19.saglik.gov.tr/ web page and get the information you need for your assignment. By using this data, lets make some statistics about the COVID-19 spreading speed in Turkey. Please follow the instructions below;\n",
701 | "\n",
702 | "1. Define a function which calculates \"percentage\".\n",
703 | "2. Get the daily based numbers for covid-19 cases, deaths, recovered people and covid-tests. \n",
704 | "3. Calculate percentages between case-death in daily bases and draw a graph. \n",
705 | "\n",
706 | "You are free to use any type of visualization, use your imagination. The shortest code will get extra point. \n",
707 | "\n",
708 | "PS: Do not forget to upload your pdf files to Microsoft Teams-CE103 Class.\n",
709 | "\n",
710 | "The attached screenshots will guide you to get the numeric data you need from the https://covid19.saglik.gov.tr/ web page. \n",
711 | "\n",
712 | "\n",
713 | "\n",
714 | "---"
715 | ]
716 | },
717 | {
718 | "cell_type": "code",
719 | "execution_count": null,
720 | "metadata": {},
721 | "outputs": [],
722 | "source": []
723 | }
724 | ],
725 | "metadata": {
726 | "kernelspec": {
727 | "display_name": "Python 3",
728 | "language": "python",
729 | "name": "python3"
730 | },
731 | "language_info": {
732 | "codemirror_mode": {
733 | "name": "ipython",
734 | "version": 3
735 | },
736 | "file_extension": ".py",
737 | "mimetype": "text/x-python",
738 | "name": "python",
739 | "nbconvert_exporter": "python",
740 | "pygments_lexer": "ipython3",
741 | "version": "3.6.8"
742 | }
743 | },
744 | "nbformat": 4,
745 | "nbformat_minor": 4
746 | }
747 |
--------------------------------------------------------------------------------
/.ipynb_checkpoints/CE103-Week12-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### CE 103- INTRODUCTION TO COMPUTERS and PROGRAMMING"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "### _The topics of the week !_\n",
15 | "\n",
16 | "- Object Oriented Programming\n",
17 | " - CLASSES & OBJECTS\n",
18 | "\n",
19 | "\n",
20 | "Python is an object oriented programming language. **_Object Oriented Programming_** can be thought of as simply adapting real life to programming. For example, let's imagine that we prepared building stock software. For this, \"reinforced concrete\", \"steel\" and \"masonry\" must be created as **_objects_**. In order to realize such a system by programming, we actually need to define the structure of each object and then produce objects from these structures. When we look around, we see that each item is actually an object. These objects have different properties (**_attributes_**) and functions (**_methods_**).\n",
21 | "\n",
22 | "In order to create our own data types and to produce objects from these data types, we first need to define the structure in which we will produce the objects. This structure is called **_\"class\"_**. Classes are a structure where we define the properties and methods of objects while creating our **_objects_**. The property of \"Reinforced Concrete\" object can be exemplified as strength and its function can be exemplified as modulus of elasticity.\n",
23 | "\n",
24 | "Classes are used to define groups or sets with common properties. For example, all cars have features such as a brand, model, price, color.\n",
25 | "\n",
26 | "### _\" CLASS \"_ a code template for creating objects.\n",
27 | "\n",
28 | "### _\" OBJECT \"_ the instance of the class"
29 | ]
30 | },
31 | {
32 | "cell_type": "markdown",
33 | "metadata": {},
34 | "source": [
35 | "---"
36 | ]
37 | },
38 | {
39 | "cell_type": "code",
40 | "execution_count": 85,
41 | "metadata": {},
42 | "outputs": [
43 | {
44 | "name": "stdout",
45 | "output_type": "stream",
46 | "text": [
47 | "<__main__.MyClass_Name object at 0x7f9dc84320f0>\n"
48 | ]
49 | }
50 | ],
51 | "source": [
52 | "# Python uses word \"class\" to define an empty class with no functionalities\n",
53 | "\n",
54 | "class MyClass_Name:\n",
55 | " '''This is a docstring line for description'''\n",
56 | " pass\n",
57 | "\n",
58 | "instanse = MyClass_Name() # object is created using the constructor of class\n",
59 | "print(instanse)"
60 | ]
61 | },
62 | {
63 | "cell_type": "markdown",
64 | "metadata": {},
65 | "source": [
66 | "# Class definition"
67 | ]
68 | },
69 | {
70 | "cell_type": "code",
71 | "execution_count": 86,
72 | "metadata": {},
73 | "outputs": [],
74 | "source": [
75 | "class firstclass():\n",
76 | " 'Lest define a class'\n",
77 | " pass\n"
78 | ]
79 | },
80 | {
81 | "cell_type": "markdown",
82 | "metadata": {},
83 | "source": [
84 | "# Attributes and Methods in class"
85 | ]
86 | },
87 | {
88 | "cell_type": "code",
89 | "execution_count": 92,
90 | "metadata": {},
91 | "outputs": [],
92 | "source": [
93 | "# Lets add some attributes or properties to this class\n",
94 | "\n",
95 | "class Lecture:\n",
96 | " Department = \"\" # class attributes\n",
97 | " Teacher = \"\" # class attributes \n",
98 | " Level = \"\" # class attributes\n",
99 | "\n",
100 | "# Lets define an object and its properties\n",
101 | "\n",
102 | "CE_103 = Lecture() # CE_103 is an instance (example) of the Class \"Lecture\"\n",
103 | "CE_103.Department = \"Civil Engineering\"\n",
104 | "CE_103.Name = \"Python Programming\"\n",
105 | "CE_103.Level = \"UnderGraduate\"\n",
106 | "\n",
107 | "# Lets define another object to same class\n",
108 | "\n",
109 | "DYB_582 = Lecture()\n",
110 | "DYB_582.Department = \"Civil Engineering\"\n",
111 | "DYB_582.Name = \"Engineering Seismology\"\n",
112 | "DYB_582.Level = \"Graduate\"\n"
113 | ]
114 | },
115 | {
116 | "cell_type": "code",
117 | "execution_count": 93,
118 | "metadata": {},
119 | "outputs": [
120 | {
121 | "name": "stdout",
122 | "output_type": "stream",
123 | "text": [
124 | "-------CE_103-----\n",
125 | "Department: Civil Engineering \n",
126 | "Name :Python Programming\n",
127 | "Level :UnderGraduate\n",
128 | "-------DYB_582------\n",
129 | "Department: Civil Engineering \n",
130 | "Name :Engineering Seismology\n",
131 | "Level :Graduate\n"
132 | ]
133 | }
134 | ],
135 | "source": [
136 | "print(\"-------CE_103-----\")\n",
137 | "print(\"Department: {} \\nName :{}\\nLevel :{}\".format(CE_103.Department,CE_103.Name,CE_103.Level))\n",
138 | " \n",
139 | "print(\"-------DYB_582------\")\n",
140 | "print(\"Department: {} \\nName :{}\\nLevel :{}\".format(DYB_582.Department,DYB_582.Name,DYB_582.Level))\n"
141 | ]
142 | },
143 | {
144 | "cell_type": "markdown",
145 | "metadata": {},
146 | "source": [
147 | "---\n",
148 | "In object oriented programming languages, the most effective tool is; when you write it once you can call it more than ones."
149 | ]
150 | },
151 | {
152 | "cell_type": "code",
153 | "execution_count": 96,
154 | "metadata": {},
155 | "outputs": [],
156 | "source": [
157 | "# lets add some function or methods to our object\n",
158 | "\n",
159 | "def lab_credit(self): # first function in Class always starts with keyword \"self\"\n",
160 | " self.lab += 1\n",
161 | " return self.lab"
162 | ]
163 | },
164 | {
165 | "cell_type": "code",
166 | "execution_count": 97,
167 | "metadata": {},
168 | "outputs": [],
169 | "source": [
170 | "# lets write function into the class\n",
171 | "\n",
172 | "class Lecture:\n",
173 | " Department = \"\"\n",
174 | " Teacher = \"\"\n",
175 | " Level = \"\"\n",
176 | " lab = 0\n",
177 | " \n",
178 | " def lab_credit(self): # first function in Class always starts with keyword \"self\"\n",
179 | " self.lab += 1\n",
180 | " return self.lab\n",
181 | "\n",
182 | " # Lets define an object ant its properties\n",
183 | "\n",
184 | "CE_103 = Lecture()\n",
185 | "CE_103.Department = \"Civil Engineering\"\n",
186 | "CE_103.Name = \"Python Programming\"\n",
187 | "CE_103.Level = \"UnderGraduate\"\n"
188 | ]
189 | },
190 | {
191 | "cell_type": "code",
192 | "execution_count": 98,
193 | "metadata": {},
194 | "outputs": [
195 | {
196 | "data": {
197 | "text/plain": [
198 | "1"
199 | ]
200 | },
201 | "execution_count": 98,
202 | "metadata": {},
203 | "output_type": "execute_result"
204 | }
205 | ],
206 | "source": [
207 | "CE_103.lab_credit() # call the function"
208 | ]
209 | },
210 | {
211 | "cell_type": "code",
212 | "execution_count": 99,
213 | "metadata": {},
214 | "outputs": [
215 | {
216 | "name": "stdout",
217 | "output_type": "stream",
218 | "text": [
219 | "-------CE_103-----\n",
220 | "Department: Civil Engineering \n",
221 | "Name :Python Programming\n",
222 | "Level :UnderGraduate\n",
223 | "Lab credit : 2\n"
224 | ]
225 | }
226 | ],
227 | "source": [
228 | "print(\"-------CE_103-----\")\n",
229 | "print(\"Department: {} \\nName :{}\\nLevel :{}\".format(CE_103.Department,CE_103.Name,CE_103.Level))\n",
230 | "\n",
231 | "CE_103.lab_credit()\n",
232 | "print(\"Lab credit :\", CE_103.lab)"
233 | ]
234 | },
235 | {
236 | "cell_type": "markdown",
237 | "metadata": {},
238 | "source": [
239 | "---\n",
240 | "Think that a class as blueprint of specific objects. These objects has to be created in the class. Assume a \"house\" as a class. Class variable is a variable that is shared by all different objects of class. Such as \"roof\", \"column\", \"foundation\". Instance variables are unique to each instance of a class. Such as \"garage\", \"doghouse\", \"dining room\". Functions, or methods, describes the behaviour of an object. In our example, this could be the location of the house. \n",
241 | "\n",
242 | "\n",
243 | "\n"
244 | ]
245 | },
246 | {
247 | "cell_type": "markdown",
248 | "metadata": {},
249 | "source": [
250 | "---\n",
251 | "While creating the object we may also define its properties, such as;"
252 | ]
253 | },
254 | {
255 | "cell_type": "code",
256 | "execution_count": 41,
257 | "metadata": {},
258 | "outputs": [
259 | {
260 | "name": "stdout",
261 | "output_type": "stream",
262 | "text": [
263 | "-------EQE_576------\n",
264 | "Department: Civil Engineering \n",
265 | "Level :Graduate\n",
266 | "-------DYB_523------\n",
267 | "Department: Civil Engineering \n",
268 | "Level :Graduate\n"
269 | ]
270 | }
271 | ],
272 | "source": [
273 | "class Lecture:\n",
274 | " Department = \"Civil Engineering\"\n",
275 | " Level = \"Graduate\"\n",
276 | " \n",
277 | "EQE_576 = Lecture() # object creating\n",
278 | "DYB_523 = Lecture()\n",
279 | "\n",
280 | "print(\"-------EQE_576------\")\n",
281 | "print(\"Department: {} \\nLevel :{}\".format(EQE_576.Department,EQE_576.Level))\n",
282 | "\n",
283 | "print(\"-------DYB_523------\")\n",
284 | "print(\"Department: {} \\nLevel :{}\".format(DYB_523.Department,DYB_523.Level))\n"
285 | ]
286 | },
287 | {
288 | "cell_type": "markdown",
289 | "metadata": {},
290 | "source": [
291 | "---\n",
292 | "BUT, in this situation, both objects have same properties! What if I would like to define different properties for each object ??\n",
293 | "\n",
294 | "# **__ init __()** function\n",
295 | "\n",
296 | "We need \"__ init __()\" and \"self\" to exemplified the properties of an object. The first parameter of this function must always be \"self\"."
297 | ]
298 | },
299 | {
300 | "cell_type": "code",
301 | "execution_count": 5,
302 | "metadata": {},
303 | "outputs": [
304 | {
305 | "name": "stdout",
306 | "output_type": "stream",
307 | "text": [
308 | "Kuzey.Guney@2005gtu.edu.tr\n",
309 | "Cinar.Selvi@2011gtu.edu.tr\n"
310 | ]
311 | }
312 | ],
313 | "source": [
314 | "# Up to know we learned class attribute, but there also object attributes. \n",
315 | "# In order to define object attributes, I need __init__() function and self.\n",
316 | "\n",
317 | "class student:\n",
318 | " def __init__(self, first, last, enroll): # set instance variables \"self, first, last, enroll\"\n",
319 | " self.fname=first\n",
320 | " self.lname=last\n",
321 | " self.enroll_year=enroll\n",
322 | " self.email=first + '.' + last + '@' + enroll + 'gtu.edu.tr'\n",
323 | "\n",
324 | "undgra1 = student('Kuzey', 'Guney', '2005')\n",
325 | "undgra2 = student('Cinar', 'Selvi', '2011')\n",
326 | "\n",
327 | "print(undgra1.email)\n",
328 | "print(undgra2.email)"
329 | ]
330 | },
331 | {
332 | "cell_type": "code",
333 | "execution_count": 1,
334 | "metadata": {},
335 | "outputs": [
336 | {
337 | "name": "stdout",
338 | "output_type": "stream",
339 | "text": [
340 | "KuzeyGuney\n",
341 | "CinarSelvi\n"
342 | ]
343 | }
344 | ],
345 | "source": [
346 | "# Instances of student class have created. Now,let's add some action, to do so, we will add a method to this class.\n",
347 | "# Asuume that we would like to display full name of student.\n",
348 | "\n",
349 | "class student:\n",
350 | " def __init__(self, first, last, enroll): # set instance variables \"self, first, last, enroll\"\n",
351 | " self.fname=first\n",
352 | " self.lname=last\n",
353 | " self.enroll_year=enroll\n",
354 | " self.email=first + '.' + last + '@' + enroll + 'gtu.edu.tr'\n",
355 | " \n",
356 | " def fullname(self):\n",
357 | " return '{}{}'.format(self.fname, self.lname)\n",
358 | "\n",
359 | "undgra1 = student('Kuzey', 'Guney', '2005')\n",
360 | "undgra2 = student('Cinar', 'Selvi', '2011') \n",
361 | "\n",
362 | "print(undgra1.fullname())\n",
363 | "print(undgra2.fullname())"
364 | ]
365 | },
366 | {
367 | "cell_type": "code",
368 | "execution_count": 8,
369 | "metadata": {},
370 | "outputs": [],
371 | "source": [
372 | "Kemal = student('Kemal','Durmaz','2009')"
373 | ]
374 | },
375 | {
376 | "cell_type": "code",
377 | "execution_count": 9,
378 | "metadata": {},
379 | "outputs": [
380 | {
381 | "data": {
382 | "text/plain": [
383 | "<__main__.student at 0x7fdab81df8d0>"
384 | ]
385 | },
386 | "execution_count": 9,
387 | "metadata": {},
388 | "output_type": "execute_result"
389 | }
390 | ],
391 | "source": [
392 | "Kemal"
393 | ]
394 | },
395 | {
396 | "cell_type": "code",
397 | "execution_count": 10,
398 | "metadata": {},
399 | "outputs": [
400 | {
401 | "data": {
402 | "text/plain": [
403 | "['__class__',\n",
404 | " '__delattr__',\n",
405 | " '__dict__',\n",
406 | " '__dir__',\n",
407 | " '__doc__',\n",
408 | " '__eq__',\n",
409 | " '__format__',\n",
410 | " '__ge__',\n",
411 | " '__getattribute__',\n",
412 | " '__gt__',\n",
413 | " '__hash__',\n",
414 | " '__init__',\n",
415 | " '__init_subclass__',\n",
416 | " '__le__',\n",
417 | " '__lt__',\n",
418 | " '__module__',\n",
419 | " '__ne__',\n",
420 | " '__new__',\n",
421 | " '__reduce__',\n",
422 | " '__reduce_ex__',\n",
423 | " '__repr__',\n",
424 | " '__setattr__',\n",
425 | " '__sizeof__',\n",
426 | " '__str__',\n",
427 | " '__subclasshook__',\n",
428 | " '__weakref__',\n",
429 | " 'email',\n",
430 | " 'enroll_year',\n",
431 | " 'fname',\n",
432 | " 'fullname',\n",
433 | " 'lname']"
434 | ]
435 | },
436 | "execution_count": 10,
437 | "metadata": {},
438 | "output_type": "execute_result"
439 | }
440 | ],
441 | "source": [
442 | "dir(Kemal)"
443 | ]
444 | },
445 | {
446 | "cell_type": "code",
447 | "execution_count": 11,
448 | "metadata": {},
449 | "outputs": [
450 | {
451 | "data": {
452 | "text/plain": [
453 | "'Kemal.Durmaz@2009gtu.edu.tr'"
454 | ]
455 | },
456 | "execution_count": 11,
457 | "metadata": {},
458 | "output_type": "execute_result"
459 | }
460 | ],
461 | "source": [
462 | "kemal.email"
463 | ]
464 | },
465 | {
466 | "cell_type": "markdown",
467 | "metadata": {},
468 | "source": [
469 | "---\n",
470 | "## Homework #12\n",
471 | "\n",
472 | "Create your own python module by defining a class for Mechanical properties of truss.\n",
473 | "\n",
474 | "These properties will be:\n",
475 | "\n",
476 | " 1. Area\n",
477 | " 2. Perimeter\n",
478 | " 3. location of center of gravity\n",
479 | " 4. Moment of Inertia\n",
480 | " 5. Moment of Inertia with respect to axes\n",
481 | " 6. Moment of inertia on principal axes\n",
482 | "\n",
483 | "PS : Do not forget to upload your answer sheets to CE_103 Class on MS Teams.\n"
484 | ]
485 | }
486 | ],
487 | "metadata": {
488 | "kernelspec": {
489 | "display_name": "Python 3",
490 | "language": "python",
491 | "name": "python3"
492 | },
493 | "language_info": {
494 | "codemirror_mode": {
495 | "name": "ipython",
496 | "version": 3
497 | },
498 | "file_extension": ".py",
499 | "mimetype": "text/x-python",
500 | "name": "python",
501 | "nbconvert_exporter": "python",
502 | "pygments_lexer": "ipython3",
503 | "version": "3.6.8"
504 | }
505 | },
506 | "nbformat": 4,
507 | "nbformat_minor": 4
508 | }
509 |
--------------------------------------------------------------------------------
/.ipynb_checkpoints/CE103-Week13-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### CE 103- INTRODUCTION TO COMPUTERS and PROGRAMMING"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "# Week 13 _ In Class Assigment I\n",
15 | "\n",
16 | "\n",
17 | "Dear students, \n",
18 | "\n",
19 | "You have a week to complete your first In Class assignment. You will be working as teams, please be sure that all of you as a team member spend same effort for this assignment. \n",
20 | "\n",
21 | "Please follow the intructions below and do not hesitate to ask question, if any, during your process. \n",
22 | "\n",
23 | "1 - Download the \"Sensor Record\" application to your Android cell phones.\n",
24 | "\n",
25 | "\n",
26 | "\n",
27 | "\n",
28 | "2 - Run the application and select 'Accelerometer' to record data. This application will record your data and will save it as file in \".csv\" format. \n",
29 | "\n",
30 | "\n",
31 | "3 - Stand up and hold your phone tight in your hand. Withput rotating your hand, slowly make a pendulum action (minimum 3 seconds period) with arm by moving back and forth. Do repeat this movement at least for 30 seconds. \n",
32 | "\n",
33 | "\n",
34 | "\n",
35 | "\n",
36 | "4 - Transfer the movement record data to your PC. Analyse the data and plot time series figure. Calculate and plot the magnitude of your pendulum movement. \n",
37 | "\n",
38 | "**_Hints:_** \n",
39 | "\n",
40 | "a. Remember the theoritical information from CE105 course.\n",
41 | "\n",
42 | "b. You may want to read the reference paper below to get help in detail : \n",
43 | "\n",
44 | "\n",
45 | "https://www.researchgate.net/publication/313164057_Step_Counting_Using_Smartphone_Accelerometer_and_Fast_Fourier_Trransform\n",
46 | "\n"
47 | ]
48 | },
49 | {
50 | "cell_type": "markdown",
51 | "metadata": {},
52 | "source": [
53 | "---"
54 | ]
55 | }
56 | ],
57 | "metadata": {
58 | "kernelspec": {
59 | "display_name": "Python 3",
60 | "language": "python",
61 | "name": "python3"
62 | },
63 | "language_info": {
64 | "codemirror_mode": {
65 | "name": "ipython",
66 | "version": 3
67 | },
68 | "file_extension": ".py",
69 | "mimetype": "text/x-python",
70 | "name": "python",
71 | "nbconvert_exporter": "python",
72 | "pygments_lexer": "ipython3",
73 | "version": "3.6.8"
74 | }
75 | },
76 | "nbformat": 4,
77 | "nbformat_minor": 4
78 | }
79 |
--------------------------------------------------------------------------------
/.ipynb_checkpoints/CE103-Week14-checkpoint.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### CE 103- INTRODUCTION TO COMPUTERS and PROGRAMMING"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "# Week 14 _ In Class Assigment II\n",
15 | "\n",
16 | "\n",
17 | "Dear students, \n",
18 | "\n",
19 | "You have a week to complete your second In Class assignment. You will be working as teams, please be sure that all of you as a team member spend same effort for this assignment. \n",
20 | "\n",
21 | "\n",
22 | "**Title of the task: \"Create your own step counter (pedometer)\"**\n",
23 | "\n",
24 | "Please follow the intructions below and do not hesitate to ask question, if any, during your process. \n",
25 | "\n",
26 | "\n",
27 | "1 - Use the \"Sensor Record\" application that you used for the previous project.\n",
28 | "\n",
29 | "\n",
30 | "\n",
31 | "\n",
32 | "2 - Run the application and select 'Accelerometer' to record data and save it as file in \".csv\" format. \n",
33 | "\n",
34 | "\n",
35 | "3 - Stand up and start walking while holding your phone tight in your hand. If you start walking, your arms will move forth and backward similar to a pendulum. Interestingly, when you step your left foot forward, your right arm will be on forward, too. Next, your right foot will move with your left arm. The movement of your arms will eventually create a pendulum motion and also lateral translation. Do walk more then 2 minutes and count your steps. \n",
36 | "\n",
37 | "\n",
38 | "\n",
39 | "\n",
40 | "4 - Transfer the movement record data to your PC. Analyse the data and plot time series figure. Creeate your own step counting module. Conclude your assignment by comparing the steps you counted with the results from your data analysis.\n"
41 | ]
42 | },
43 | {
44 | "cell_type": "markdown",
45 | "metadata": {},
46 | "source": [
47 | "---"
48 | ]
49 | }
50 | ],
51 | "metadata": {
52 | "kernelspec": {
53 | "display_name": "Python 3",
54 | "language": "python",
55 | "name": "python3"
56 | },
57 | "language_info": {
58 | "codemirror_mode": {
59 | "name": "ipython",
60 | "version": 3
61 | },
62 | "file_extension": ".py",
63 | "mimetype": "text/x-python",
64 | "name": "python",
65 | "nbconvert_exporter": "python",
66 | "pygments_lexer": "ipython3",
67 | "version": "3.6.8"
68 | }
69 | },
70 | "nbformat": 4,
71 | "nbformat_minor": 4
72 | }
73 |
--------------------------------------------------------------------------------
/.ipynb_checkpoints/README-checkpoint.md:
--------------------------------------------------------------------------------
1 |
Gebze Technical University | Civil Engineering Department | CE_103 Introduction to computers and programming for civil engineers
2 |
3 |
4 |
--------------------------------------------------------------------------------
/CE103-Figures.drawio:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/CE103-Week00-Info.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "\n",
8 | "\n",
9 | "## GEBZE TECHNICAL UNIVERSITY - DEPARTMENT OF CIVIL ENGINEERING\n",
10 | "\n",
11 | "### CE 103 Introduction to Computers and Programming \n",
12 | "##### _2019-2020 Spring_\n",
13 | "\n",
14 | "This lecture meant to serve as an introduction to the Python programming for Civil Engineering undergraduate students. It has enriched content with solved examples based on specific Civil Engineering problems.\n",
15 | "\n",
16 | "---\n",
17 | "### Instructor : \n",
18 | "##### Dr. Ahu Kömeç Mutlu --> _ahumutlu@gtu.edu.tr_\n",
19 | "\n",
20 | "---\n",
21 | "### Teaching Assistants :\n",
22 | "##### Fırat Bezir --> _fbezir@gtu.edu.tr_\n",
23 | "\n",
24 | "##### Sezgin Sarak --> _sezginsarak@gtu.edu.tr_\n",
25 | "\n",
26 | "---\n",
27 | "\n",
28 | "### Textbook and Resources :\n",
29 | "_Introduction to Python for Science and Engineering, David J. Pine, CRC Press, 2019._\n",
30 | "\n",
31 | "_https://docs.python.org/3/tutorial/index.html_\n",
32 | "\n",
33 | "_https://docs.python.org/3/reference/index.html_\n",
34 | "\n",
35 | "---\n"
36 | ]
37 | },
38 | {
39 | "cell_type": "markdown",
40 | "metadata": {},
41 | "source": [
42 | "## Grading and Attendance\n",
43 | ""
44 | ]
45 | },
46 | {
47 | "cell_type": "markdown",
48 | "metadata": {},
49 | "source": [
50 | "## Syllabus\n",
51 | "-\n",
52 | "\n",
53 | "\n",
54 | "**Week 1 Theory :** Introduction to Python, launching Python, learning Github, Azure and Algorithm\n",
55 | "\n",
56 | "**Week 1 Lab :** Github - Jupyter settings \n",
57 | "\n",
58 | "---\n",
59 | "**Week 2 Theory :** Strings, Lists, Arrays and Dictionaries\n",
60 | "\n",
61 | "**Week 2 Lab :** _Coding applications_\n",
62 | "\n",
63 | "---\n",
64 | "**Week 3 Theory :** Numerical Routines NumPy\n",
65 | "\n",
66 | "**Wek 3 Lab :** _Coding applications_\n",
67 | "\n",
68 | "---\n",
69 | "**Week 4 Theory :** Conditionals ad Loops\n",
70 | "\n",
71 | "**Week 4 Lab :** _Coding applications_\n",
72 | "\n",
73 | "---\n",
74 | "**Week 5 Theory :** Plotting\n",
75 | "\n",
76 | "**Week 5 Lab :** _Coding applications_\n",
77 | "\n",
78 | "---\n",
79 | "**Week 6 Theory :** Functions\n",
80 | "\n",
81 | "**Week 6 Lab :** _Coding applications_\n",
82 | "\n",
83 | "---\n",
84 | "**Week 7 Theory :** Curve Fitting\n",
85 | "\n",
86 | "**Week 7 Lab :** _Coding applications_\n",
87 | "\n",
88 | "---\n",
89 | "**Week 8 Theory :** Numerical Routines SciPy\n",
90 | "\n",
91 | "**Week 8 Lab :** _Coding applications_\n",
92 | "\n",
93 | "---\n",
94 | "**Week 9 Theory :** File input and output\n",
95 | "\n",
96 | "**Week 9 Lab :** _Coding applications_\n",
97 | "\n",
98 | "---\n",
99 | "**Week 10 Theory :** Data manipulation and Analysis Pandas\n",
100 | "\n",
101 | "**Week 10 Lab :** _Coding applications_\n",
102 | "\n",
103 | "---\n",
104 | "**Week 11 Theory :** Getting Data from the Web\n",
105 | "\n",
106 | "**Week 11 Lab :** _Coding applications_\n",
107 | "\n",
108 | "---\n",
109 | "**Week 12 Theory :** Python Classes\n",
110 | "\n",
111 | "**Week 12 Lab :** _Coding applications_\n",
112 | "\n",
113 | "---\n",
114 | "**Week 13 Theory :** InClass Project - I \n",
115 | "\n",
116 | "**Week 13 Lab :** _Coding applications_\n",
117 | "\n",
118 | "---\n",
119 | "**Week 14 Theory :** InClass Project - II\n",
120 | "\n",
121 | "**Week 14 Lab :** _Coding applications_\n",
122 | "\n",
123 | "---\n",
124 | "**Week 15 Theory :** No class\n",
125 | "\n",
126 | "---\n",
127 | "**Week 16 Theory :** Final Exam\n",
128 | "\n",
129 | "---"
130 | ]
131 | },
132 | {
133 | "cell_type": "code",
134 | "execution_count": null,
135 | "metadata": {},
136 | "outputs": [],
137 | "source": []
138 | }
139 | ],
140 | "metadata": {
141 | "kernelspec": {
142 | "display_name": "Python 3",
143 | "language": "python",
144 | "name": "python3"
145 | },
146 | "language_info": {
147 | "codemirror_mode": {
148 | "name": "ipython",
149 | "version": 3
150 | },
151 | "file_extension": ".py",
152 | "mimetype": "text/x-python",
153 | "name": "python",
154 | "nbconvert_exporter": "python",
155 | "pygments_lexer": "ipython3",
156 | "version": "3.6.8"
157 | }
158 | },
159 | "nbformat": 4,
160 | "nbformat_minor": 4
161 | }
162 |
--------------------------------------------------------------------------------
/CE103-Week01.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### CE 103- INTRODUCTION TO COMPUTERS and PROGRAMMING"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "### _The topics of the week !_\n",
15 | "\n",
16 | "- Programming Algorithm\n",
17 | "- Launching Python, Variable, List\n",
18 | "- Interactive Python as a Calculator\n",
19 | "- Homework #1 assignment"
20 | ]
21 | },
22 | {
23 | "cell_type": "markdown",
24 | "metadata": {},
25 | "source": [
26 | "---\n",
27 | "## Programming Algorithm\n",
28 | "\n",
29 | "Algorithms tell the programmers how to code the program. It is important editting to a strong algorithm than coding a program. Flowchart represents a diagram that graphically depicts the steps in a program.An algorithm steps basically be like as below.\n",
30 | "\n",
31 | " \n",
32 | "\n",
33 | "Figure 1 : Flowchart diagram of basic programming seps. Ovals are terminal symbols, Parallelograms are input and output symbols, Rectangles are processing symbols, Symbols are connected by arrows that represent the flow of the program, Statements in a program execute in the order that they appear\n",
34 | "\n",
35 | "\n",
36 | "### Typical steps of programming:\n",
37 | "\n",
38 | ">Design the program\n",
39 | "\n",
40 | ">>Write the code\n",
41 | "\n",
42 | ">>>Correct syntax errors\n",
43 | "\n",
44 | ">>>>Test the program\n",
45 | "\n",
46 | ">>>>>Correct logic errors"
47 | ]
48 | },
49 | {
50 | "cell_type": "markdown",
51 | "metadata": {},
52 | "source": [
53 | "---\n",
54 | "## Introduction to Python\n",
55 | "\n",
56 | "Python is a open source general-purpose programming language. It is available across many platforms including Windows, Linux and Mac OS.\n",
57 | "\n",
58 | "The history of the Python programming language dates back to the late 1980s and its implementation was started in December 1989 by Guido van Rossum. \n",
59 | "\n",
60 | "The version of Python (i.e., Python 1.0) was introduced in 1991 and its eveluation has reached up to Version 3.x (till 2019).\n",
61 | "\n",
62 | "\n",
63 | "Figure 2 : Photograph of Guido van Rossum—Creator. (Image courtesy of Wikipedia.org)."
64 | ]
65 | },
66 | {
67 | "cell_type": "markdown",
68 | "metadata": {},
69 | "source": [
70 | "---\n",
71 | "## Scientific Tools of Python\n",
72 | "\n",
73 | "The Python ecosystem consists of these core scientific tools which are essential for analysing and simulating complex systems, these packages are SciPy library,SciPy, NumPy, Sympy and Matplotlib. **SciPy** library is mainly used for numerical integration and optimization. **NumPy** provides N-dimensional array objects which can be used to perform linear algebra, Fourier transform and other mathematical operations. **SymPy** library is used to generate symbolic mathematics. **Matplotlib** is the oldest and most popular plotting library available for Python. These tools are usefull for solving scientific problems.\n"
74 | ]
75 | },
76 | {
77 | "cell_type": "markdown",
78 | "metadata": {},
79 | "source": [
80 | "---\n",
81 | "## Launching Python \n",
82 | "\n"
83 | ]
84 | },
85 | {
86 | "cell_type": "markdown",
87 | "metadata": {},
88 | "source": [
89 | "There are several interfaces that allows us to use Python interactively. IPython, jupyter notebooks, anaconda spyder are some of them. But in this lecture we will use notebook.azure.com.\n",
90 | "\n",
91 | "You do not have to install Python on to your computer, all you need is internet accesss. "
92 | ]
93 | },
94 | {
95 | "cell_type": "markdown",
96 | "metadata": {},
97 | "source": [
98 | "---\n",
99 | "## Installing and Using Jupyter Notebook\n",
100 | "Jupyter Notebook is an open source web application that uses a browserbased interface and it is one of the many possible ways to interact with Python and the scientific libraries. \n",
101 | "\n",
102 | "You can :\n",
103 | "\n",
104 | "• create and share documents,\n",
105 | "\n",
106 | "• write and execute Python code,\n",
107 | "\n",
108 | "• include tables, figures, equation, visualizations, etc. with Jupyter which is fast processor in the scientific computing algorithms."
109 | ]
110 | },
111 | {
112 | "cell_type": "markdown",
113 | "metadata": {},
114 | "source": [
115 | "---\n",
116 | "## Python Programming Fundamentals\n",
117 | "\n",
118 | "Lets discuss the fundamentals of Python Programming language that we need to know to start writing basic Python codes. These are identifiers, keywords, variables and operators.\n",
119 | "\n",
120 | "### Identifiers\n",
121 | "An identifier is a name given to a variable, function, class or module. Here are the rules that we should know to set an identifier.\n",
122 | "\n",
123 | "• Can begin with an alphabet (A – Z and a – z and _) and be a combination of lowercase or uppercase or digits.\n",
124 | "\n",
125 | "• Do not start with a digit but can used in anywhere else such as legend1 can allow but 1legend is invalid.\n",
126 | "\n",
127 | "• Keywords cannot be used as identifiers.\n",
128 | "\n",
129 | "• Do not use spaces and special symbols like !, @, #, $, % etc. as identifiers.\n",
130 | "\n",
131 | "• Identifier can be of any length.\n",
132 | "\n",
133 | "### Keywords\n",
134 | "\n",
135 | "Keywords are a list of reserved words that have predefined meaning. They are special vocabulary and should not be use as an identifier name which will cause an error.\n",
136 | "\n",
137 | "\n",
138 | "\n",
139 | "### Variables\n",
140 | "\n",
141 | "Variable is a placeholder to hold any type of data.\n",
142 | "\n",
143 | "• Can consist of any number of letters, underscores and digits.\n",
144 | "\n",
145 | "• Should not start with a number.\n",
146 | "\n",
147 | "• Keywords are not assigned as variables\n",
148 | "\n",
149 | "• They are case-sensitive.\n",
150 | "\n",
151 | "***variable_name = expression***\n"
152 | ]
153 | },
154 | {
155 | "cell_type": "code",
156 | "execution_count": null,
157 | "metadata": {},
158 | "outputs": [],
159 | "source": [
160 | "# set a variable name\n",
161 | "number = 3\n",
162 | "road = \"D100\"\n",
163 | "name = 'Python'\n",
164 | "century = \"hundred\"\n",
165 | "\n",
166 | "# print them on to the screen\n",
167 | "number, road, name, century"
168 | ]
169 | },
170 | {
171 | "cell_type": "markdown",
172 | "metadata": {},
173 | "source": [
174 | "You can assign a single value to several variables simultaneously."
175 | ]
176 | },
177 | {
178 | "cell_type": "code",
179 | "execution_count": null,
180 | "metadata": {},
181 | "outputs": [],
182 | "source": [
183 | "a = b = c = 4\n",
184 | "a, b, c"
185 | ]
186 | },
187 | {
188 | "cell_type": "markdown",
189 | "metadata": {},
190 | "source": [
191 | "---\n",
192 | "### Operators\n",
193 | "\n",
194 | "Operators are symbols, such as +, –, =, >, and <. Python allows you to perform mathematical or logical operations to manipulate data values. and produce a result based on some rules.\n",
195 | "\n",
196 | "Python language supports a wide range of operators. \n",
197 | "\n",
198 | "\n",
199 | "#### 1. Arithmetic Operators\n",
200 | "\n",
201 | "\n",
202 | "Arithmetic operators are used to execute arithmetic operations such as addition, subtraction, division, multiplication etc.\n",
203 | "\n",
204 | " "
205 | ]
206 | },
207 | {
208 | "cell_type": "code",
209 | "execution_count": null,
210 | "metadata": {},
211 | "outputs": [],
212 | "source": [
213 | " 4 + 5"
214 | ]
215 | },
216 | {
217 | "cell_type": "code",
218 | "execution_count": null,
219 | "metadata": {},
220 | "outputs": [],
221 | "source": [
222 | "a = 3\n",
223 | "b = 5 \n",
224 | "c = 7\n",
225 | "\n",
226 | "a + b * c"
227 | ]
228 | },
229 | {
230 | "cell_type": "code",
231 | "execution_count": null,
232 | "metadata": {},
233 | "outputs": [],
234 | "source": [
235 | "# find answer of the equations below\n",
236 | "\n",
237 | "apple = a ** b\n",
238 | "orange = a / b * c + 3\n",
239 | "d = apple // orange\n",
240 | "\n",
241 | "apple, orange, d"
242 | ]
243 | },
244 | {
245 | "cell_type": "code",
246 | "execution_count": null,
247 | "metadata": {},
248 | "outputs": [],
249 | "source": [
250 | "# find the remainder of the \"apple/orange\"\n",
251 | "\n"
252 | ]
253 | },
254 | {
255 | "cell_type": "markdown",
256 | "metadata": {},
257 | "source": [
258 | "#### 2. Assignment Operators\n",
259 | "\n",
260 | "Assignment operators are used for assigning the values to a variable.\n",
261 | "\n"
262 | ]
263 | },
264 | {
265 | "cell_type": "code",
266 | "execution_count": null,
267 | "metadata": {},
268 | "outputs": [],
269 | "source": [
270 | "x = 5\n",
271 | "y = 8\n",
272 | "x + y"
273 | ]
274 | },
275 | {
276 | "cell_type": "markdown",
277 | "metadata": {},
278 | "source": [
279 | ""
280 | ]
281 | },
282 | {
283 | "cell_type": "code",
284 | "execution_count": null,
285 | "metadata": {},
286 | "outputs": [],
287 | "source": [
288 | "# run the operator below and recognize how x changec in each run\n",
289 | "x += 1\n",
290 | "x\n"
291 | ]
292 | },
293 | {
294 | "cell_type": "markdown",
295 | "metadata": {},
296 | "source": [
297 | "#### 3. Comparison Operators\n",
298 | "\n",
299 | "They are used to compare the values of two operands and output is always a Boolean value, either True or False\n",
300 | "\n",
301 | ""
302 | ]
303 | },
304 | {
305 | "cell_type": "code",
306 | "execution_count": null,
307 | "metadata": {},
308 | "outputs": [],
309 | "source": [
310 | "5 == 7"
311 | ]
312 | },
313 | {
314 | "cell_type": "markdown",
315 | "metadata": {},
316 | "source": [
317 | "---\n",
318 | "## Data Types\n",
319 | "\n",
320 | "Definition of the data type classifies and categorize data items. Its a way to understand which kind of value determines what operatoins can be performed. Different types of variable can do different things.\n",
321 | "\n",
322 | " - int (integers) (ex: 5,98,28829382983) \n",
323 | " - float (real numbers) (ex: 3.7)\n",
324 | " - bool (boolean values) (True or False)\n",
325 | " - NoneType (special) (None; has one value)\n",
326 | "\n",
327 | "You can check the type of your ariable by clling \"type\" command. Python allows you to convert your data from one type to another. "
328 | ]
329 | },
330 | {
331 | "cell_type": "code",
332 | "execution_count": null,
333 | "metadata": {},
334 | "outputs": [],
335 | "source": [
336 | "type(3)"
337 | ]
338 | },
339 | {
340 | "cell_type": "code",
341 | "execution_count": null,
342 | "metadata": {},
343 | "outputs": [],
344 | "source": [
345 | "type('hi')"
346 | ]
347 | },
348 | {
349 | "cell_type": "code",
350 | "execution_count": null,
351 | "metadata": {},
352 | "outputs": [],
353 | "source": [
354 | "# type conversion\n",
355 | "float(5)"
356 | ]
357 | },
358 | {
359 | "cell_type": "code",
360 | "execution_count": null,
361 | "metadata": {},
362 | "outputs": [],
363 | "source": [
364 | "# type conversion\n",
365 | "int(3.1)"
366 | ]
367 | },
368 | {
369 | "cell_type": "markdown",
370 | "metadata": {},
371 | "source": [
372 | "Lets go in detail with the basic data types below;\n",
373 | "\n",
374 | "### 1. Numbers\n",
375 | "\n",
376 | "Integers, floating point numbers and complex numbers are defined as int, float and complex class in Python. \n",
377 | "\n",
378 | "### 2. Boolean\n",
379 | "\n",
380 | "They are essential to set conditional statements which could be either True or False (treated as reserved words).\n",
381 | "\n",
382 | "### 3. String\n",
383 | "\n",
384 | "A string may consists letters, numbers, and other types of characters with spaces.\n",
385 | "\n",
386 | "You can check the type of your ariable by clling \"type\" command."
387 | ]
388 | },
389 | {
390 | "cell_type": "code",
391 | "execution_count": null,
392 | "metadata": {},
393 | "outputs": [],
394 | "source": [
395 | "x = [3.14]\n",
396 | "y = False\n",
397 | "\n",
398 | "print(type(x))\n",
399 | "print(type(y))"
400 | ]
401 | },
402 | {
403 | "cell_type": "markdown",
404 | "metadata": {},
405 | "source": [
406 | "---\n",
407 | "### 1. Types of numbers\n",
408 | "\n",
409 | "There ara basically three different types of numbers that we can use in Python.\n",
410 | "\n",
411 | "#### 1.1. Integers\n",
412 | "They can be positive or negative numbers which are written without decimals."
413 | ]
414 | },
415 | {
416 | "cell_type": "code",
417 | "execution_count": null,
418 | "metadata": {},
419 | "outputs": [],
420 | "source": [
421 | "(5 + 2) * 3 / 4"
422 | ]
423 | },
424 | {
425 | "cell_type": "code",
426 | "execution_count": null,
427 | "metadata": {},
428 | "outputs": [],
429 | "source": [
430 | "13 // 2"
431 | ]
432 | },
433 | {
434 | "cell_type": "code",
435 | "execution_count": null,
436 | "metadata": {},
437 | "outputs": [],
438 | "source": [
439 | "3828374649983 / 298374"
440 | ]
441 | },
442 | {
443 | "cell_type": "markdown",
444 | "metadata": {},
445 | "source": [
446 | "#### 1.2. Floats\n",
447 | "\n",
448 | "They are rational numbers with fractional parts."
449 | ]
450 | },
451 | {
452 | "cell_type": "code",
453 | "execution_count": null,
454 | "metadata": {},
455 | "outputs": [],
456 | "source": [
457 | "8.0 * 4"
458 | ]
459 | },
460 | {
461 | "cell_type": "code",
462 | "execution_count": null,
463 | "metadata": {},
464 | "outputs": [],
465 | "source": [
466 | "19. / 3"
467 | ]
468 | },
469 | {
470 | "cell_type": "code",
471 | "execution_count": null,
472 | "metadata": {},
473 | "outputs": [],
474 | "source": [
475 | "13. // 2"
476 | ]
477 | },
478 | {
479 | "cell_type": "code",
480 | "execution_count": null,
481 | "metadata": {},
482 | "outputs": [],
483 | "source": [
484 | "11. % 3"
485 | ]
486 | },
487 | {
488 | "cell_type": "code",
489 | "execution_count": null,
490 | "metadata": {},
491 | "outputs": [],
492 | "source": [
493 | "3.98e32 * 222"
494 | ]
495 | },
496 | {
497 | "cell_type": "markdown",
498 | "metadata": {},
499 | "source": [
500 | "#### 1.3. Complex Numbers\n",
501 | "\n",
502 | "Numbers with sum of real and imaginery parts. Use j instead of i which equals square root of -1. \n"
503 | ]
504 | },
505 | {
506 | "cell_type": "code",
507 | "execution_count": null,
508 | "metadata": {},
509 | "outputs": [],
510 | "source": [
511 | "(3 + 2j) * (4 - 2j)"
512 | ]
513 | },
514 | {
515 | "cell_type": "markdown",
516 | "metadata": {},
517 | "source": [
518 | "---\n",
519 | "## Homework #1\n",
520 | "\n",
521 | "1 - Design an algorithm for question 2 in Homework #1.\n",
522 | "\n",
523 | "2 - Write your first code that calculates your monthly budget for transportation. \n",
524 | " \n",
525 | " a ) Assume you are using Marmaray and paying 2.6 turkish liras for one way. \n",
526 | " \n",
527 | " b ) Assume that you are traveling by your own car and the gasoline costs 0.7 turkish liras per kilometer.\n",
528 | " \n",
529 | " c ) Calculate the differance between traveling by car and by Marmaray.\n",
530 | " \n",
531 | " PS: Please use your home location and GTU Civil Engineering Department building locations for distance calculations."
532 | ]
533 | },
534 | {
535 | "cell_type": "markdown",
536 | "metadata": {},
537 | "source": [
538 | "---"
539 | ]
540 | },
541 | {
542 | "cell_type": "code",
543 | "execution_count": null,
544 | "metadata": {},
545 | "outputs": [],
546 | "source": []
547 | }
548 | ],
549 | "metadata": {
550 | "kernelspec": {
551 | "display_name": "Python 3",
552 | "language": "python",
553 | "name": "python3"
554 | },
555 | "language_info": {
556 | "codemirror_mode": {
557 | "name": "ipython",
558 | "version": 3
559 | },
560 | "file_extension": ".py",
561 | "mimetype": "text/x-python",
562 | "name": "python",
563 | "nbconvert_exporter": "python",
564 | "pygments_lexer": "ipython3",
565 | "version": "3.6.8"
566 | }
567 | },
568 | "nbformat": 4,
569 | "nbformat_minor": 4
570 | }
571 |
--------------------------------------------------------------------------------
/CE103-Week04.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### CE 103- INTRODUCTION TO COMPUTERS and PROGRAMMING"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "### _The topics of the week !_\n",
15 | "\n",
16 | "- Conditionals and Loops\n",
17 | "\n",
18 | " - The **_\" if \"_** statement\n",
19 | " - The **_\" if else / elif\"_** statement\n",
20 | " - The **_\" for \"_** loop\n",
21 | " - **_\" break \"_**, **_\" continue \"_**, **_\" pass \"_** statements\n",
22 | " - The **_\" while \"_** statement\n",
23 | " - Nested Loops"
24 | ]
25 | },
26 | {
27 | "cell_type": "markdown",
28 | "metadata": {},
29 | "source": [
30 | "---\n",
31 | "\n",
32 | "In programming world, suc as in real world, sometimes we need to make decisions to move with next step. In Python, when we make a decision, so we can execute the next step of the code. This week we will learn to use decision makeing statements in Python programming language. \n",
33 | "\n",
34 | "In the code we use _conditionals_ to execute different lines of the code, as a way to repeat something, especially to say if its True or not. If the conditional is True, the loop will be infine, otherwise, if the code starts with False, means it will never run.\n",
35 | "\n",
36 | "\n",
37 | "### The **_\" if \"_** statement\n",
38 | "\n",
39 | "\" if \" statement is one of the most simple decision making statement. It is used to decide whether a certain statement is True or False. \n",
40 | "\n",
41 | "\n",
42 | "\n",
43 | "---\n",
44 | "\n",
45 | "Lets remember that Python supports the logical conditions listed below;\n",
46 | "\n",
47 | "\n",
48 | " Equal: a == b\n",
49 | " Not Equal: a != b\n",
50 | " Less than: a < b\n",
51 | " Less than or equal to: a <= b\n",
52 | " Greater than: a > b\n",
53 | " Greater than or equal to: a >= b\n",
54 | "\n"
55 | ]
56 | },
57 | {
58 | "cell_type": "code",
59 | "execution_count": null,
60 | "metadata": {},
61 | "outputs": [],
62 | "source": [
63 | "# write your first \"if\" statement\n",
64 | "# The colon (:) is required to seprarate the condition from the body. The line after the colon is also required and it stands for four spaces for indenting.\n",
65 | "\n",
66 | "a = 5\n",
67 | "b = 15\n",
68 | "if b > a:\n",
69 | " print('I\\'m bigger than you')"
70 | ]
71 | },
72 | {
73 | "cell_type": "code",
74 | "execution_count": null,
75 | "metadata": {},
76 | "outputs": [],
77 | "source": [
78 | "# using TABS and spaces make differences, such as:\n",
79 | "\n",
80 | "condition = False\n",
81 | "if condition:\n",
82 | " print('condition is True')\n",
83 | " print('condition is False') # this code will skip both print lines as long as acondition is False.\n",
84 | " \n",
85 | " \n",
86 | "condition = False\n",
87 | "if condition:\n",
88 | " print('condition is True')\n",
89 | "print('condition is False') # will print 'condition is False' regardless of whether condition is True or False\n",
90 | "\n",
91 | "condition = False\n",
92 | "if condition:\n",
93 | " print('condition is True')\n",
94 | " print('condition is False') # will appear \"IndentationError: unexpected indent\" error message"
95 | ]
96 | },
97 | {
98 | "cell_type": "code",
99 | "execution_count": null,
100 | "metadata": {},
101 | "outputs": [],
102 | "source": [
103 | "# lets try it with boolean expression\n",
104 | "\n",
105 | "action = 'jump'\n",
106 | "\n",
107 | "if action == 'jump':\n",
108 | " print('I would like to ', 5 * (action + '! '))"
109 | ]
110 | },
111 | {
112 | "cell_type": "code",
113 | "execution_count": null,
114 | "metadata": {},
115 | "outputs": [],
116 | "source": [
117 | "# make a decision about a number if its positive or not,\n",
118 | "\n",
119 | "A = 5\n",
120 | "if A > 0:\n",
121 | " print(A, \"is a positive number.\")\n",
122 | "\n",
123 | "A = -3\n",
124 | "if A < 0:\n",
125 | " print(A, \"is a negative number.\")"
126 | ]
127 | },
128 | {
129 | "cell_type": "markdown",
130 | "metadata": {},
131 | "source": [
132 | "---\n",
133 | "\n",
134 | "### The **_\" if else / elif \"_** statement\n",
135 | "\n",
136 | "\" if else\" statement is stands for a decision with two possible conclusion. If the statement is True follow 1st path, else follow the 2nd path. \n",
137 | "\n",
138 | ""
139 | ]
140 | },
141 | {
142 | "cell_type": "code",
143 | "execution_count": null,
144 | "metadata": {},
145 | "outputs": [],
146 | "source": [
147 | "# Lets write a very basic if else statement;\n",
148 | "\n",
149 | "a = 15\n",
150 | "b = 5\n",
151 | "if b > a:\n",
152 | " print('I\\'m bigger than you')\n",
153 | "else:\n",
154 | " print('No you are NOT !')"
155 | ]
156 | },
157 | {
158 | "cell_type": "code",
159 | "execution_count": null,
160 | "metadata": {},
161 | "outputs": [],
162 | "source": [
163 | "# lets try it with boolean expression\n",
164 | "\n",
165 | "#action = 'jump'\n",
166 | "action = 'walk'\n",
167 | "\n",
168 | "if action == 'jump':\n",
169 | " print('I would like to ', 5 * (action + '! '))\n",
170 | "else:\n",
171 | " print('Don\\'t want to', action, 'any more :(')"
172 | ]
173 | },
174 | {
175 | "cell_type": "code",
176 | "execution_count": null,
177 | "metadata": {},
178 | "outputs": [],
179 | "source": [
180 | "# Lets simplify the \" if \" statement above by using \"if else\" statement\n",
181 | "\n",
182 | "A = 5\n",
183 | "\n",
184 | "if A >= 0:\n",
185 | " print(A, \"is a positive number.\")\n",
186 | "else:\n",
187 | " print(A, \"is a negative number.\")"
188 | ]
189 | },
190 | {
191 | "cell_type": "markdown",
192 | "metadata": {},
193 | "source": [
194 | "---\n",
195 | "In order to chain conditions to each other to simplify/solve more complex logics \"elif\" can be used as a concentration version of else and if. \n",
196 | "If the _\" if \"_ statement condition is False, then the code will check the _\" elif \"_ condition on the next block, and so on. Even all of them are False, _\" else \"_ will be executed.\n",
197 | "\n",
198 | "\n"
199 | ]
200 | },
201 | {
202 | "cell_type": "code",
203 | "execution_count": null,
204 | "metadata": {},
205 | "outputs": [],
206 | "source": [
207 | "A = 5\n",
208 | "B = 8\n",
209 | "\n",
210 | "if A > 7:\n",
211 | " print(A, \"is greater than 7\")\n",
212 | "elif B > 7:\n",
213 | " print(B, \"is greater than 7.\")\n",
214 | "else:\n",
215 | " print('what is going on!!')"
216 | ]
217 | },
218 | {
219 | "cell_type": "markdown",
220 | "metadata": {},
221 | "source": [
222 | "Or, we can set more complex chain;"
223 | ]
224 | },
225 | {
226 | "cell_type": "code",
227 | "execution_count": null,
228 | "metadata": {},
229 | "outputs": [],
230 | "source": [
231 | "A = 4\n",
232 | "B = 8\n",
233 | "\n",
234 | "if A > 7 and B > 7 :\n",
235 | " print(\"Everything is awsome\")\n",
236 | "elif B > 7 or A < 5 :\n",
237 | " print(\"Confusing\")\n",
238 | "else:\n",
239 | " print('Nothing to do')"
240 | ]
241 | },
242 | {
243 | "cell_type": "markdown",
244 | "metadata": {},
245 | "source": [
246 | "---\n",
247 | "#### _Short hand statements;_"
248 | ]
249 | },
250 | {
251 | "cell_type": "code",
252 | "execution_count": null,
253 | "metadata": {},
254 | "outputs": [],
255 | "source": [
256 | "if a > b: print(\"a is greater than b\")"
257 | ]
258 | },
259 | {
260 | "cell_type": "code",
261 | "execution_count": null,
262 | "metadata": {},
263 | "outputs": [],
264 | "source": [
265 | "a = 3\n",
266 | "b = 5\n",
267 | "print(\"bigger a\") if a > b else print(\"smaller a\") "
268 | ]
269 | },
270 | {
271 | "cell_type": "code",
272 | "execution_count": null,
273 | "metadata": {},
274 | "outputs": [],
275 | "source": [
276 | "a = 5\n",
277 | "b = 5\n",
278 | "print(\"bigger a\") if a > b else print(\"a = b\") if a == b else print(\"smaller a\") "
279 | ]
280 | },
281 | {
282 | "cell_type": "code",
283 | "execution_count": null,
284 | "metadata": {},
285 | "outputs": [],
286 | "source": [
287 | "a = 6\n",
288 | "b = 5\n",
289 | "c = 8\n",
290 | "if a > b and c > a:\n",
291 | " print(\"c > a > b\")"
292 | ]
293 | },
294 | {
295 | "cell_type": "code",
296 | "execution_count": null,
297 | "metadata": {},
298 | "outputs": [],
299 | "source": [
300 | "a = 5\n",
301 | "b = 3\n",
302 | "c = 8\n",
303 | "if a > b or a > c:\n",
304 | " print(\"At least one of the conditions is True\")"
305 | ]
306 | },
307 | {
308 | "cell_type": "markdown",
309 | "metadata": {},
310 | "source": [
311 | "---\n",
312 | "### The **_\" for \"_** loop\n",
313 | "\n",
314 | "Loops are another type of flow control structure in programming language. By using loop conditions, a code can be repeated multiple times under specific conditions.\n",
315 | "\n",
316 | "\n"
317 | ]
318 | },
319 | {
320 | "cell_type": "code",
321 | "execution_count": null,
322 | "metadata": {},
323 | "outputs": [],
324 | "source": [
325 | "# define a list of values and iterate each of the values\n",
326 | "\n",
327 | "spring_semester = ['CE 102', 'CE 103', 'CE 105']\n",
328 | "\n",
329 | "for lectures in spring_semester: # searches for \"lecture\" variable in the list assigned to \"spring_semester\"\n",
330 | " print(lectures)"
331 | ]
332 | },
333 | {
334 | "cell_type": "code",
335 | "execution_count": null,
336 | "metadata": {},
337 | "outputs": [],
338 | "source": [
339 | "# Find the summation of the numbers in a list\n",
340 | "\n",
341 | "sum = 0 # what if I dit not define it?? \n",
342 | "\n",
343 | "digit = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # create the list\n",
344 | "\n",
345 | "for i in digit:\n",
346 | " sum = sum + i\n",
347 | "\n",
348 | "print(\"Sum = \", sum)"
349 | ]
350 | },
351 | {
352 | "cell_type": "code",
353 | "execution_count": null,
354 | "metadata": {},
355 | "outputs": [],
356 | "source": [
357 | "# for loop with else statement \n",
358 | "\n",
359 | "digits = [1, 3, 5, 7, 9, 11, 13]\n",
360 | "\n",
361 | "for i in digits:\n",
362 | " print(i)\n",
363 | "else:\n",
364 | " print(\"Listed them all\")"
365 | ]
366 | },
367 | {
368 | "cell_type": "code",
369 | "execution_count": null,
370 | "metadata": {},
371 | "outputs": [],
372 | "source": [
373 | "# create two column list output with for loop\n",
374 | "\n",
375 | "for x in range(8): # Generate numbers 0 to 8\n",
376 | " print(x, '\\t', x**2) # ('\\t') character makes the output align with tab between values "
377 | ]
378 | },
379 | {
380 | "cell_type": "markdown",
381 | "metadata": {},
382 | "source": [
383 | "---\n",
384 | "#### _**.keys( )**_ function"
385 | ]
386 | },
387 | {
388 | "cell_type": "code",
389 | "execution_count": null,
390 | "metadata": {},
391 | "outputs": [],
392 | "source": [
393 | "# do the same iteration in a dictionary using \".keys()\" function, which goes through each item in the dictionary.\n",
394 | "\n",
395 | "credits = {'CE 102': 2, 'CE 103': 3, 'CE 105': 3}\n",
396 | "\n",
397 | "for x in credits.keys(): # allows to iterate over each entry\n",
398 | " print(credits[x])"
399 | ]
400 | },
401 | {
402 | "cell_type": "markdown",
403 | "metadata": {},
404 | "source": [
405 | "---\n",
406 | "#### _**range( )**_ function"
407 | ]
408 | },
409 | {
410 | "cell_type": "code",
411 | "execution_count": null,
412 | "metadata": {},
413 | "outputs": [],
414 | "source": [
415 | "# range() function can be used to create basic loop as below;\n",
416 | "\n",
417 | "print(range(8))\n",
418 | "\n",
419 | "for i in range(8):\n",
420 | " print('count', i)"
421 | ]
422 | },
423 | {
424 | "cell_type": "code",
425 | "execution_count": null,
426 | "metadata": {},
427 | "outputs": [],
428 | "source": [
429 | "spring_semester = ['CE 102', 'CE 103', 'CE 105']\n",
430 | "\n",
431 | "for lectures in range(len(spring_semester)): # combine range() and len() functions, tries the range() function to the length of a list\n",
432 | " print(lectures)"
433 | ]
434 | },
435 | {
436 | "cell_type": "markdown",
437 | "metadata": {},
438 | "source": [
439 | "---\n",
440 | "#### _**enumerate( )**_ function"
441 | ]
442 | },
443 | {
444 | "cell_type": "code",
445 | "execution_count": null,
446 | "metadata": {},
447 | "outputs": [],
448 | "source": [
449 | "# enumerate() function is another way to access a a list and returns both item and index\n",
450 | "\n",
451 | "spring_semester = ['CE 102', 'CE 103', 'CE 105']\n",
452 | "\n",
453 | "for i, lectures in enumerate(spring_semester): # takes in a list and returns both the item and its index\n",
454 | " print(lectures + 'is a spring semester lecture' + str(i))"
455 | ]
456 | },
457 | {
458 | "cell_type": "markdown",
459 | "metadata": {},
460 | "source": [
461 | "---\n",
462 | "### The **_\" while \"_** statement\n",
463 | "\n",
464 | "A while loop statement is used to repeatedly iterate a block of target statement as long as the given expression is True. If the condition becomes False, the code will pass that line and will follow the loop. The while loop generally prefers for the conditions that we don't know the number of times to iterate.\n",
465 | "\n",
466 | ""
467 | ]
468 | },
469 | {
470 | "cell_type": "code",
471 | "execution_count": null,
472 | "metadata": {},
473 | "outputs": [],
474 | "source": [
475 | "a = 0\n",
476 | "while (a < 5): \n",
477 | " a = a + 1\n",
478 | " print(\"pisi\") # will print \"pisi\" as long as a < 5"
479 | ]
480 | },
481 | {
482 | "cell_type": "code",
483 | "execution_count": null,
484 | "metadata": {},
485 | "outputs": [],
486 | "source": [
487 | "a = [1, 3, 5, 7] \n",
488 | "while a: \n",
489 | " print(a.pop()) # will print items in a, till they exist"
490 | ]
491 | },
492 | {
493 | "cell_type": "code",
494 | "execution_count": null,
495 | "metadata": {},
496 | "outputs": [],
497 | "source": [
498 | "# Lets use \"else\" with \"while\" loop\n",
499 | "\n",
500 | "a = 0\n",
501 | "while a < 3:\n",
502 | " print(a, \" is less than 3\")\n",
503 | " a = a + 1\n",
504 | "else:\n",
505 | " print(a, \" is not less than 3\") "
506 | ]
507 | },
508 | {
509 | "cell_type": "code",
510 | "execution_count": null,
511 | "metadata": {},
512 | "outputs": [],
513 | "source": [
514 | "digit = 10\n",
515 | "\n",
516 | "sum = 0 # set sum as summation variable\n",
517 | "i = 1 # set \" i \" as a counter\n",
518 | " \n",
519 | "while i <= digit:\n",
520 | " sum = sum + i\n",
521 | " i = i+1 # increase counter\n",
522 | "\n",
523 | "print(\"The sum is\", sum) # calculate the summation of all numbers between 0 and 'digit', till 'digit' = 10. "
524 | ]
525 | },
526 | {
527 | "cell_type": "markdown",
528 | "metadata": {},
529 | "source": [
530 | "---\n",
531 | "### The **_\" break \"_** loop\n",
532 | "\n",
533 | "This statement terminates the current loop and proceed with next statement. It can be used with both for and while loops. \n"
534 | ]
535 | },
536 | {
537 | "cell_type": "code",
538 | "execution_count": null,
539 | "metadata": {},
540 | "outputs": [],
541 | "source": [
542 | "for numbers in '1234567890': \n",
543 | " if numbers == '5':\n",
544 | " break\n",
545 | " print('Current number is :', numbers) # will print out all the numbers till its equal 5"
546 | ]
547 | },
548 | {
549 | "cell_type": "code",
550 | "execution_count": null,
551 | "metadata": {},
552 | "outputs": [],
553 | "source": [
554 | "a = 6\n",
555 | "while a > 0: \n",
556 | " print('Current variable value :', a)\n",
557 | " a = a -1\n",
558 | " if a == 5:\n",
559 | " break\n",
560 | "print(\"That\\'s all!\") # will break the code when the condition \"a = 5\""
561 | ]
562 | },
563 | {
564 | "cell_type": "markdown",
565 | "metadata": {},
566 | "source": [
567 | "---\n",
568 | "### The **_\" continue \"_** loop\n",
569 | "\n",
570 | "This statement returns the control to the beginning of the loop and skip all the remaining statements. And, control moves to the beginning of the loop. It can be used with both for and while loops. "
571 | ]
572 | },
573 | {
574 | "cell_type": "code",
575 | "execution_count": null,
576 | "metadata": {},
577 | "outputs": [],
578 | "source": [
579 | "for numbers in '1234567890': \n",
580 | " if numbers == '5':\n",
581 | " continue\n",
582 | " print('Current number is :', numbers) # will not print out the '5'"
583 | ]
584 | },
585 | {
586 | "cell_type": "code",
587 | "execution_count": null,
588 | "metadata": {},
589 | "outputs": [],
590 | "source": [
591 | "a = 6\n",
592 | "while a > 0: \n",
593 | " print('Current variable value :', a)\n",
594 | " a = a -1\n",
595 | " if a == 5:\n",
596 | " continue\n",
597 | "print(\"That\\'s all!\") # will keep doing the condition again as long as \"a > 0\""
598 | ]
599 | },
600 | {
601 | "cell_type": "markdown",
602 | "metadata": {},
603 | "source": [
604 | "---\n",
605 | "### The **_\" pass \"_** loop\n",
606 | "\n",
607 | "The pass statement is used to write empty statements, functions or classes. It is a \"null\" opretion which means nothing happens when its executed. "
608 | ]
609 | },
610 | {
611 | "cell_type": "code",
612 | "execution_count": null,
613 | "metadata": {},
614 | "outputs": [],
615 | "source": [
616 | "for numbers in '1234567890': \n",
617 | " if numbers == '5':\n",
618 | " pass\n",
619 | " print('5 is my favorite number')\n",
620 | " print('Current number is :', numbers) # will not print out the '5'"
621 | ]
622 | },
623 | {
624 | "cell_type": "markdown",
625 | "metadata": {},
626 | "source": [
627 | "---\n",
628 | "### The Nested Loops\n",
629 | "\n",
630 | "A loop inside another loop is called _\"Nested Loop\"_, which is allowed in Python. If you have while/for loop inside any loop, this is also allowed."
631 | ]
632 | },
633 | {
634 | "cell_type": "markdown",
635 | "metadata": {},
636 | "source": [
637 | "---\n",
638 | "#### _Nested If_\n",
639 | "\n",
640 | "If you have if statement inside if statement, this is called nested if statements.\n"
641 | ]
642 | },
643 | {
644 | "cell_type": "code",
645 | "execution_count": null,
646 | "metadata": {},
647 | "outputs": [],
648 | "source": [
649 | "a = 300\n",
650 | "\n",
651 | "if a > 10:\n",
652 | " print(\"Above ten,\")\n",
653 | " if a > 50:\n",
654 | " print(\"and also above 100!\")\n",
655 | " else:\n",
656 | " print(\"but not above 50.\") "
657 | ]
658 | },
659 | {
660 | "cell_type": "code",
661 | "execution_count": null,
662 | "metadata": {},
663 | "outputs": [],
664 | "source": [
665 | "a = -5\n",
666 | "if a >= 0:\n",
667 | " if a == 0:\n",
668 | " print(\"Zero\")\n",
669 | " else:\n",
670 | " print(\"Positive number\")\n",
671 | "else:\n",
672 | " print(\"Negative number\")"
673 | ]
674 | },
675 | {
676 | "cell_type": "markdown",
677 | "metadata": {},
678 | "source": [
679 | "---\n",
680 | "#### _Nested while/for_\n",
681 | "\n",
682 | "\n"
683 | ]
684 | },
685 | {
686 | "cell_type": "code",
687 | "execution_count": null,
688 | "metadata": {},
689 | "outputs": [],
690 | "source": [
691 | "# Lets find prime numbers between 1 to 50\n",
692 | "i = 1\n",
693 | "while(i < 50):\n",
694 | " j = 2\n",
695 | " while(j <= (i/j)):\n",
696 | " if not(i%j): \n",
697 | " break\n",
698 | " j = j + 1\n",
699 | " if (j > i/j) : \n",
700 | " print(i, \" is prime\")\n",
701 | " i = i + 1"
702 | ]
703 | },
704 | {
705 | "cell_type": "code",
706 | "execution_count": null,
707 | "metadata": {},
708 | "outputs": [],
709 | "source": []
710 | },
711 | {
712 | "cell_type": "markdown",
713 | "metadata": {},
714 | "source": [
715 | "## Homework #4\n",
716 | "---\n",
717 | "\n",
718 | "Assume you roll a dice 100 times randomly and calculate the summation of the values of the dice you roll. \n",
719 | "\n",
720 | "PS: Do not forget to upload your pdf files to http://derskutusu.gtu.edu.tr/\n",
721 | "\n",
722 | "---"
723 | ]
724 | },
725 | {
726 | "cell_type": "code",
727 | "execution_count": null,
728 | "metadata": {},
729 | "outputs": [],
730 | "source": []
731 | }
732 | ],
733 | "metadata": {
734 | "kernelspec": {
735 | "display_name": "Python 3",
736 | "language": "python",
737 | "name": "python3"
738 | },
739 | "language_info": {
740 | "codemirror_mode": {
741 | "name": "ipython",
742 | "version": 3
743 | },
744 | "file_extension": ".py",
745 | "mimetype": "text/x-python",
746 | "name": "python",
747 | "nbconvert_exporter": "python",
748 | "pygments_lexer": "ipython3",
749 | "version": "3.6.8"
750 | }
751 | },
752 | "nbformat": 4,
753 | "nbformat_minor": 4
754 | }
755 |
--------------------------------------------------------------------------------
/CE103-Week06.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### CE 103- INTRODUCTION TO COMPUTERS and PROGRAMMING"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "### _The topics of the week !_\n",
15 | "\n",
16 | "- Functions\n",
17 | " \n",
18 | "A function is a code block written to carry out a specified task, which similar with modules. Functions define in the code body, no need to import. They are generally not predefined modules. \n",
19 | "\n",
20 | "You can install a new module you need by simply using \"pip\" and call it by using \"import\" command. But you may need more complicated or specific problem to solve, than you may need your own module. \n",
21 | "\n",
22 | "With the help of **\"Functions\"**, a program break into smaller codes. So, as your program becomes longer, \"Functions\" help you to manage and organize a readable code. You can all a function more than once.\n",
23 | "\n",
24 | ""
25 | ]
26 | },
27 | {
28 | "cell_type": "code",
29 | "execution_count": 1,
30 | "metadata": {},
31 | "outputs": [],
32 | "source": [
33 | "## SYNTAX ##\n",
34 | "\n",
35 | "def function_name( arguments ):\n",
36 | " \"function_docstring\"\n",
37 | " function_body\n",
38 | " return [expression]"
39 | ]
40 | },
41 | {
42 | "cell_type": "markdown",
43 | "metadata": {},
44 | "source": [
45 | "## _How Functions work in Python?_\n",
46 | "\n",
47 | "There are three types of functions in Python;\n",
48 | "\n",
49 | "**1. Built-in Functions :** \n",
50 | " These functions are always available. No need to import any module. Such as: abs(), bool(), eval(), max(), print(), help(), sum(), type().\n",
51 | "For the full list of Built-in functions, visit --> https://docs.python.org/3/library/functions.html"
52 | ]
53 | },
54 | {
55 | "cell_type": "code",
56 | "execution_count": 2,
57 | "metadata": {},
58 | "outputs": [
59 | {
60 | "data": {
61 | "text/plain": [
62 | "10"
63 | ]
64 | },
65 | "execution_count": 2,
66 | "metadata": {},
67 | "output_type": "execute_result"
68 | }
69 | ],
70 | "source": [
71 | "sum([4,6])"
72 | ]
73 | },
74 | {
75 | "cell_type": "markdown",
76 | "metadata": {},
77 | "source": [
78 | "**2. Anonymous Functions :**\n",
79 | " They are also called \"lambda\" functions, they do not use \"def\" keyword. It has no name.\n",
80 | " "
81 | ]
82 | },
83 | {
84 | "cell_type": "code",
85 | "execution_count": 3,
86 | "metadata": {},
87 | "outputs": [
88 | {
89 | "name": "stdout",
90 | "output_type": "stream",
91 | "text": [
92 | "Value of total : 8\n"
93 | ]
94 | }
95 | ],
96 | "source": [
97 | "# Syntax --> lambda [arg1 [,arg2,.....argn]]:expression\n",
98 | "\n",
99 | "sum = lambda arg1, arg2: arg1 + arg2;\n",
100 | "\n",
101 | "print(\"Value of total : \", sum( 3, 5 )) # call sum as a function"
102 | ]
103 | },
104 | {
105 | "cell_type": "code",
106 | "execution_count": 4,
107 | "metadata": {},
108 | "outputs": [
109 | {
110 | "data": {
111 | "text/plain": [
112 | "81"
113 | ]
114 | },
115 | "execution_count": 4,
116 | "metadata": {},
117 | "output_type": "execute_result"
118 | }
119 | ],
120 | "source": [
121 | "square = lambda x:x**2 # x is argument, x**2 is expression\n",
122 | "\n",
123 | "square(9)"
124 | ]
125 | },
126 | {
127 | "cell_type": "markdown",
128 | "metadata": {},
129 | "source": [
130 | "**3. Used-Defined Functions (UDFs) :**\n",
131 | " These are functions that users create by using **_\" def \"_** command. Functions name should be unique. A Function starts with **_\" def \"_** keyword and a colon **_\" (:) \"_** marks the end of header line. They might or might not need multiple inputs, which are called Parameters or Arguments: information that are passed into a function. A parameter is the variable listed inside the paranthesis and Argument is the value that sent to the function. A function should execute the statement defined by user. It ends with **_\" return \"_** statement if it should output something, otherwise, it will return an object None. The **_\" return \"_** statement is also used to exit a function. "
132 | ]
133 | },
134 | {
135 | "cell_type": "code",
136 | "execution_count": 5,
137 | "metadata": {},
138 | "outputs": [],
139 | "source": [
140 | "def function_name(parameters): \n",
141 | " statement(s) # is called the body of the function\n",
142 | " return"
143 | ]
144 | },
145 | {
146 | "cell_type": "code",
147 | "execution_count": 6,
148 | "metadata": {},
149 | "outputs": [],
150 | "source": [
151 | "# Lets define a square function with UDFs to see the difference between the \"lambda function\".\n",
152 | "\n",
153 | "def square(x):\n",
154 | " return x**2"
155 | ]
156 | },
157 | {
158 | "cell_type": "markdown",
159 | "metadata": {},
160 | "source": [
161 | "---\n",
162 | "## _Define a Function_\n",
163 | "\n",
164 | "*** _In this lecture, from know on, all the words called \"Functions\", refers to the \"used-defined functions (UDFs)\"._"
165 | ]
166 | },
167 | {
168 | "cell_type": "code",
169 | "execution_count": 7,
170 | "metadata": {},
171 | "outputs": [],
172 | "source": [
173 | "def welcome(name):\n",
174 | " print(\"Welcome \" + name + \" !\")\n",
175 | " return"
176 | ]
177 | },
178 | {
179 | "cell_type": "code",
180 | "execution_count": 8,
181 | "metadata": {},
182 | "outputs": [],
183 | "source": [
184 | "# A function could be more complex: for example; contain for loops\n",
185 | "\n",
186 | "def order():\n",
187 | " name = str(input(\"What would you like to eat as dessert?: \"))\n",
188 | " if name:\n",
189 | " print (\"You ordered: \" + str(name))\n",
190 | " else:\n",
191 | " print(\"St Sebastian Cheese-Cake\") \n",
192 | " return # return command is not necessery here."
193 | ]
194 | },
195 | {
196 | "cell_type": "markdown",
197 | "metadata": {},
198 | "source": [
199 | "---\n",
200 | "## _Call a Function_\n",
201 | "\n",
202 | "Use the function name and parenthesis as shown in the example below, to call a function."
203 | ]
204 | },
205 | {
206 | "cell_type": "markdown",
207 | "metadata": {},
208 | "source": [
209 | "### function_name([arguments])"
210 | ]
211 | },
212 | {
213 | "cell_type": "code",
214 | "execution_count": 9,
215 | "metadata": {},
216 | "outputs": [
217 | {
218 | "data": {
219 | "text/plain": [
220 | "25"
221 | ]
222 | },
223 | "execution_count": 9,
224 | "metadata": {},
225 | "output_type": "execute_result"
226 | }
227 | ],
228 | "source": [
229 | "square(5)"
230 | ]
231 | },
232 | {
233 | "cell_type": "code",
234 | "execution_count": 10,
235 | "metadata": {},
236 | "outputs": [
237 | {
238 | "name": "stdout",
239 | "output_type": "stream",
240 | "text": [
241 | "Welcome Home !\n"
242 | ]
243 | }
244 | ],
245 | "source": [
246 | "welcome(\"Home\")"
247 | ]
248 | },
249 | {
250 | "cell_type": "code",
251 | "execution_count": 11,
252 | "metadata": {},
253 | "outputs": [
254 | {
255 | "name": "stdin",
256 | "output_type": "stream",
257 | "text": [
258 | "What would you like to eat as dessert?: \n"
259 | ]
260 | },
261 | {
262 | "name": "stdout",
263 | "output_type": "stream",
264 | "text": [
265 | "St Sebastian Cheese-Cake\n"
266 | ]
267 | }
268 | ],
269 | "source": [
270 | "order()"
271 | ]
272 | },
273 | {
274 | "cell_type": "code",
275 | "execution_count": null,
276 | "metadata": {},
277 | "outputs": [],
278 | "source": [
279 | "# Lets define a function that checks even a number is positive or negative\n",
280 | "\n",
281 | "def test():\n",
282 | " num = int(input(\"Write a number: \"))\n",
283 | " if (num >= 0):\n",
284 | " print(\"The number you entered is POSITIVE\")\n",
285 | " else:\n",
286 | " print(\"The number you entered is NEGATIVE\")\n",
287 | " return\n",
288 | "test()"
289 | ]
290 | },
291 | {
292 | "cell_type": "markdown",
293 | "metadata": {},
294 | "source": [
295 | "---\n",
296 | "## _Arguments_\n",
297 | "\n",
298 | "We already learned what is \"Argument\" stands for above. Its important to call function with correct number of arguments. Meaning that; the number of the arguments that function expects should be equal to the number of arguments that you call in function. "
299 | ]
300 | },
301 | {
302 | "cell_type": "code",
303 | "execution_count": 13,
304 | "metadata": {},
305 | "outputs": [
306 | {
307 | "name": "stdout",
308 | "output_type": "stream",
309 | "text": [
310 | "Jelly+fish = Jellyfish\n"
311 | ]
312 | }
313 | ],
314 | "source": [
315 | "# Lets define a function expects 2 arguments and gets 2 arguments;\n",
316 | "\n",
317 | "def compound(first,second):\n",
318 | " print(first + '+' + second + \" = \" + first + \"\" + second)\n",
319 | "\n",
320 | "compound(\"Jelly\",\"fish\")\n"
321 | ]
322 | },
323 | {
324 | "cell_type": "markdown",
325 | "metadata": {},
326 | "source": [
327 | "#### There are four types of Arguments;\n",
328 | "**1. Default Arguments**\n",
329 | " Assumes a default value if a value is not provided in the function.\n",
330 | " "
331 | ]
332 | },
333 | {
334 | "cell_type": "code",
335 | "execution_count": 14,
336 | "metadata": {},
337 | "outputs": [
338 | {
339 | "data": {
340 | "text/plain": [
341 | "8"
342 | ]
343 | },
344 | "execution_count": 14,
345 | "metadata": {},
346 | "output_type": "execute_result"
347 | }
348 | ],
349 | "source": [
350 | "def defarg(x, y=5): # two argument is given one of them is \"default\", function asks for only one \n",
351 | " return (x * y)\n",
352 | "\n",
353 | "defarg(4, y=2) "
354 | ]
355 | },
356 | {
357 | "cell_type": "markdown",
358 | "metadata": {},
359 | "source": [
360 | "**2. Required Arguments** (also called \"Positional Arguments\")\n",
361 | " the number of arguments in the function has to be in correct positional order and should match with the function definition."
362 | ]
363 | },
364 | {
365 | "cell_type": "code",
366 | "execution_count": 15,
367 | "metadata": {},
368 | "outputs": [
369 | {
370 | "data": {
371 | "text/plain": [
372 | "3.0"
373 | ]
374 | },
375 | "execution_count": 15,
376 | "metadata": {},
377 | "output_type": "execute_result"
378 | }
379 | ],
380 | "source": [
381 | "def div(x,y): \n",
382 | " return x / y # change in order will effect the result\n",
383 | "\n",
384 | "div(9,3)"
385 | ]
386 | },
387 | {
388 | "cell_type": "markdown",
389 | "metadata": {},
390 | "source": [
391 | "**3. Keyword Arguments**\n",
392 | " If you don't want to keep the right order of parameters in your mind, its easy way to identify arguments by using parameter names."
393 | ]
394 | },
395 | {
396 | "cell_type": "code",
397 | "execution_count": 16,
398 | "metadata": {},
399 | "outputs": [
400 | {
401 | "data": {
402 | "text/plain": [
403 | "2.5"
404 | ]
405 | },
406 | "execution_count": 16,
407 | "metadata": {},
408 | "output_type": "execute_result"
409 | }
410 | ],
411 | "source": [
412 | "# lets call the \"div()\" function again\n",
413 | "\n",
414 | "div(x=5, y=2) # Call function with keyword arguments"
415 | ]
416 | },
417 | {
418 | "cell_type": "code",
419 | "execution_count": 17,
420 | "metadata": {},
421 | "outputs": [
422 | {
423 | "data": {
424 | "text/plain": [
425 | "2.5"
426 | ]
427 | },
428 | "execution_count": 17,
429 | "metadata": {},
430 | "output_type": "execute_result"
431 | }
432 | ],
433 | "source": [
434 | "div(y=2, x=5) # with keyword arguments, parameters do not have t be in ordered"
435 | ]
436 | },
437 | {
438 | "cell_type": "code",
439 | "execution_count": 18,
440 | "metadata": {},
441 | "outputs": [
442 | {
443 | "name": "stdout",
444 | "output_type": "stream",
445 | "text": [
446 | "The first mounth of summer is June\n"
447 | ]
448 | }
449 | ],
450 | "source": [
451 | "# if you send the arguments with the key = value syntax, the order of the arguments doesn't matter.\n",
452 | "\n",
453 | "def summer(second, third, first):\n",
454 | " print(\"The first mounth of summer is \" + first)\n",
455 | "\n",
456 | "summer(first = \"June\", second = \"July\", third = \"August\") "
457 | ]
458 | },
459 | {
460 | "cell_type": "markdown",
461 | "metadata": {},
462 | "source": [
463 | "**4. Arbitrary Arguments**\n",
464 | " If you don't have any idea about the exact number of arguments to call the function, then you can use **\" *args \"** syntax."
465 | ]
466 | },
467 | {
468 | "cell_type": "code",
469 | "execution_count": 19,
470 | "metadata": {},
471 | "outputs": [
472 | {
473 | "name": "stdout",
474 | "output_type": "stream",
475 | "text": [
476 | "Keep\n",
477 | " your\n",
478 | " social\n",
479 | " distance\n",
480 | " !\n"
481 | ]
482 | }
483 | ],
484 | "source": [
485 | "def message(*argv): \n",
486 | " for arg in argv: \n",
487 | " print(arg) \n",
488 | "\n",
489 | "message(\"Keep\",\" your\",\" social\",\" distance\",\" !\")"
490 | ]
491 | },
492 | {
493 | "cell_type": "markdown",
494 | "metadata": {},
495 | "source": [
496 | "---\n",
497 | "## _The \"return\" Statement_\n",
498 | "\n",
499 | "Simply it prints the result to the console. But, if you want to assign the result to a variable, the return statement sends a result back to the caller and exist the function."
500 | ]
501 | },
502 | {
503 | "cell_type": "code",
504 | "execution_count": 20,
505 | "metadata": {},
506 | "outputs": [
507 | {
508 | "name": "stdout",
509 | "output_type": "stream",
510 | "text": [
511 | "15\n"
512 | ]
513 | }
514 | ],
515 | "source": [
516 | "# lets define a total function which calculates the summation of numbers between two specific numbers\n",
517 | "\n",
518 | "def total(num1, num2):\n",
519 | " sum = 0\n",
520 | " for i in range(num1, num2 + 1):\n",
521 | " sum += i\n",
522 | " return sum\n",
523 | "\n",
524 | "t = total(1, 5)\n",
525 | "print(t)\n"
526 | ]
527 | },
528 | {
529 | "cell_type": "markdown",
530 | "metadata": {},
531 | "source": [
532 | "---\n",
533 | "## _Recursive Function_"
534 | ]
535 | },
536 | {
537 | "cell_type": "markdown",
538 | "metadata": {},
539 | "source": [
540 | "A function can call other functions or can call itself either. These type of functions are called _recursive functions_.\n",
541 | "\n",
542 | "These functions make the code look elegant but its hard to follow the logic behind."
543 | ]
544 | },
545 | {
546 | "cell_type": "code",
547 | "execution_count": 25,
548 | "metadata": {},
549 | "outputs": [
550 | {
551 | "name": "stdout",
552 | "output_type": "stream",
553 | "text": [
554 | "5 * 4 * 3 * 2 * n = 1\n"
555 | ]
556 | },
557 | {
558 | "data": {
559 | "text/plain": [
560 | "120"
561 | ]
562 | },
563 | "execution_count": 25,
564 | "metadata": {},
565 | "output_type": "execute_result"
566 | }
567 | ],
568 | "source": [
569 | "def factorial(n): # define recursive function\n",
570 | " if n == 1: \n",
571 | " print(\"n = \", n)\n",
572 | " return n \n",
573 | " else:\n",
574 | " print (n,'*', end = \" \") \n",
575 | " return n * factorial(n-1)\n",
576 | "\n",
577 | "factorial(5)"
578 | ]
579 | },
580 | {
581 | "cell_type": "code",
582 | "execution_count": 22,
583 | "metadata": {},
584 | "outputs": [
585 | {
586 | "name": "stdout",
587 | "output_type": "stream",
588 | "text": [
589 | "12 10 8 6 4 2 2 4 6 8 10 12 "
590 | ]
591 | }
592 | ],
593 | "source": [
594 | "def mirror(x):\n",
595 | " if (x < 1):\n",
596 | " return\n",
597 | " else:\n",
598 | " print( x,end = \" \")\n",
599 | " mirror(x-2)\n",
600 | " print(x,end = \" \")\n",
601 | " return\n",
602 | "x = 12\n",
603 | "mirror(x)"
604 | ]
605 | },
606 | {
607 | "cell_type": "markdown",
608 | "metadata": {},
609 | "source": [
610 | "---\n",
611 | "## _Global and Local Variables_\n",
612 | "\n",
613 | "A variable declared inside a function is called **_local variable_**, while a variable not bound to any function but can be accessed outside the function is called **_global variable_**."
614 | ]
615 | },
616 | {
617 | "cell_type": "code",
618 | "execution_count": 23,
619 | "metadata": {},
620 | "outputs": [
621 | {
622 | "name": "stdout",
623 | "output_type": "stream",
624 | "text": [
625 | "15\n"
626 | ]
627 | }
628 | ],
629 | "source": [
630 | "global_var = 3\n",
631 | "\n",
632 | "def cool():\n",
633 | " local_var = 5 # local variable\n",
634 | " print(global_var * local_var) # both variables are accessible from inside\n",
635 | "\n",
636 | "cool() \n",
637 | " # when function ends, local_var is destroyed\n",
638 | "#print(local_var) # but you can't access local_var outside the function"
639 | ]
640 | },
641 | {
642 | "cell_type": "markdown",
643 | "metadata": {},
644 | "source": [
645 | "---\n",
646 | "## _BONUS_ function\n",
647 | "\n",
648 | "#### **map() function**"
649 | ]
650 | },
651 | {
652 | "cell_type": "code",
653 | "execution_count": 24,
654 | "metadata": {},
655 | "outputs": [
656 | {
657 | "data": {
658 | "text/plain": [
659 | "[1.0, 2.0, 3.0, 4.0, 5.0]"
660 | ]
661 | },
662 | "execution_count": 24,
663 | "metadata": {},
664 | "output_type": "execute_result"
665 | }
666 | ],
667 | "source": [
668 | "# map() function; applies a function to every item in the array, if you have \"list\" of values\n",
669 | "# Lets define \"div()\" function again\n",
670 | "\n",
671 | "def div(x,y=2): \n",
672 | " return x / y\n",
673 | "\n",
674 | "data = [2, 4, 6, 8, 10] # declare an array of numbers\n",
675 | "list(map(div,data)) # no need to write a loop "
676 | ]
677 | },
678 | {
679 | "cell_type": "markdown",
680 | "metadata": {},
681 | "source": [
682 | "---\n",
683 | "## Homework #6\n",
684 | "\n",
685 | "Please visit https://covid19.saglik.gov.tr/ web page and get the information you need for your assignment. By using this data, lets make some statistics about the COVID-19 spreading speed in Turkey. Please follow the instructions below;\n",
686 | "\n",
687 | "1. Define a function which calculates \"percentage\".\n",
688 | "2. Get the daily based numbers for covid-19 cases, deaths, recovered people and covid-tests. \n",
689 | "3. Calculate percentages between case-death in daily bases and draw a graph. \n",
690 | "\n",
691 | "You are free to use any type of visualization, use your imagination. The shortest code will get extra point. \n",
692 | "\n",
693 | "PS: Do not forget to upload your pdf files to Microsoft Teams-CE103 Class.\n",
694 | "\n",
695 | "The attached screenshots will guide you to get the numeric data you need from the https://covid19.saglik.gov.tr/ web page. \n",
696 | "\n",
697 | "\n",
698 | "\n",
699 | "---"
700 | ]
701 | },
702 | {
703 | "cell_type": "code",
704 | "execution_count": null,
705 | "metadata": {},
706 | "outputs": [],
707 | "source": []
708 | }
709 | ],
710 | "metadata": {
711 | "kernelspec": {
712 | "display_name": "Python 3",
713 | "language": "python",
714 | "name": "python3"
715 | },
716 | "language_info": {
717 | "codemirror_mode": {
718 | "name": "ipython",
719 | "version": 3
720 | },
721 | "file_extension": ".py",
722 | "mimetype": "text/x-python",
723 | "name": "python",
724 | "nbconvert_exporter": "python",
725 | "pygments_lexer": "ipython3",
726 | "version": "3.6.8"
727 | }
728 | },
729 | "nbformat": 4,
730 | "nbformat_minor": 4
731 | }
732 |
--------------------------------------------------------------------------------
/CE103-Week12.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### CE 103- INTRODUCTION TO COMPUTERS and PROGRAMMING"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "### _The topics of the week !_\n",
15 | "\n",
16 | "- Object Oriented Programming\n",
17 | " - CLASSES & OBJECTS\n",
18 | "\n",
19 | "\n",
20 | "Python is an object oriented programming language. **_Object Oriented Programming_** can be thought of as simply adapting real life to programming. For example, let's imagine that we prepared building stock software. For this, \"reinforced concrete\", \"steel\" and \"masonry\" must be created as **_objects_**. In order to realize such a system by programming, we actually need to define the structure of each object and then produce objects from these structures. When we look around, we see that each item is actually an object. These objects have different properties (**_attributes_**) and functions (**_methods_**).\n",
21 | "\n",
22 | "In order to create our own data types and to produce objects from these data types, we first need to define the structure in which we will produce the objects. This structure is called **_\"class\"_**. Classes are a structure where we define the properties and methods of objects while creating our **_objects_**. The property of \"Reinforced Concrete\" object can be exemplified as strength and its function can be exemplified as modulus of elasticity.\n",
23 | "\n",
24 | "Classes are used to define groups or sets with common properties. For example, all cars have features such as a brand, model, price, color.\n",
25 | "\n",
26 | "### _\" CLASS \"_ a code template for creating objects.\n",
27 | "\n",
28 | "### _\" OBJECT \"_ the instance of the class"
29 | ]
30 | },
31 | {
32 | "cell_type": "markdown",
33 | "metadata": {},
34 | "source": [
35 | "---"
36 | ]
37 | },
38 | {
39 | "cell_type": "code",
40 | "execution_count": 85,
41 | "metadata": {},
42 | "outputs": [
43 | {
44 | "name": "stdout",
45 | "output_type": "stream",
46 | "text": [
47 | "<__main__.MyClass_Name object at 0x7f9dc84320f0>\n"
48 | ]
49 | }
50 | ],
51 | "source": [
52 | "# Python uses word \"class\" to define an empty class with no functionalities\n",
53 | "\n",
54 | "class MyClass_Name:\n",
55 | " '''This is a docstring line for description'''\n",
56 | " pass\n",
57 | "\n",
58 | "instanse = MyClass_Name() # object is created using the constructor of class\n",
59 | "print(instanse)"
60 | ]
61 | },
62 | {
63 | "cell_type": "markdown",
64 | "metadata": {},
65 | "source": [
66 | "# Class definition"
67 | ]
68 | },
69 | {
70 | "cell_type": "code",
71 | "execution_count": 86,
72 | "metadata": {},
73 | "outputs": [],
74 | "source": [
75 | "class firstclass():\n",
76 | " 'Lest define a class'\n",
77 | " pass\n"
78 | ]
79 | },
80 | {
81 | "cell_type": "markdown",
82 | "metadata": {},
83 | "source": [
84 | "# Attributes and Methods in class"
85 | ]
86 | },
87 | {
88 | "cell_type": "code",
89 | "execution_count": 92,
90 | "metadata": {},
91 | "outputs": [],
92 | "source": [
93 | "# Lets add some attributes or properties to this class\n",
94 | "\n",
95 | "class Lecture:\n",
96 | " Department = \"\" # class attributes\n",
97 | " Teacher = \"\" # class attributes \n",
98 | " Level = \"\" # class attributes\n",
99 | "\n",
100 | "# Lets define an object and its properties\n",
101 | "\n",
102 | "CE_103 = Lecture() # CE_103 is an instance (example) of the Class \"Lecture\"\n",
103 | "CE_103.Department = \"Civil Engineering\"\n",
104 | "CE_103.Name = \"Python Programming\"\n",
105 | "CE_103.Level = \"UnderGraduate\"\n",
106 | "\n",
107 | "# Lets define another object to same class\n",
108 | "\n",
109 | "DYB_582 = Lecture()\n",
110 | "DYB_582.Department = \"Civil Engineering\"\n",
111 | "DYB_582.Name = \"Engineering Seismology\"\n",
112 | "DYB_582.Level = \"Graduate\"\n"
113 | ]
114 | },
115 | {
116 | "cell_type": "code",
117 | "execution_count": 93,
118 | "metadata": {},
119 | "outputs": [
120 | {
121 | "name": "stdout",
122 | "output_type": "stream",
123 | "text": [
124 | "-------CE_103-----\n",
125 | "Department: Civil Engineering \n",
126 | "Name :Python Programming\n",
127 | "Level :UnderGraduate\n",
128 | "-------DYB_582------\n",
129 | "Department: Civil Engineering \n",
130 | "Name :Engineering Seismology\n",
131 | "Level :Graduate\n"
132 | ]
133 | }
134 | ],
135 | "source": [
136 | "print(\"-------CE_103-----\")\n",
137 | "print(\"Department: {} \\nName :{}\\nLevel :{}\".format(CE_103.Department,CE_103.Name,CE_103.Level))\n",
138 | " \n",
139 | "print(\"-------DYB_582------\")\n",
140 | "print(\"Department: {} \\nName :{}\\nLevel :{}\".format(DYB_582.Department,DYB_582.Name,DYB_582.Level))\n"
141 | ]
142 | },
143 | {
144 | "cell_type": "markdown",
145 | "metadata": {},
146 | "source": [
147 | "---\n",
148 | "In object oriented programming languages, the most effective tool is; when you write it once you can call it more than ones."
149 | ]
150 | },
151 | {
152 | "cell_type": "code",
153 | "execution_count": 96,
154 | "metadata": {},
155 | "outputs": [],
156 | "source": [
157 | "# lets add some function or methods to our object\n",
158 | "\n",
159 | "def lab_credit(self): # first function in Class always starts with keyword \"self\"\n",
160 | " self.lab += 1\n",
161 | " return self.lab"
162 | ]
163 | },
164 | {
165 | "cell_type": "code",
166 | "execution_count": 97,
167 | "metadata": {},
168 | "outputs": [],
169 | "source": [
170 | "# lets write function into the class\n",
171 | "\n",
172 | "class Lecture:\n",
173 | " Department = \"\"\n",
174 | " Teacher = \"\"\n",
175 | " Level = \"\"\n",
176 | " lab = 0\n",
177 | " \n",
178 | " def lab_credit(self): # first function in Class always starts with keyword \"self\"\n",
179 | " self.lab += 1\n",
180 | " return self.lab\n",
181 | "\n",
182 | " # Lets define an object ant its properties\n",
183 | "\n",
184 | "CE_103 = Lecture()\n",
185 | "CE_103.Department = \"Civil Engineering\"\n",
186 | "CE_103.Name = \"Python Programming\"\n",
187 | "CE_103.Level = \"UnderGraduate\"\n"
188 | ]
189 | },
190 | {
191 | "cell_type": "code",
192 | "execution_count": 98,
193 | "metadata": {},
194 | "outputs": [
195 | {
196 | "data": {
197 | "text/plain": [
198 | "1"
199 | ]
200 | },
201 | "execution_count": 98,
202 | "metadata": {},
203 | "output_type": "execute_result"
204 | }
205 | ],
206 | "source": [
207 | "CE_103.lab_credit() # call the function"
208 | ]
209 | },
210 | {
211 | "cell_type": "code",
212 | "execution_count": 99,
213 | "metadata": {},
214 | "outputs": [
215 | {
216 | "name": "stdout",
217 | "output_type": "stream",
218 | "text": [
219 | "-------CE_103-----\n",
220 | "Department: Civil Engineering \n",
221 | "Name :Python Programming\n",
222 | "Level :UnderGraduate\n",
223 | "Lab credit : 2\n"
224 | ]
225 | }
226 | ],
227 | "source": [
228 | "print(\"-------CE_103-----\")\n",
229 | "print(\"Department: {} \\nName :{}\\nLevel :{}\".format(CE_103.Department,CE_103.Name,CE_103.Level))\n",
230 | "\n",
231 | "CE_103.lab_credit()\n",
232 | "print(\"Lab credit :\", CE_103.lab)"
233 | ]
234 | },
235 | {
236 | "cell_type": "markdown",
237 | "metadata": {},
238 | "source": [
239 | "---\n",
240 | "Think that a class as blueprint of specific objects. These objects has to be created in the class. Assume a \"house\" as a class. Class variable is a variable that is shared by all different objects of class. Such as \"roof\", \"column\", \"foundation\". Instance variables are unique to each instance of a class. Such as \"garage\", \"doghouse\", \"dining room\". Functions, or methods, describes the behaviour of an object. In our example, this could be the location of the house. \n",
241 | "\n",
242 | "\n",
243 | "\n"
244 | ]
245 | },
246 | {
247 | "cell_type": "markdown",
248 | "metadata": {},
249 | "source": [
250 | "---\n",
251 | "While creating the object we may also define its properties, such as;"
252 | ]
253 | },
254 | {
255 | "cell_type": "code",
256 | "execution_count": 41,
257 | "metadata": {},
258 | "outputs": [
259 | {
260 | "name": "stdout",
261 | "output_type": "stream",
262 | "text": [
263 | "-------EQE_576------\n",
264 | "Department: Civil Engineering \n",
265 | "Level :Graduate\n",
266 | "-------DYB_523------\n",
267 | "Department: Civil Engineering \n",
268 | "Level :Graduate\n"
269 | ]
270 | }
271 | ],
272 | "source": [
273 | "class Lecture:\n",
274 | " Department = \"Civil Engineering\"\n",
275 | " Level = \"Graduate\"\n",
276 | " \n",
277 | "EQE_576 = Lecture() # object creating\n",
278 | "DYB_523 = Lecture()\n",
279 | "\n",
280 | "print(\"-------EQE_576------\")\n",
281 | "print(\"Department: {} \\nLevel :{}\".format(EQE_576.Department,EQE_576.Level))\n",
282 | "\n",
283 | "print(\"-------DYB_523------\")\n",
284 | "print(\"Department: {} \\nLevel :{}\".format(DYB_523.Department,DYB_523.Level))\n"
285 | ]
286 | },
287 | {
288 | "cell_type": "markdown",
289 | "metadata": {},
290 | "source": [
291 | "---\n",
292 | "BUT, in this situation, both objects have same properties! What if I would like to define different properties for each object ??\n",
293 | "\n",
294 | "# **__ init __()** function\n",
295 | "\n",
296 | "We need \"__ init __()\" and \"self\" to exemplified the properties of an object. The first parameter of this function must always be \"self\"."
297 | ]
298 | },
299 | {
300 | "cell_type": "code",
301 | "execution_count": 5,
302 | "metadata": {},
303 | "outputs": [
304 | {
305 | "name": "stdout",
306 | "output_type": "stream",
307 | "text": [
308 | "Kuzey.Guney@2005gtu.edu.tr\n",
309 | "Cinar.Selvi@2011gtu.edu.tr\n"
310 | ]
311 | }
312 | ],
313 | "source": [
314 | "# Up to know we learned class attribute, but there also object attributes. \n",
315 | "# In order to define object attributes, I need __init__() function and self.\n",
316 | "\n",
317 | "class student:\n",
318 | " def __init__(self, first, last, enroll): # set instance variables \"self, first, last, enroll\"\n",
319 | " self.fname=first\n",
320 | " self.lname=last\n",
321 | " self.enroll_year=enroll\n",
322 | " self.email=first + '.' + last + '@' + enroll + 'gtu.edu.tr'\n",
323 | "\n",
324 | "undgra1 = student('Kuzey', 'Guney', '2005')\n",
325 | "undgra2 = student('Cinar', 'Selvi', '2011')\n",
326 | "\n",
327 | "print(undgra1.email)\n",
328 | "print(undgra2.email)"
329 | ]
330 | },
331 | {
332 | "cell_type": "code",
333 | "execution_count": 1,
334 | "metadata": {},
335 | "outputs": [
336 | {
337 | "name": "stdout",
338 | "output_type": "stream",
339 | "text": [
340 | "KuzeyGuney\n",
341 | "CinarSelvi\n"
342 | ]
343 | }
344 | ],
345 | "source": [
346 | "# Instances of student class have created. Now,let's add some action, to do so, we will add a method to this class.\n",
347 | "# Asuume that we would like to display full name of student.\n",
348 | "\n",
349 | "class student:\n",
350 | " def __init__(self, first, last, enroll): # set instance variables \"self, first, last, enroll\"\n",
351 | " self.fname=first\n",
352 | " self.lname=last\n",
353 | " self.enroll_year=enroll\n",
354 | " self.email=first + '.' + last + '@' + enroll + 'gtu.edu.tr'\n",
355 | " \n",
356 | " def fullname(self):\n",
357 | " return '{}{}'.format(self.fname, self.lname)\n",
358 | "\n",
359 | "undgra1 = student('Kuzey', 'Guney', '2005')\n",
360 | "undgra2 = student('Cinar', 'Selvi', '2011') \n",
361 | "\n",
362 | "print(undgra1.fullname())\n",
363 | "print(undgra2.fullname())"
364 | ]
365 | },
366 | {
367 | "cell_type": "code",
368 | "execution_count": 8,
369 | "metadata": {},
370 | "outputs": [],
371 | "source": [
372 | "Kemal = student('Kemal','Durmaz','2009')"
373 | ]
374 | },
375 | {
376 | "cell_type": "code",
377 | "execution_count": 9,
378 | "metadata": {},
379 | "outputs": [
380 | {
381 | "data": {
382 | "text/plain": [
383 | "<__main__.student at 0x7fdab81df8d0>"
384 | ]
385 | },
386 | "execution_count": 9,
387 | "metadata": {},
388 | "output_type": "execute_result"
389 | }
390 | ],
391 | "source": [
392 | "Kemal"
393 | ]
394 | },
395 | {
396 | "cell_type": "code",
397 | "execution_count": 10,
398 | "metadata": {},
399 | "outputs": [
400 | {
401 | "data": {
402 | "text/plain": [
403 | "['__class__',\n",
404 | " '__delattr__',\n",
405 | " '__dict__',\n",
406 | " '__dir__',\n",
407 | " '__doc__',\n",
408 | " '__eq__',\n",
409 | " '__format__',\n",
410 | " '__ge__',\n",
411 | " '__getattribute__',\n",
412 | " '__gt__',\n",
413 | " '__hash__',\n",
414 | " '__init__',\n",
415 | " '__init_subclass__',\n",
416 | " '__le__',\n",
417 | " '__lt__',\n",
418 | " '__module__',\n",
419 | " '__ne__',\n",
420 | " '__new__',\n",
421 | " '__reduce__',\n",
422 | " '__reduce_ex__',\n",
423 | " '__repr__',\n",
424 | " '__setattr__',\n",
425 | " '__sizeof__',\n",
426 | " '__str__',\n",
427 | " '__subclasshook__',\n",
428 | " '__weakref__',\n",
429 | " 'email',\n",
430 | " 'enroll_year',\n",
431 | " 'fname',\n",
432 | " 'fullname',\n",
433 | " 'lname']"
434 | ]
435 | },
436 | "execution_count": 10,
437 | "metadata": {},
438 | "output_type": "execute_result"
439 | }
440 | ],
441 | "source": [
442 | "dir(Kemal)"
443 | ]
444 | },
445 | {
446 | "cell_type": "code",
447 | "execution_count": 11,
448 | "metadata": {},
449 | "outputs": [
450 | {
451 | "data": {
452 | "text/plain": [
453 | "'Kemal.Durmaz@2009gtu.edu.tr'"
454 | ]
455 | },
456 | "execution_count": 11,
457 | "metadata": {},
458 | "output_type": "execute_result"
459 | }
460 | ],
461 | "source": [
462 | "kemal.email"
463 | ]
464 | },
465 | {
466 | "cell_type": "markdown",
467 | "metadata": {},
468 | "source": [
469 | "---\n",
470 | "## Homework #12\n",
471 | "\n",
472 | "Create your own python module by defining a class for Mechanical properties of truss.\n",
473 | "\n",
474 | "These properties will be:\n",
475 | "\n",
476 | " 1. Area\n",
477 | " 2. Perimeter\n",
478 | " 3. location of center of gravity\n",
479 | " 4. Moment of Inertia\n",
480 | " 5. Moment of Inertia with respect to axes\n",
481 | " 6. Moment of inertia on principal axes\n",
482 | "\n",
483 | "PS : Do not forget to upload your answer sheets to CE_103 Class on MS Teams.\n"
484 | ]
485 | }
486 | ],
487 | "metadata": {
488 | "kernelspec": {
489 | "display_name": "Python 3",
490 | "language": "python",
491 | "name": "python3"
492 | },
493 | "language_info": {
494 | "codemirror_mode": {
495 | "name": "ipython",
496 | "version": 3
497 | },
498 | "file_extension": ".py",
499 | "mimetype": "text/x-python",
500 | "name": "python",
501 | "nbconvert_exporter": "python",
502 | "pygments_lexer": "ipython3",
503 | "version": "3.6.8"
504 | }
505 | },
506 | "nbformat": 4,
507 | "nbformat_minor": 4
508 | }
509 |
--------------------------------------------------------------------------------
/CE103-Week13.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### CE 103- INTRODUCTION TO COMPUTERS and PROGRAMMING"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "# Week 13 _ In Class Assigment I\n",
15 | "\n",
16 | "\n",
17 | "Dear students, \n",
18 | "\n",
19 | "You have a week to complete your first In Class assignment. You will be working as teams, please be sure that all of you as a team member spend same effort for this assignment. \n",
20 | "\n",
21 | "Please follow the intructions below and do not hesitate to ask question, if any, during your process. \n",
22 | "\n",
23 | "1 - Download the \"Sensor Record\" application to your Android cell phones.\n",
24 | "\n",
25 | "\n",
26 | "\n",
27 | "\n",
28 | "2 - Run the application and select 'Accelerometer' to record data. This application will record your data and will save it as file in \".csv\" format. \n",
29 | "\n",
30 | "\n",
31 | "3 - Stand up and hold your phone tight in your hand. Withput rotating your hand, slowly make a pendulum action (minimum 3 seconds period) with arm by moving back and forth. Do repeat this movement at least for 30 seconds. \n",
32 | "\n",
33 | "\n",
34 | "\n",
35 | "\n",
36 | "4 - Transfer the movement record data to your PC. Analyse the data and plot time series figure. Calculate and plot the magnitude of your pendulum movement. \n",
37 | "\n",
38 | "**_Hints:_** \n",
39 | "\n",
40 | "a. Remember the theoritical information from CE105 course.\n",
41 | "\n",
42 | "b. You may want to read the reference paper below to get help in detail : \n",
43 | "\n",
44 | "\n",
45 | "https://www.researchgate.net/publication/313164057_Step_Counting_Using_Smartphone_Accelerometer_and_Fast_Fourier_Trransform\n",
46 | "\n"
47 | ]
48 | },
49 | {
50 | "cell_type": "markdown",
51 | "metadata": {},
52 | "source": [
53 | "---"
54 | ]
55 | }
56 | ],
57 | "metadata": {
58 | "kernelspec": {
59 | "display_name": "Python 3",
60 | "language": "python",
61 | "name": "python3"
62 | },
63 | "language_info": {
64 | "codemirror_mode": {
65 | "name": "ipython",
66 | "version": 3
67 | },
68 | "file_extension": ".py",
69 | "mimetype": "text/x-python",
70 | "name": "python",
71 | "nbconvert_exporter": "python",
72 | "pygments_lexer": "ipython3",
73 | "version": "3.6.8"
74 | }
75 | },
76 | "nbformat": 4,
77 | "nbformat_minor": 4
78 | }
79 |
--------------------------------------------------------------------------------
/CE103-Week14.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {},
6 | "source": [
7 | "### CE 103- INTRODUCTION TO COMPUTERS and PROGRAMMING"
8 | ]
9 | },
10 | {
11 | "cell_type": "markdown",
12 | "metadata": {},
13 | "source": [
14 | "# Week 14 _ In Class Assigment II\n",
15 | "\n",
16 | "\n",
17 | "Dear students, \n",
18 | "\n",
19 | "You have a week to complete your second In Class assignment. You will be working as teams, please be sure that all of you as a team member spend same effort for this assignment. \n",
20 | "\n",
21 | "\n",
22 | "**Title of the task: \"Create your own step counter (pedometer)\"**\n",
23 | "\n",
24 | "Please follow the intructions below and do not hesitate to ask question, if any, during your process. \n",
25 | "\n",
26 | "\n",
27 | "1 - Use the \"Sensor Record\" application that you used for the previous project.\n",
28 | "\n",
29 | "2 - Run the application and select 'Accelerometer' to record data and save it as file in \".csv\" format. \n",
30 | "\n",
31 | "3 - Stand up and start walking while holding your phone tight in your hand. If you start walking, your arms will move forth and backward similar to a pendulum. Interestingly, when you step your left foot forward, your right arm will be on forward, too. Next, your right foot will move with your left arm. The movement of your arms will eventually create a pendulum motion and also lateral translation. Do walk more then 2 minutes and count your steps. \n",
32 | "\n",
33 | "\n",
34 | "\n",
35 | "4 - Transfer the movement record data to your PC. Analyse the data and plot time series figure. Creeate your own step counting module. Conclude your assignment by comparing the steps you counted with the results from your data analysis.\n",
36 | "\n",
37 | "Hints:\n",
38 | "\n",
39 | "a. Remember the theoritical information from CE105 course.\n",
40 | "\n",
41 | "b. You may want to read the reference paper below to get help in detail :\n",
42 | "\n",
43 | "https://www.researchgate.net/publication/313164057_Step_Counting_Using_Smartphone_Accelerometer_and_Fast_Fourier_Trransform\n"
44 | ]
45 | },
46 | {
47 | "cell_type": "markdown",
48 | "metadata": {},
49 | "source": [
50 | "---"
51 | ]
52 | }
53 | ],
54 | "metadata": {
55 | "kernelspec": {
56 | "display_name": "Python 3",
57 | "language": "python",
58 | "name": "python3"
59 | },
60 | "language_info": {
61 | "codemirror_mode": {
62 | "name": "ipython",
63 | "version": 3
64 | },
65 | "file_extension": ".py",
66 | "mimetype": "text/x-python",
67 | "name": "python",
68 | "nbconvert_exporter": "python",
69 | "pygments_lexer": "ipython3",
70 | "version": "3.6.8"
71 | }
72 | },
73 | "nbformat": 4,
74 | "nbformat_minor": 4
75 | }
76 |
--------------------------------------------------------------------------------
/Data_Input/.ipynb_checkpoints/Hello-checkpoint.txt:
--------------------------------------------------------------------------------
1 | Hello from the other side
2 | I must've called a thousand times
3 |
--------------------------------------------------------------------------------
/Data_Input/.ipynb_checkpoints/Kusma-GyadiBridge_Nepal-checkpoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Data_Input/.ipynb_checkpoints/Kusma-GyadiBridge_Nepal-checkpoint.png
--------------------------------------------------------------------------------
/Data_Input/.ipynb_checkpoints/civil_abb-checkpoint.txt:
--------------------------------------------------------------------------------
1 | A.A.S.H.T.O - American Association of State Highway Transport
2 | A.B - Anchor Bolt Or Asbestos Board
3 | A.C.I - American concrete institute.
4 | A.R.E.A - American Railway Engineering Association.
5 | A.S.C - Allowable stress of concrete.
6 | A.S.T.M - American Society for Testing Materials
7 | AC - Asphalt Concrete
8 | AE - Assistant Engineer
9 | APM - Assistant Project Manager
10 | B.M - Benchmark
11 | B.M - Bending moment.
12 | B.O.F - Bottom Of Foundation
13 | BHK - Bedroom, Hall, Kitchen
14 | BLK - Block Work
--------------------------------------------------------------------------------
/Data_Input/.ipynb_checkpoints/class-checkpoint.json:
--------------------------------------------------------------------------------
1 | {
2 | "LectureCodes": [
3 | "GTU_CE103",
4 | "GTU_CE105",
5 | "GTU_CE247"
6 | ],
7 | "Avg_StudentPerLecture": 75,
8 | "NumberOfClass": 12,
9 | "Students": [
10 | {
11 | "Name/Surname": "Braced Frame",
12 | "age": 19
13 | },
14 | {
15 | "Name/Surname": "Axial Load",
16 | "age": 18
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/Data_Input/.ipynb_checkpoints/eventlist-checkpoint.json:
--------------------------------------------------------------------------------
1 | "STATION,STATION_NAME,ELEVATION,LATITUDE,LONGITUDE,DATE,HPCP,Measurement Flag,Quality Flag\nCOOP:310301,ASHEVILLE NC US,682.1,35.5954,-82.5568,20100101 00:00,99999,], \nCOOP:310301,ASHEVILLE NC US,682.1,35.5954,-82.5568,20100101 01:00,0,g, \nCOOP:310301,ASHEVILLE NC US,682.1,35.5954,-82.5568,20100102 06:00,1, , \n"
--------------------------------------------------------------------------------
/Data_Input/.ipynb_checkpoints/filename-checkpoint:
--------------------------------------------------------------------------------
1 | Lets write some words in the FIRST line of a file.
2 | This could be the SECOND line. Am I right?.
3 |
--------------------------------------------------------------------------------
/Data_Input/.ipynb_checkpoints/merged-checkpoint.txt:
--------------------------------------------------------------------------------
1 | Hello from the other side
2 | I must've called a thousand times
3 | lets write something for line 1.
4 | lets write something for line 2.
5 | third line.
6 | 4th line.
7 |
--------------------------------------------------------------------------------
/Data_Input/.ipynb_checkpoints/tuik-checkpoint.csv:
--------------------------------------------------------------------------------
1 | |||Sütunlar||||||||||||
2 | Satırlar|||Türkiye-TR||||||||||||
3 | |||01-Ocak|02-Şubat|03-Mart|04-Nisan|05-Mayıs|06-Haziran|07-Temmuz|08-Ağustos|09-Eylül|10-Ekim|11-Kasım|12-Aralık|
4 | |||||||||||||||
5 | İnşaat Faaliyetleri Endeksi (Son 3 Aylık Dönemde)-Mevsim Etkilerinden Arındırılmış-Aylık Değişim Oranı (%)|Ölçüm bazında|2011||-1.94|-1.41|-1.3|-0.78|-0.42|4.13|-2.81|-1.96|2.97|-3.89|4.54|
6 | ||2012|-4.25|-2.19|-4.24|8.31|1.14|1.58|-5.35|0.02|-0.18|-0.98|-4.06|-2.51|
7 | ||2013|1.24|2.89|6.72|-3.98|-2.69|-1.36|2.59|0.29|1.69|-3.96|3.59|-1.79|
8 | ||2014|1.67|-2.32|-1.75|-1.42|-1.13|0.74|-0.54|-0.03|1.12|1.13|2.4|-3.67|
9 | ||2015|1.13|2.75|-0.65|-2.27|2.51|-1.86|-1.67|1.64|-1.93|0.06|1.01|2.93|
10 | ||2016|-0.91|-2.58|7.33|1.78|-10.87|-1.94|9.08|-5.38|5.9|-5.58|-3.13|-4.26|
11 | ||2017|-0.99|2.85|5.95|2.36|6.07|-0.79|-2.51|5.02|-8.0|1.77|-0.04|-0.2|
12 | ||2018|2.07|0.68|-4.58|-3.26|-5.66|-5.17|1.6|-6.81|-18.34|1.73|-4.14|-0.04|
13 | ||2019|-8.57|10.04|7.99|-8.37|-3.7|-3.53|6.6|5.11|7.52|8.46|-0.54|11.17|
14 | ||2020|5.24|6.61|-3.45|-34.07|||||||||
15 | İnşaat Sektörü Güven Endeksi-Mevsim Etkilerinden Arındırılmış-Aylık Değişim Oranı (%)|Ölçüm bazında|2011||-0.91|-8.45|7.78|0.35|1.08|2.57|-5.64|1.49|0.86|-2.15|1.05|
16 | ||2012|-2.15|-3.03|2.99|2.04|-0.25|-2.18|-1.33|-0.65|1.1|-2.5|-3.42|-2.16|
17 | ||2013|0.63|1.11|6.56|-4.04|0.29|-1.24|-0.21|-0.02|-1.44|3.45|-1.86|-1.31|
18 | ||2014|6.53|-8.04|-3.81|1.62|1.06|0.71|-1.2|3.41|2.42|-2.77|0.5|0.27|
19 | ||2015|-0.49|2.78|-1.39|-2.31|2.96|1.56|-2.56|-0.86|-1.71|-0.46|5.02|0.68|
20 | ||2016|-1.4|-1.31|-1.67|0.14|-2.9|2.23|2.49|-4.24|3.22|-0.82|-6.85|0.53|
21 | ||2017|-1.73|2.12|12.31|-0.18|0.77|0.42|-1.41|3.32|-5.46|0.89|-2.13|-1.03|
22 | ||2018|6.68|-3.69|-5.92|-0.08|-2.06|-2.44|2.44|-10.75|-16.75|2.34|-3.54|-2.14|
23 | ||2019|2.47|-8.74|4.43|-0.27|-7.69|1.32|3.81|6.01|8.35|8.32|-1.94|7.85|
24 | ||2020|14.59|-5.68|3.72|-42.19|||||||||
25 | |||||||||||||||
26 |
--------------------------------------------------------------------------------
/Data_Input/.ipynb_checkpoints/tuik_new-checkpoint.csv:
--------------------------------------------------------------------------------
1 | ,YEAR,Unnamed: 4,Unnamed: 5,Unnamed: 6
2 | 3,2011.0,-1.94,-1.41,-1.3
3 | 4,2012.0,-2.19,-4.24,8.31
4 | 5,2013.0,2.89,6.72,-3.98
5 | 6,2014.0,-2.32,-1.75,-1.42
6 | 7,2015.0,2.75,-0.65,-2.27
7 | 8,2016.0,-2.58,7.33,1.78
8 | 9,2017.0,2.85,5.95,2.36
9 | 10,2018.0,0.68,-4.58,-3.26
10 | 11,2019.0,10.04,7.99,-8.37
11 | 12,2020.0,6.61,-3.45,-34.07
12 | 13,2011.0,-0.91,-8.45,7.78
13 | 14,2012.0,-3.03,2.99,2.04
14 | 15,2013.0,1.11,6.56,-4.04
15 | 16,2014.0,-8.04,-3.81,1.62
16 | 17,2015.0,2.78,-1.39,-2.31
17 | 18,2016.0,-1.31,-1.67,0.14
18 | 19,2017.0,2.12,12.31,-0.18
19 | 20,2018.0,-3.69,-5.92,-0.08
20 | 21,2019.0,-8.74,4.43,-0.27
21 | 22,2020.0,-5.68,3.72,-42.19
22 |
--------------------------------------------------------------------------------
/Data_Input/.ipynb_checkpoints/write-checkpoint.txt:
--------------------------------------------------------------------------------
1 | lets write something for line 1.
2 | lets write something for line 2.
3 | third line.
4 | 4th line.
5 |
--------------------------------------------------------------------------------
/Data_Input/Hello.txt:
--------------------------------------------------------------------------------
1 | Hello from the other side
2 | I must've called a thousand times
3 |
--------------------------------------------------------------------------------
/Data_Input/Kusma-GyadiBridge_Nepal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Data_Input/Kusma-GyadiBridge_Nepal.png
--------------------------------------------------------------------------------
/Data_Input/ZipDir.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Data_Input/ZipDir.zip
--------------------------------------------------------------------------------
/Data_Input/ZipDir/pic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Data_Input/ZipDir/pic.png
--------------------------------------------------------------------------------
/Data_Input/aaa.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Data_Input/aaa.xlsx
--------------------------------------------------------------------------------
/Data_Input/civil_abb.txt:
--------------------------------------------------------------------------------
1 | A.A.S.H.T.O - American Association of State Highway Transport
2 | A.B - Anchor Bolt Or Asbestos Board
3 | A.C.I - American concrete institute.
4 | A.R.E.A - American Railway Engineering Association.
5 | A.S.C - Allowable stress of concrete.
6 | A.S.T.M - American Society for Testing Materials
7 | AC - Asphalt Concrete
8 | AE - Assistant Engineer
9 | APM - Assistant Project Manager
10 | B.M - Benchmark
11 | B.M - Bending moment.
12 | B.O.F - Bottom Of Foundation
13 | BHK - Bedroom, Hall, Kitchen
14 | BLK - Block Work
--------------------------------------------------------------------------------
/Data_Input/civil_abb_out.csv:
--------------------------------------------------------------------------------
1 | A.A.S.H.T.O , American Association of State Highway Transport
2 | A.B , Anchor Bolt Or Asbestos Board
3 | A.C.I , American concrete institute.
4 | A.R.E.A , American Railway Engineering Association.
5 | A.S.C , Allowable stress of concrete.
6 | A.S.T.M , American Society for Testing Materials
7 | AC , Asphalt Concrete
8 | AE , Assistant Engineer
9 | APM , Assistant Project Manager
10 | B.M , Benchmark
11 | B.M , Bending moment.
12 | B.O.F , Bottom Of Foundation
13 | BHK ," Bedroom, Hall, Kitchen"
14 | BLK , Block Work
15 |
--------------------------------------------------------------------------------
/Data_Input/civil_abb_out.json:
--------------------------------------------------------------------------------
1 | {"A.A.S.H.T.O": "American Association of State Highway Transport", "A.B": "Anchor Bolt Or Asbestos Board", "A.C.I": "American concrete institute.", "A.R.E.A": "American Railway Engineering Association.", "A.S.C": "Allowable stress of concrete.", "A.S.T.M": "American Society for Testing Materials", "AC": "Asphalt Concrete", "AE": "Assistant Engineer", "APM": "Assistant Project Manager", "B.M": "Bending moment.", "B.O.F": "Bottom Of Foundation", "BHK": "Bedroom, Hall, Kitchen", "BLK": "Block Work"}
--------------------------------------------------------------------------------
/Data_Input/class.json:
--------------------------------------------------------------------------------
1 | {
2 | "LectureCodes": [
3 | "GTU_CE103",
4 | "GTU_CE105",
5 | "GTU_CE247"
6 | ],
7 | "Avg_StudentPerLecture": 75,
8 | "NumberOfClass": 12,
9 | "Students": [
10 | {
11 | "Name/Surname": "Braced Frame",
12 | "age": 19
13 | },
14 | {
15 | "Name/Surname": "Axial Load",
16 | "age": 18
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/Data_Input/eventlist.json:
--------------------------------------------------------------------------------
1 | "STATION,STATION_NAME,ELEVATION,LATITUDE,LONGITUDE,DATE,HPCP,Measurement Flag,Quality Flag\nCOOP:310301,ASHEVILLE NC US,682.1,35.5954,-82.5568,20100101 00:00,99999,], \nCOOP:310301,ASHEVILLE NC US,682.1,35.5954,-82.5568,20100101 01:00,0,g, \nCOOP:310301,ASHEVILLE NC US,682.1,35.5954,-82.5568,20100102 06:00,1, , \n"
--------------------------------------------------------------------------------
/Data_Input/filename:
--------------------------------------------------------------------------------
1 | Lets write some words in the FIRST line of a file.
2 | This could be the SECOND line. Am I right?.
3 | 3rd Line
4 | 4th Line
5 | 5th Line
6 |
--------------------------------------------------------------------------------
/Data_Input/merged:
--------------------------------------------------------------------------------
1 | Hello from the other side
2 | I must've called a thousand times
3 | lets write something for line 1.
4 | lets write something for line 2.
5 | third line.
6 | 4th line.
7 |
--------------------------------------------------------------------------------
/Data_Input/merged.txt:
--------------------------------------------------------------------------------
1 | Hello from the other side
2 | I must've called a thousand times
3 | lets write something for line 1.
4 | lets write something for line 2.
5 | third line.
6 | 4th line.
7 |
--------------------------------------------------------------------------------
/Data_Input/narrow.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Data_Input/narrow.zip
--------------------------------------------------------------------------------
/Data_Input/sales.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Data_Input/sales.xlsx
--------------------------------------------------------------------------------
/Data_Input/tuik.csv:
--------------------------------------------------------------------------------
1 | |||Sütunlar||||||||||||
2 | Satırlar|||Türkiye-TR||||||||||||
3 | |||01-Ocak|02-Şubat|03-Mart|04-Nisan|05-Mayıs|06-Haziran|07-Temmuz|08-Ağustos|09-Eylül|10-Ekim|11-Kasım|12-Aralık|
4 | |||||||||||||||
5 | İnşaat Faaliyetleri Endeksi (Son 3 Aylık Dönemde)-Mevsim Etkilerinden Arındırılmış-Aylık Değişim Oranı (%)|Ölçüm bazında|2011||-1.94|-1.41|-1.3|-0.78|-0.42|4.13|-2.81|-1.96|2.97|-3.89|4.54|
6 | ||2012|-4.25|-2.19|-4.24|8.31|1.14|1.58|-5.35|0.02|-0.18|-0.98|-4.06|-2.51|
7 | ||2013|1.24|2.89|6.72|-3.98|-2.69|-1.36|2.59|0.29|1.69|-3.96|3.59|-1.79|
8 | ||2014|1.67|-2.32|-1.75|-1.42|-1.13|0.74|-0.54|-0.03|1.12|1.13|2.4|-3.67|
9 | ||2015|1.13|2.75|-0.65|-2.27|2.51|-1.86|-1.67|1.64|-1.93|0.06|1.01|2.93|
10 | ||2016|-0.91|-2.58|7.33|1.78|-10.87|-1.94|9.08|-5.38|5.9|-5.58|-3.13|-4.26|
11 | ||2017|-0.99|2.85|5.95|2.36|6.07|-0.79|-2.51|5.02|-8.0|1.77|-0.04|-0.2|
12 | ||2018|2.07|0.68|-4.58|-3.26|-5.66|-5.17|1.6|-6.81|-18.34|1.73|-4.14|-0.04|
13 | ||2019|-8.57|10.04|7.99|-8.37|-3.7|-3.53|6.6|5.11|7.52|8.46|-0.54|11.17|
14 | ||2020|5.24|6.61|-3.45|-34.07|||||||||
15 | İnşaat Sektörü Güven Endeksi-Mevsim Etkilerinden Arındırılmış-Aylık Değişim Oranı (%)|Ölçüm bazında|2011||-0.91|-8.45|7.78|0.35|1.08|2.57|-5.64|1.49|0.86|-2.15|1.05|
16 | ||2012|-2.15|-3.03|2.99|2.04|-0.25|-2.18|-1.33|-0.65|1.1|-2.5|-3.42|-2.16|
17 | ||2013|0.63|1.11|6.56|-4.04|0.29|-1.24|-0.21|-0.02|-1.44|3.45|-1.86|-1.31|
18 | ||2014|6.53|-8.04|-3.81|1.62|1.06|0.71|-1.2|3.41|2.42|-2.77|0.5|0.27|
19 | ||2015|-0.49|2.78|-1.39|-2.31|2.96|1.56|-2.56|-0.86|-1.71|-0.46|5.02|0.68|
20 | ||2016|-1.4|-1.31|-1.67|0.14|-2.9|2.23|2.49|-4.24|3.22|-0.82|-6.85|0.53|
21 | ||2017|-1.73|2.12|12.31|-0.18|0.77|0.42|-1.41|3.32|-5.46|0.89|-2.13|-1.03|
22 | ||2018|6.68|-3.69|-5.92|-0.08|-2.06|-2.44|2.44|-10.75|-16.75|2.34|-3.54|-2.14|
23 | ||2019|2.47|-8.74|4.43|-0.27|-7.69|1.32|3.81|6.01|8.35|8.32|-1.94|7.85|
24 | ||2020|14.59|-5.68|3.72|-42.19|||||||||
25 | |||||||||||||||
26 |
--------------------------------------------------------------------------------
/Data_Input/tuik.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Data_Input/tuik.xlsx
--------------------------------------------------------------------------------
/Data_Input/tuik_new.csv:
--------------------------------------------------------------------------------
1 | ,YEAR,Unnamed: 4,Unnamed: 5,Unnamed: 6
2 | 3,2011.0,-1.94,-1.41,-1.3
3 | 4,2012.0,-2.19,-4.24,8.31
4 | 5,2013.0,2.89,6.72,-3.98
5 | 6,2014.0,-2.32,-1.75,-1.42
6 | 7,2015.0,2.75,-0.65,-2.27
7 | 8,2016.0,-2.58,7.33,1.78
8 | 9,2017.0,2.85,5.95,2.36
9 | 10,2018.0,0.68,-4.58,-3.26
10 | 11,2019.0,10.04,7.99,-8.37
11 | 12,2020.0,6.61,-3.45,-34.07
12 | 13,2011.0,-0.91,-8.45,7.78
13 | 14,2012.0,-3.03,2.99,2.04
14 | 15,2013.0,1.11,6.56,-4.04
15 | 16,2014.0,-8.04,-3.81,1.62
16 | 17,2015.0,2.78,-1.39,-2.31
17 | 18,2016.0,-1.31,-1.67,0.14
18 | 19,2017.0,2.12,12.31,-0.18
19 | 20,2018.0,-3.69,-5.92,-0.08
20 | 21,2019.0,-8.74,4.43,-0.27
21 | 22,2020.0,-5.68,3.72,-42.19
22 |
--------------------------------------------------------------------------------
/Data_Input/write.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Data_Input/write.txt
--------------------------------------------------------------------------------
/Examples/.ipynb_checkpoints/example-checkpoint.py:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": null,
6 | "metadata": {},
7 | "outputs": [],
8 | "source": [
9 | "vowels = 'aeiou'\n",
10 | "counter = 0\n",
11 | "\n",
12 | "def word_enter():\n",
13 | "return input('Please write a word: ')\n",
14 | "\n",
15 | "def special(letter):\n",
16 | "return letter in vowels\n",
17 | "\n",
18 | "def count(counter, word):\n",
19 | "for letter in word:\n",
20 | "if special(letter):\n",
21 | "counter += 1\n",
22 | "return counter\n",
23 | "\n",
24 | "def write_screen(word):\n",
25 | "message = \"In the word \\\"{}\\\" there are {} vowels.\"\n",
26 | "print(message.format(word, count(counter, word)))\n",
27 | "\n",
28 | "def run():\n",
29 | "word = word_enter()\n",
30 | "write_screen(word)"
31 | ]
32 | }
33 | ],
34 | "metadata": {
35 | "kernelspec": {
36 | "display_name": "Python 3",
37 | "language": "python",
38 | "name": "python3"
39 | },
40 | "language_info": {
41 | "codemirror_mode": {
42 | "name": "ipython",
43 | "version": 3
44 | },
45 | "file_extension": ".py",
46 | "mimetype": "text/x-python",
47 | "name": "python",
48 | "nbconvert_exporter": "python",
49 | "pygments_lexer": "ipython3",
50 | "version": "3.6.8"
51 | }
52 | },
53 | "nbformat": 4,
54 | "nbformat_minor": 4
55 | }
56 |
--------------------------------------------------------------------------------
/Examples/example.py:
--------------------------------------------------------------------------------
1 | vowels='aeiou'
2 | counter=0
3 |
4 | def word_enter():
5 | return input('Please write a word: ')
6 |
7 | def special(letter):
8 | return letter in vowels
9 |
10 | def count(counter, word):
11 | for letter in word:
12 | if special(letter):
13 | counter += 1
14 | return counter
15 |
16 | def write_screen(word):
17 | message = "In the word \"{}\" there are {} vowels."
18 | print(message.format(word, count(counter, word)))
19 |
20 | def run():
21 | word = word_enter()
22 | write_screen(word)
23 |
--------------------------------------------------------------------------------
/Figures/.ipynb_checkpoints/algorithm2-checkpoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/.ipynb_checkpoints/algorithm2-checkpoint.png
--------------------------------------------------------------------------------
/Figures/.ipynb_checkpoints/grading-checkpoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/.ipynb_checkpoints/grading-checkpoint.png
--------------------------------------------------------------------------------
/Figures/.ipynb_checkpoints/slope-int-checkpoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/.ipynb_checkpoints/slope-int-checkpoint.png
--------------------------------------------------------------------------------
/Figures/.ipynb_checkpoints/travel-time-checkpoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/.ipynb_checkpoints/travel-time-checkpoint.png
--------------------------------------------------------------------------------
/Figures/3d-array.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/3d-array.png
--------------------------------------------------------------------------------
/Figures/GTU_LOGO_1200X768_JPG_EN.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/GTU_LOGO_1200X768_JPG_EN.jpg
--------------------------------------------------------------------------------
/Figures/GTU_LOGO_1200X768_JPG_EN_Small.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/GTU_LOGO_1200X768_JPG_EN_Small.jpg
--------------------------------------------------------------------------------
/Figures/Z_TravelTimeCurve.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/Z_TravelTimeCurve.mp4
--------------------------------------------------------------------------------
/Figures/algorithm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/algorithm.png
--------------------------------------------------------------------------------
/Figures/algorithm2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/algorithm2.png
--------------------------------------------------------------------------------
/Figures/arithmetic-operators.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/arithmetic-operators.png
--------------------------------------------------------------------------------
/Figures/array-sum.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/array-sum.png
--------------------------------------------------------------------------------
/Figures/array.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/array.png
--------------------------------------------------------------------------------
/Figures/array_vs_list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/array_vs_list.png
--------------------------------------------------------------------------------
/Figures/assignmentoparetor.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/assignmentoparetor.png
--------------------------------------------------------------------------------
/Figures/blackwidow.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/blackwidow.jpg
--------------------------------------------------------------------------------
/Figures/captainamerica.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/captainamerica.jpg
--------------------------------------------------------------------------------
/Figures/class.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/class.png
--------------------------------------------------------------------------------
/Figures/color.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/color.png
--------------------------------------------------------------------------------
/Figures/comparisonoperator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/comparisonoperator.png
--------------------------------------------------------------------------------
/Figures/def_func.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/def_func.png
--------------------------------------------------------------------------------
/Figures/earth-dist.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/earth-dist.png
--------------------------------------------------------------------------------
/Figures/elif-else-statement.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/elif-else-statement.png
--------------------------------------------------------------------------------
/Figures/error-messages.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/error-messages.pdf
--------------------------------------------------------------------------------
/Figures/figure-exp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/figure-exp.png
--------------------------------------------------------------------------------
/Figures/for-loop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/for-loop.png
--------------------------------------------------------------------------------
/Figures/grading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/grading.png
--------------------------------------------------------------------------------
/Figures/grading2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/grading2.jpg
--------------------------------------------------------------------------------
/Figures/guido.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/guido.png
--------------------------------------------------------------------------------
/Figures/homework10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/homework10.png
--------------------------------------------------------------------------------
/Figures/hulk.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/hulk.jpg
--------------------------------------------------------------------------------
/Figures/hw6_screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/hw6_screenshot.png
--------------------------------------------------------------------------------
/Figures/hw6_screenshot2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/hw6_screenshot2.png
--------------------------------------------------------------------------------
/Figures/hw7-ibb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/hw7-ibb.png
--------------------------------------------------------------------------------
/Figures/hw7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/hw7.png
--------------------------------------------------------------------------------
/Figures/hw_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/hw_11.png
--------------------------------------------------------------------------------
/Figures/hw_11_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/hw_11_2.png
--------------------------------------------------------------------------------
/Figures/if-else-statement.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/if-else-statement.png
--------------------------------------------------------------------------------
/Figures/if-statement.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/if-statement.png
--------------------------------------------------------------------------------
/Figures/inclass_II.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/inclass_II.png
--------------------------------------------------------------------------------
/Figures/ironman.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/ironman.png
--------------------------------------------------------------------------------
/Figures/ironman2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/ironman2.jpg
--------------------------------------------------------------------------------
/Figures/keywords.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/keywords.png
--------------------------------------------------------------------------------
/Figures/lin-reg-fig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/lin-reg-fig.png
--------------------------------------------------------------------------------
/Figures/lin-reg-formula.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/lin-reg-formula.png
--------------------------------------------------------------------------------
/Figures/plaka.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/plaka.jpg
--------------------------------------------------------------------------------
/Figures/regression-curve.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/regression-curve.png
--------------------------------------------------------------------------------
/Figures/scipy-submodules.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/scipy-submodules.png
--------------------------------------------------------------------------------
/Figures/sensorrecord.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/sensorrecord.png
--------------------------------------------------------------------------------
/Figures/slope-int.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/slope-int.png
--------------------------------------------------------------------------------
/Figures/spoon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/spoon.jpg
--------------------------------------------------------------------------------
/Figures/string-sequence.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/string-sequence.png
--------------------------------------------------------------------------------
/Figures/subplot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/subplot.png
--------------------------------------------------------------------------------
/Figures/swinging_arm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/swinging_arm.png
--------------------------------------------------------------------------------
/Figures/travel-time.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/travel-time.png
--------------------------------------------------------------------------------
/Figures/while-loop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gtuinsaat/CE103_Python-in-Civil-Engineering/20d0538ffc7dd84b413b86b33184a970da15ba65/Figures/while-loop.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ---
4 |
5 |
Gebze Technical University | Civil Engineering Department | CE_103 Introduction to computers and programming for civil engineers
6 |
7 |
8 |
9 |
10 |
PLEASE VISIT "https://github.com/komec/py4civil" FOR RECENT LECTURE NOTES.
11 |
12 |
--------------------------------------------------------------------------------