|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "<small><small><i>\n", |
| 8 | + "All of these python notebooks are available at [ https://github.com/milaan9/Python4DataScience ]\n", |
| 9 | + "</i></small></small>" |
| 10 | + ] |
| 11 | + }, |
| 12 | + { |
| 13 | + "cell_type": "markdown", |
| 14 | + "metadata": {}, |
| 15 | + "source": [ |
| 16 | + "# Introduction to Python\n", |
| 17 | + "\n", |
| 18 | + "<div>\n", |
| 19 | + "<img src=\"img/logo.png\" width=\"200\"/>\n", |
| 20 | + "</div>\n", |
| 21 | + "\n", |
| 22 | + "> These documents provide a relatively brief overview of the main features of Python. They are intended as a complete course for students that already have some idea of how to program in another language. Every aspect of Python is covered with some brief examples. " |
| 23 | + ] |
| 24 | + }, |
| 25 | + { |
| 26 | + "cell_type": "markdown", |
| 27 | + "metadata": { |
| 28 | + "heading_collapsed": true |
| 29 | + }, |
| 30 | + "source": [ |
| 31 | + "## Introduction\n", |
| 32 | + "\n", |
| 33 | + "1. Python is a **general purpose, mordern, dynamic, robust, high level** and **interpreted** programming language. It supports **Object Oriented** programming approach to develop applications. It is simple and easy to learn and provides lots of high-level data **structures**. It is very **easy to pick up** even if you are completely new to programming. **Guido Van Rossum** is known as the founder of python programming.\n", |
| 34 | + "\n", |
| 35 | + "\n", |
| 36 | + "2. Python is easy to learn yet powerful and versatile scripting language which makes it attractive for **Application Development.**\n", |
| 37 | + "\n", |
| 38 | + "\n", |
| 39 | + "3. Python's syntax and **dynamic typing** with its interpreted nature, makes it an ideal language for scripting and rapid application development.\n", |
| 40 | + "\n", |
| 41 | + "\n", |
| 42 | + "4. Python supports **multiple** programming pattern, including object oriented, imperative and **functional** or **procedural** programming styles.\n", |
| 43 | + "\n", |
| 44 | + "\n", |
| 45 | + "5. Python is not intended to work on special area such as **web** programming. That is why it is known as multipurpose because it can be used with **web, enterprise, 3D CAD** etc.\n", |
| 46 | + "\n", |
| 47 | + "\n", |
| 48 | + "6. We don't need to use data types to declare variable because it is **dynamically typed** so we can write a=10 to assign an integer value in an integer variable.\n", |
| 49 | + "\n", |
| 50 | + "\n", |
| 51 | + "7. Python makes the development and debugging **fast** because there is no compilation step included in python development and **edit-test-debug** cycle is **very fast.** \n", |
| 52 | + "\n", |
| 53 | + "\n", |
| 54 | + "8. Python, similar to other languages like matlab or R, is interpreted hence runs slowly compared to C++, Fortran or Java. However, writing programs in Python is very quick. Python has a very large collection of libraries for everything from scientific computing to web services. It caters for object oriented and functional programming with module system that allows large and complex applications to be developed in Python. \n", |
| 55 | + "\n", |
| 56 | + "\n", |
| 57 | + "These lectures are using jupyter notebooks which mix Python code with documentation. The python notebooks can be run on a webserver or stand-alone on a computer.\n", |
| 58 | + "\n", |
| 59 | + "To give an indication of what Python code looks like, here is a simple bit of code that defines a set $N=\\{1,3,4,5,7\\}$ and calculates the sum of the squared elements of this set: $\\sum_{i\\in N} i^2=100$" |
| 60 | + ] |
| 61 | + }, |
| 62 | + { |
| 63 | + "cell_type": "markdown", |
| 64 | + "metadata": { |
| 65 | + "heading_collapsed": true |
| 66 | + }, |
| 67 | + "source": [ |
| 68 | + "## Python History\n", |
| 69 | + "\n", |
| 70 | + "1. Python laid its foundation in the late 1980s.\n", |
| 71 | + "\n", |
| 72 | + "\n", |
| 73 | + "2. The implementation of Python was started in the December 1989 by **Guido Van Rossum** at CWI in Netherland.\n", |
| 74 | + "\n", |
| 75 | + "\n", |
| 76 | + "3. In February 1991, van **Rossum** published the code (labeled version 0.9.0) to alt.sources.\n", |
| 77 | + "\n", |
| 78 | + "\n", |
| 79 | + "4. In 1994, **Python 1.0** was released with new features like: lambda, map, filter, and reduce.\n", |
| 80 | + "\n", |
| 81 | + "\n", |
| 82 | + "5. **Python 2.0** added new features like: list **comprehensions, garbage collection system.**\n", |
| 83 | + "\n", |
| 84 | + "\n", |
| 85 | + "6. On December 3, 2008, **Python 3.0** (also called \"**Py3K**\") was released. It was designed to rectify fundamental flaw of the language.\n", |
| 86 | + "\n", |
| 87 | + "\n", |
| 88 | + "7. **ABC** programming language is said to be the predecessor of Python language which was capable of Exception Handling and interfacing with **Amoeba Operating System.**\n", |
| 89 | + "\n", |
| 90 | + "\n", |
| 91 | + "8. Python is influenced by following programming languages: **(1) ABC language. (2) ABC language.**" |
| 92 | + ] |
| 93 | + }, |
| 94 | + { |
| 95 | + "cell_type": "markdown", |
| 96 | + "metadata": { |
| 97 | + "heading_collapsed": true |
| 98 | + }, |
| 99 | + "source": [ |
| 100 | + "## Python Version\n", |
| 101 | + "\n", |
| 102 | + "Lets start off by looking at Python history. Python was developed at a time when many other dynamic and **open-source** programming languages like Tcl, Perl, Ruby etc. were also being actively developed and gaining popularity. \n", |
| 103 | + "\n", |
| 104 | + "1. #### Python 1.0\n", |
| 105 | + "In **January 1994**, the first version of **Python 1.0** was released. This version 1 includes the major new features like the functional programming tools filter, reduce, map, and lambda etc.\n", |
| 106 | + "\n", |
| 107 | + "2. #### Python 2.0\n", |
| 108 | + "After Six and a half years later, **Python 2.0** was introduced in **October 2000**. In this release, a full garbage collector, list comprehensions were included, and it also supports **Unicode.**\n", |
| 109 | + "\n", |
| 110 | + "3. #### Python 3.0\n", |
| 111 | + "then after 8 years, the next major release was made. This release was **Python 3.0** also known as “**Py3K**” or “**Python 3000**”.\n", |
| 112 | + "\n", |
| 113 | + "The major changes in Python 3.0 are:\n", |
| 114 | + "\n", |
| 115 | + "* In this version, **Print** is a Python function \n", |
| 116 | + "* Instead of lists, in this version, we have **Views** and **iterators**.\n", |
| 117 | + "* In this version, we have more simplified rules for ordering **comparisons**. For example, we cannot sort a **heterogeneous** list, because each element of a Python List must be comparable to other elements.\n", |
| 118 | + "* In this python version, **int. long** is also an int as there is only one **integer type.**\n", |
| 119 | + "* In this python version, when we divide two integers it resultant returns is a float instead of an integer. We can use “**//**” to have the “**old**” behavior.\n", |
| 120 | + "* In this python version, Instead of **Unicode** Vs. **8-bit** we have **Text** Vs. **Data**\n", |
| 121 | + "* The one drawback of **Python 3.0** is that it is **not backward compatible** with **Python 2.x.**\n", |
| 122 | + "\n", |
| 123 | + "Python Latest version:\n", |
| 124 | + "\n", |
| 125 | + "The Python latest version is **3.7.0**. This stable version was released on **27 June**. The current latest (as of Winter 2019) is Python **3.7.2**. \n", |
| 126 | + "\n", |
| 127 | + "The Python 3.7 version is aimed at making complex tasks simple, and It is currently in production release. The improvements to Python 3.7 version include:\n", |
| 128 | + "\n", |
| 129 | + "* **Data classes** that reduce boilerplate when working with data in classes.\n", |
| 130 | + "* A “**development mode**” for the interpreter.\n", |
| 131 | + "* A new built-in for **triggering** the debugger.\n", |
| 132 | + "* **UTF-8** mode that uses UTF-8 encoding by default in the environment.\n", |
| 133 | + "* A potentially **backward-incompatible** change involving the handling of exceptions in generators.\n", |
| 134 | + "* **Nanosecond-resolution** time objects .\n" |
| 135 | + ] |
| 136 | + }, |
| 137 | + { |
| 138 | + "cell_type": "markdown", |
| 139 | + "metadata": { |
| 140 | + "heading_collapsed": true |
| 141 | + }, |
| 142 | + "source": [ |
| 143 | + "## Python 2 vs. Python 3\n", |
| 144 | + "\n", |
| 145 | + "n most of the programming languages, whenever a new version releases, it supports the features and syntax of the existing version of the language, therefore, it is easier for the projects to switch in the newer version. However, in the case of Python, the two versions Python 2 and Python 3 are very much different from each other.\n", |
| 146 | + "\n", |
| 147 | + "**A list of differences between Python 2 and Python 3 are given below:**\n", |
| 148 | + "\n", |
| 149 | + "* In **Python 2** uses print as a statement and used as print \"something\" to print some string on the console. On the other hand, **Python 3** uses print as a function and used as print(\"something\") to print something on the console.\n", |
| 150 | + "\n", |
| 151 | + "\n", |
| 152 | + "* **Python 2** uses the function **raw_input()** to accept the user's input. It returns the string representing the value, which is typed by the user. To convert it into the integer, we need to use the int() function in Python. On the other hand, **Python 3** uses **input()** function which automatically interpreted the type of input entered by the user. However, we can cast this value to any type by using primitive functions (int(), str(), etc.).\n", |
| 153 | + "\n", |
| 154 | + "\n", |
| 155 | + "* In **Python 2**, the implicit string type is **ASCII**, whereas, in **Python 3**, the implicit string type is **Unicode** \n", |
| 156 | + "\n", |
| 157 | + "\n", |
| 158 | + "* **Python 3** doesn't contain the **xrange()** function of **Python 2**. The **xrange()** is the variant of **range()** function which returns a xrange object that works similar to **Java iterator.** The range() returns a list for example the function range(0,3) contains 0, 1, 2.\n", |
| 159 | + "\n", |
| 160 | + "\n", |
| 161 | + "* There is also a small change made in Exception handling in **Python 3.** It defines a keyword as which is necessary to be used. We will discuss it in Exception handling section of Python programming tutorial.\n" |
| 162 | + ] |
| 163 | + }, |
| 164 | + { |
| 165 | + "cell_type": "markdown", |
| 166 | + "metadata": { |
| 167 | + "heading_collapsed": true |
| 168 | + }, |
| 169 | + "source": [ |
| 170 | + "## Python Applications Area\n", |
| 171 | + "\n", |
| 172 | + "Python is known for its **general purpose** nature that makes it applicable in almost each domain of software development. Python as a whole can be used in any sphere of development. \n", |
| 173 | + "\n", |
| 174 | + "\n", |
| 175 | + "Here, we are **specifing applications** areas where python can be applied.\n", |
| 176 | + "\n", |
| 177 | + "1. #### Web Applications\n", |
| 178 | + "-We can use Python to develop web applications. It provides libraries to handle internet protocols such as HTML and XML, JSON, Email processing, request, beautifulSoup, Feedparser etc. It also provides Frameworks such as Django, Pyramid, Flask etc to design and delelop web based applications. Some important developments are: PythonWikiEngines, Pocoo, PythonBlogSoftware etc.\n", |
| 179 | + "\n", |
| 180 | + "2. #### AI & Machine Learning \n", |
| 181 | + "-Python has Prebuilt Libraries like Numpy for scientific computation, Scipy for advanced computing and Pybrain for machine learning (Python Machine Learning) making it one of the best languages For AI.\n", |
| 182 | + "\n", |
| 183 | + "3. #### Desktop GUI Applications \n", |
| 184 | + "-Python provides Tk GUI library to develop user interface in python based application. Some other useful toolkits wxWidgets, Kivy, pyqt that are useable on several platforms. The Kivy is popular for writing multitouch applications.\n", |
| 185 | + "\n", |
| 186 | + "4. #### Software Development \n", |
| 187 | + "-Python is helpful for software development process. It works as a support language and can be used for build control and management, testing etc.\n", |
| 188 | + "\n", |
| 189 | + "5. #### Scientific and Numeric \n", |
| 190 | + "-Python is popular and widely used in scientific and numeric computing. Some useful library and package are SciPy, Pandas, IPython etc. SciPy is group of packages of engineering, science and mathematics.\n", |
| 191 | + "\n", |
| 192 | + "6. #### Business Applications \n", |
| 193 | + "-Python is used to build Bussiness applications like ERP and e-commerce systems. Tryton is a high level application platform.\n", |
| 194 | + "\n", |
| 195 | + "7. #### Console Based Application \n", |
| 196 | + "-We can use Python to develop console based applications. For example: IPython.\n", |
| 197 | + "\n", |
| 198 | + "8. #### Audio or Video based Applications \n", |
| 199 | + "-Python is awesome to perform multiple tasks and can be used to develop multimedia applications. Some of real applications are: TimPlayer, cplay etc.\n", |
| 200 | + "\n", |
| 201 | + "9. #### 3D CAD Applications \n", |
| 202 | + "-To create CAD application Fandango is a real application which provides full features of CAD.\n", |
| 203 | + "\n", |
| 204 | + "10. #### Enterprise Applications \n", |
| 205 | + "-Python can be used to create applications which can be used within an Enterprise or an Organization. Some real time applications are: OpenErp, Tryton, Picalo etc.\n", |
| 206 | + "\n", |
| 207 | + "11. #### Applications for Images \n", |
| 208 | + "-Using Python several application can be developed for image. Applications developed are: VPython, Gogh, imgSeek etc.\n", |
| 209 | + "\n", |
| 210 | + "12. #### Games and 3D Graphics \n", |
| 211 | + "-PyGame, PyKyra are two frameworks for game-development with Python. Apart from these, we also get a variety of 3D-rendering libraries. If you’re one of those game-developers, you can check out PyWeek, a semi-annual game programming contest." |
| 212 | + ] |
| 213 | + }, |
| 214 | + { |
| 215 | + "cell_type": "code", |
| 216 | + "execution_count": null, |
| 217 | + "metadata": { |
| 218 | + "hidden": true |
| 219 | + }, |
| 220 | + "outputs": [], |
| 221 | + "source": [] |
| 222 | + } |
| 223 | + ], |
| 224 | + "metadata": { |
| 225 | + "hide_input": false, |
| 226 | + "kernelspec": { |
| 227 | + "display_name": "Python 3", |
| 228 | + "language": "python", |
| 229 | + "name": "python3" |
| 230 | + }, |
| 231 | + "language_info": { |
| 232 | + "codemirror_mode": { |
| 233 | + "name": "ipython", |
| 234 | + "version": 3 |
| 235 | + }, |
| 236 | + "file_extension": ".py", |
| 237 | + "mimetype": "text/x-python", |
| 238 | + "name": "python", |
| 239 | + "nbconvert_exporter": "python", |
| 240 | + "pygments_lexer": "ipython3", |
| 241 | + "version": "3.8.3" |
| 242 | + }, |
| 243 | + "varInspector": { |
| 244 | + "cols": { |
| 245 | + "lenName": 16, |
| 246 | + "lenType": 16, |
| 247 | + "lenVar": 40 |
| 248 | + }, |
| 249 | + "kernels_config": { |
| 250 | + "python": { |
| 251 | + "delete_cmd_postfix": "", |
| 252 | + "delete_cmd_prefix": "del ", |
| 253 | + "library": "var_list.py", |
| 254 | + "varRefreshCmd": "print(var_dic_list())" |
| 255 | + }, |
| 256 | + "r": { |
| 257 | + "delete_cmd_postfix": ") ", |
| 258 | + "delete_cmd_prefix": "rm(", |
| 259 | + "library": "var_list.r", |
| 260 | + "varRefreshCmd": "cat(var_dic_list()) " |
| 261 | + } |
| 262 | + }, |
| 263 | + "types_to_exclude": [ |
| 264 | + "module", |
| 265 | + "function", |
| 266 | + "builtin_function_or_method", |
| 267 | + "instance", |
| 268 | + "_Feature" |
| 269 | + ], |
| 270 | + "window_display": false |
| 271 | + } |
| 272 | + }, |
| 273 | + "nbformat": 4, |
| 274 | + "nbformat_minor": 2 |
| 275 | +} |
0 commit comments