Python Orientation

1,885 views

Published on

Python Basics Tutorial, Intro to Python
Python Data types 
Functions, method
Basic Elements, program structure
Exceptions, Errors
Strings, methods
Python module
OO Python:inheritance, staticmethod, classmethod, abc,
Regular Expressions
File I/O, SQlite DB
Intro to Python, web framework dJango, testing

Published in: Education, Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,885
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
66
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Python Orientation

  1. 1. This presentation cannot be shared unless the course is completed. The slides can be shared by the course provider end of the session only. 1
  2. 2. 2
  3. 3. Gives a brief overview of the Python programming. Describe the major focus of the presentation and why it is important. Introduce each of the major topics. To provide a road map for the audience, you can repeat this Overview slide throughout the presentation, highlighting the particular topic you will discuss next. 3
  4. 4. 4
  5. 5. https://wiki.python.org/moin/WebFrameworks 5
  6. 6. WEBSERVICES PYTHON – SOA • http://www.pythomnic3k.org/tour-resources.html • http://pyvideo.org/speaker/377/jessica-mckellar • http://flask.pocoo.org/ • http://www.oracle.com/technetwork/articles/dsl/mastering-oracle-python1391323.html 6
  7. 7. Qt Cross platform framework (Win/Mac/X11, soon S60) Native look and feel Modular (Core, GUI, Network, OpenGL, SQL, WebKit, etc) Mature Internationalization Excellent documentation Available under both commercial and Open Source licenses 7
  8. 8. This is another option for an Overview slides using transitions. 8
  9. 9. 9
  10. 10. 10
  11. 11. 11
  12. 12. The purpose of this presentation is to make the case for three technologies ... (see next slide) 12
  13. 13. 13
  14. 14. There is no standard definition of "scripting language", but this set of criteria pretty much captures what most people mean by the term. Note that Java is interpreted (it requires a JVM) but it is statically (strongly) typed and requires a compilation step, so it is not a scripting language. 14
  15. 15. 15
  16. 16. 16
  17. 17. 17
  18. 18. 18
  19. 19. 19
  20. 20. 20
  21. 21. 21
  22. 22. I got tired of cutting and pasting in pictures. This selection is possibly one-third of the Python books on the market in May of 2003. One way to judge the acceptance of a language is by how many O'Reilly books cover it! Note that there are several O'Reilly books on this page, including "Python in a Nutshell" (a VERY good book), and there are others not shown – "Learning Python" by Lutz, the "Python Cookbook", etc. 22
  23. 23. 23
  24. 24. 24
  25. 25. 25
  26. 26. 26
  27. 27. 27
  28. 28. 28
  29. 29. 29
  30. 30. 30
  31. 31. 31
  32. 32. 32
  33. 33. 33
  34. 34. 34
  35. 35. 35
  36. 36. >>> a=[[1,2,3],[4,5,6],[7,8,9]] >>> b=[[1,1,1],[1,1,1],[1,1,1]] >>> a [[1, 2, 3], [4, 5, 6], [7, 8, 9]] >>> b [[1, 1, 1], [1, 1, 1], [1, 1, 1]] >>> c=[[0, 0, 0], [0, 0, 0], [0, 0, 0]] >>> for i in range(3): ... for j in range(3): ... c[i][j]=a[i][j] + b[i][j] ... >>> c [[2, 3, 4], [5, 6, 7], [8, 9, 10]] Matrix in Python good references: http://stackoverflow.com/questions/16541973/print-matrix-with-indicies-python 36
  37. 37. 37
  38. 38. http://stackoverflow.com/questions/4877290/what-is-the-dict-dict-attribute-of-apython-class 38
  39. 39. 39
  40. 40. 40
  41. 41. 41
  42. 42. 42
  43. 43. 43
  44. 44. 44
  45. 45. http://software-carpentry.org/v3/py04.html 45
  46. 46. 46
  47. 47. 47
  48. 48. 48
  49. 49. 49
  50. 50. 50
  51. 51. 51
  52. 52. 52
  53. 53. 53
  54. 54. 54
  55. 55. 55
  56. 56. Bool True = 1 False = 0 56
  57. 57. 57
  58. 58. 58
  59. 59. 59
  60. 60. 60
  61. 61. 61
  62. 62. 62
  63. 63. # Fibonacci a, b = 0, 1 while b < 1000: print b a, b = b, a +b 63
  64. 64. 64
  65. 65. What a function is Defining a function in Python Adding a docstring in Python Function execution Function Assignment Return from function Inner function Default values of function parameters Keyword argument Lambda expression 65
  66. 66. http://www.c-sharpcorner.com/UploadFile/4aac15/python-basics-understanding-thefunctions/ 66
  67. 67. 67
  68. 68. http://www.c-sharpcorner.com/UploadFile/4aac15/python-basics-understanding-thefunctions/ def functionNameHere(parameters): """place your doc string here""" #rest of the code. 68
  69. 69. 69
  70. 70. 70
  71. 71. 71
  72. 72. Recursion is not a best practice for automations. Most preferred way is using loops 72
  73. 73. 73
  74. 74. 74
  75. 75. 75
  76. 76. 76
  77. 77. 77
  78. 78. 78
  79. 79. 79
  80. 80. hi bye 80
  81. 81. 81
  82. 82. 82
  83. 83. hi bye 83
  84. 84. Try to see y value not having the string in the x. 84
  85. 85. This will help user when dealing with currency, Symbols, Specific Non English Languages 85
  86. 86. 86
  87. 87. 87
  88. 88. The approach using string.Template is easy to learn and should be familiar to bash users. It is suitable for exposing to end-users. This style became available in Python 2.4. The percent-style will be familiar to many people coming from other programming languages. Some people find this style to be error-prone because of the trailing "s" in %(name)s, because the %-operator has the same precedence as multiplication, and because the behavior of the applied arguments depends on their data type (tuples and dicts get special handling). This style has been supported in Python since the beginning. The curly-bracket style is only supported in Python 2.6 or later. It is the most flexible style (providing a rich set of control characters and allowing objects to implement custom formatters). 88
  89. 89. 89
  90. 90. 90
  91. 91. 91
  92. 92. 92
  93. 93. 93
  94. 94. 94
  95. 95. 95
  96. 96. 96
  97. 97. 97
  98. 98. 98
  99. 99. 99
  100. 100. 100
  101. 101. 101
  102. 102. 102
  103. 103. 103
  104. 104. 104
  105. 105. 105
  106. 106. 106
  107. 107. 107
  108. 108. 108
  109. 109. 109
  110. 110. 110
  111. 111. http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-189-agentle-introduction-to-programming-using-python-january-iap-2011/lectures/ 111
  112. 112. 112
  113. 113. 113
  114. 114. Standard Python Modules http://www.python.org/doc/current/modindex.html PyPI: the Python Package Index : third-party Python packages. http://www.python.org/pypi 114
  115. 115. 115
  116. 116. 116
  117. 117. 117
  118. 118. 118
  119. 119. 119
  120. 120. 120
  121. 121. 121
  122. 122. 122
  123. 123. 123
  124. 124. 124
  125. 125. 125
  126. 126. 127
  127. 127. 128
  128. 128. 129
  129. 129. 130
  130. 130. 131
  131. 131. 132
  132. 132. 133
  133. 133. 134
  134. 134. 135
  135. 135. 136
  136. 136. 137
  137. 137. 138
  138. 138. 139
  139. 139. 140
  140. 140. 141
  141. 141. 142
  142. 142. 143
  143. 143. 144
  144. 144. 145
  145. 145. Because Python doesn't have (and doesn't need) a formal Interface contract, the Java-style distinction between abstraction and interface doesn't exist. If someone goes through the effort to define a formal interface, it will also be an abstract class. The only differences would be in the stated intent in the docstring. And the difference between abstract and interface is a hairsplitting thing when you have duck typing. Java uses interfaces because it doesn't have multiple inheritance. 146
  146. 146. 147
  147. 147. 148
  148. 148. Shape=type(“Shape”,(object,),{}) def area(): Rect=type(“Rect”,(Shape,),{l=2,b=4} 149
  149. 149. 150
  150. 150. 151
  151. 151. 152
  152. 152. 153
  153. 153. 154
  154. 154. 155
  155. 155. 156
  156. 156. 157
  157. 157. 158
  158. 158. 159
  159. 159. 160
  160. 160. 161
  161. 161. 162
  162. 162. Greedy means match longest possible string. Lazy means match shortest possible string. For example, the greedy h.+l matches 'hell' in 'hello' but the lazy h.+?l matches 'hel'. 163
  163. 163. >>> s = ‘<a href=“index.html”>HERE</a><font size=“10”>’ 164
  164. 164. 165
  165. 165. 166
  166. 166. 167
  167. 167. 168
  168. 168. 169
  169. 169. 170
  170. 170. 171
  171. 171. 172
  172. 172. 173
  173. 173. 174
  174. 174. 175
  175. 175. 176
  176. 176. 177
  177. 177. 178
  178. 178. 179
  179. 179. 180
  180. 180. As you can see, the method split has two optional parameters. If none is given (or is None) , a string will be separated into substring using whitespaces as delimiters, i.e. every substring consisting purely of whitespaces is used as a delimiter. 181
  181. 181. 182
  182. 182. ZIP http://pythonprogramming.language-tutorial.com/2012/10/python-script-to-zip-andunzip-files.html 183
  183. 183. 184
  184. 184. 185
  185. 185. 186
  186. 186. hi bye 187
  187. 187. 188
  188. 188. Remember that print >> automatically appends an end-of-line marker Which is why the program above strips whitespace off the end of the string before printing it 189
  189. 189. 190
  190. 190. YouTube: TheMonkeyLords Tutorial: 24 >>> with open('c:/pbin/pystudent2/foo.txt','rt') as fin: ... print fin.read() ... This is testing text file new line some more text 191
  191. 191. The whence argument is optional and defaults to os.SEEK_SET or 0 (absolute file positioning); other values are os.SEEK_CUR or 1 (seek relative to the current position) and os.SEEK_END or 2 (seek relative to the file’s end). 192
  192. 192. http://pymotw.com/2/ospath/ 193
  193. 193. The CSV (comma separated value) format is a common format used for spreadsheets and databases, for importing and exporting of data. Each line or record in the file has its fields separated by a delimiter, which can be a comma, tab, etc. 194
  194. 194. This is another option for an Overview slides using transitions. http://zetcode.com/db/sqlitepythontutorial/ http://www.tutorialspoint.com/sqlite/sqlite_python.htm 195
  195. 195. 196
  196. 196. 197
  197. 197. 198
  198. 198. This is another option for an Overview slides using transitions. 199
  199. 199. 200
  200. 200. 201
  201. 201. 202
  202. 202. 203
  203. 203. 204
  204. 204. 205
  205. 205. Set the path to this directory 206
  206. 206. 207
  207. 207. 208
  208. 208. 209
  209. 209. 210
  210. 210. PhoneNumberField, EmailField, URLField 같이 DB차원의 Low-level ….이 아닌 사용자입장에서 모델링 가능.. 적절한 validation도 자동으로 됨 211
  211. 211. 212
  212. 212. 213
  213. 213. startproject startapp settings.py, urls.py models.py 복사 manage.py syncdb manage.py runserver http://localhost:8000/admin/ 214
  214. 214. 215
  215. 215. 216
  216. 216. 217
  217. 217. 218
  218. 218. 219
  219. 219. 220
  220. 220. 221
  221. 221. 222
  222. 222. This is another option for an Overview slides using transitions. 223
  223. 223. 224
  224. 224. 225
  225. 225. http://effbot.org/zone/element-index.htm 226
  226. 226. 227
  227. 227. 228
  228. 228. 229
  229. 229. 230
  230. 230. 231
  231. 231. 232
  232. 232. Add a case study or class simulation to encourage discussion and apply lessons. 233
  233. 233. Discuss outcomes of the case study or class simulation. Cover best practices. 234
  234. 234. Microsoft Engineering Excellence Microsoft Confidential 235
  235. 235. 236
  236. 236. Microsoft Engineering Excellence http://zetcode.com/db/sqlitepythontutorial/ Microsoft Confidential 237
  237. 237. Microsoft Engineering Excellence Microsoft Confidential 238
  238. 238. You can contact us by email. 239
  239. 239. Microsoft Engineering Excellence Presentation available on sildeshare and authorstream. Free to share it! Microsoft Confidential 240

×