{"id":1661,"date":"2020-05-19T03:51:43","date_gmt":"2020-05-19T03:51:43","guid":{"rendered":"https:\/\/www.afternerd.com\/blog\/?p=1661"},"modified":"2020-06-09T14:55:05","modified_gmt":"2020-06-09T14:55:05","slug":"what-is-python-used-for","status":"publish","type":"post","link":"https:\/\/www.afternerd.com\/blog\/what-is-python-used-for\/","title":{"rendered":"What is Python used for?"},"content":{"rendered":"<p><em>So what is Python really used for?<\/em><\/p>\n<p>If you are really asking this question, then I am going to assume that you are a beginner who is not entirely sure if investing your time learning Python is a good choice.<\/p>\n<p>I totally get it.<\/p>\n<p><span style=\"font-weight: 400;\">When you are new to the world of programming, it is easy to get overwhelmed by the sheer amount of programming languages.<\/span><\/p>\n<p>You probably have received a lot of advice to start your programming learning journey with Python.<\/p>\n<p>But you are still not sure.<\/p>\n<p><em>What can you really do with Python?<\/em><\/p>\n<p><span style=\"font-weight: 400;\"> In this article, I will try to enumerate all the main applications that Python is used for \ud83d\ude42<\/span><\/p>\n<p>Here are 5 things you can do with Python. Let&#8217;s get started!<\/p>\n<h2>0- Python is a general-purpose Programming Language<\/h2>\n<p>Let&#8217;s get this out of the way.<\/p>\n<p>First and foremost, Python is a general-purpose programming language.<\/p>\n<p>Like any other programming language, Python is a tool that you can use to build software. <em>ANY<\/em> software.<\/p>\n<p>This is critical to understand and internalize because a lot of beginners think that they are boxing themselves into a corner by choosing one language over the other.<\/p>\n<p>Don&#8217;t worry. You are not.<\/p>\n<p>Whether you choose to learn C++, Java, or Python&#8230;you will be fine. They are all very popular languages that are very popular in our industry.<\/p>\n<p>Here is the <a href=\"https:\/\/www.tiobe.com\/tiobe-index\/\" target=\"_blank\" rel=\"noopener noreferrer\">TIOBE index of the most popular programming languages<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1789\" src=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/Screen-Shot-2020-04-30-at-8.51.09-PM-1024x314.png\" alt=\"\" width=\"1024\" height=\"314\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/Screen-Shot-2020-04-30-at-8.51.09-PM-1024x314.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/Screen-Shot-2020-04-30-at-8.51.09-PM-300x92.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/Screen-Shot-2020-04-30-at-8.51.09-PM-768x236.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/Screen-Shot-2020-04-30-at-8.51.09-PM-200x61.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/Screen-Shot-2020-04-30-at-8.51.09-PM-400x123.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/Screen-Shot-2020-04-30-at-8.51.09-PM-600x184.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/Screen-Shot-2020-04-30-at-8.51.09-PM-800x246.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/Screen-Shot-2020-04-30-at-8.51.09-PM-1200x368.png 1200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/Screen-Shot-2020-04-30-at-8.51.09-PM.png 1890w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>The <em>TIOBE index<\/em> is a well-known indicator of the popularity of programming languages.<\/p>\n<p>As you can see, Python is really high up on the list!<\/p>\n<p>In addition to its popularity, Python also has the advantage of being one of the easiest programming languages to learn.<\/p>\n<p>So if you are completely new to the world of programming and you don&#8217;t know what language to start with, then I highly recommend you start with Python.<\/p>\n<p><a href=\"https:\/\/www.afternerd.com\/blog\/learn-python\/\" target=\"_blank\" rel=\"noopener noreferrer\">Here is an in-depth guide that I wrote about the process of learning Python step-by-step.<\/a><\/p>\n<p>Python also lends itself very well to specific types of applications.<\/p>\n<p>This is what we are going to discuss in the following sections.<\/p>\n<h2>1- Web Applications<\/h2>\n<p>Another area that Python excels at is for <em>creating Web applications<\/em>.<\/p>\n<p>Many people are interested in creating their own web applications. Maybe you want to create your own personal website, or you want to have an online business.<\/p>\n<p>Truth is, creating a web application involves having a solid understanding of <strong>numerous<\/strong> technologies (not just one) because there are so many involved.<\/p>\n<p>To give you an example, let&#8217;s say you type <strong>yahoo.com<\/strong> on your browser.<\/p>\n<p>your browser sends a request to the yahoo web server using a communication protocol called <a href=\"https:\/\/www.w3schools.com\/whatis\/whatis_http.asp\" target=\"_blank\" rel=\"noopener noreferrer\">HTTP<\/a>.<\/p>\n<p>The yahoo web server receives this request and communicates with numerous backend services also using HTTP (or <a href=\"https:\/\/en.wikipedia.org\/wiki\/Remote_procedure_call\" target=\"_blank\" rel=\"noopener noreferrer\">RPC<\/a>).<\/p>\n<p>These backend services eventually respond back to the web server, which assembles a bunch of files (HTML\/CSS\/javascript) and returns them back to your browser.<\/p>\n<p>Finally, your browser reads these files and renders the Yahoo homepage on your screen.<\/p>\n<p><em>So how does Python fit into this picture?<\/em><\/p>\n<p>Python can be used to program the backend services.<\/p>\n<p>As you can see, in order to build a web application end-to-end, you need to understand many technologies.<\/p>\n<p>However, there are some Python libraries and frameworks that make this job a little easier.<\/p>\n<p><span style=\"font-weight: 400;\">For instance, <a href=\"https:\/\/flask.palletsprojects.com\/en\/1.1.x\/\" target=\"_blank\" rel=\"noopener noreferrer\">Flask<\/a> and <a href=\"https:\/\/www.djangoproject.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Django<\/a> are popular web frameworks that allow you to write your web applications using all these technologies in one &#8220;place&#8221;.&nbsp;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Flask is a microframework. It is a simple web framework capable of sending and receiving HTTP network requests.&nbsp;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Django, on the other hand, is a full-fledged web framework. It can do everything Flask does in addition to native support for authentication, authorization, and database modeling.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Both Flask and Django have strong communities and great documentation. <\/span><\/p>\n<h2>2- Numerical Analysis, Data Science and Visualization<\/h2>\n<p><span style=\"font-weight: 400;\">When you hear <em>numerical analysis and data visualization<\/em>, usually a lot of random-looking numbers and fancy graphs float before your eyes. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">We have studied and used these at school, but how can we connect this mathematical world with the programming world?<\/span><\/p>\n<p>There are only a few programming languages that do this job well.<\/p>\n<p><span style=\"font-weight: 400;\">Python is definitely on top of this list.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">There are numerous Python libraries in this domain, the most commonly used are <a href=\"https:\/\/numpy.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">NumPy<\/a>, <a href=\"https:\/\/www.scipy.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">SciPy<\/a>, and <a href=\"https:\/\/matplotlib.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Matplotlib<\/a>.<\/span><\/p>\n<p>Let&#8217;s talk about each one of these, and what they can do.<\/p>\n<p><span style=\"font-weight: 400;\"><strong>NumPy<\/strong> (short for Numerical Python) is a Python library specifically created to handle operations on multi-dimensional arrays in an efficient and fast manner. These operations include virtually any operation you can perform on a Matrix.<\/span><\/p>\n<p><em>But can&#8217;t we just do matrix operations using regular lists in Python?<\/em><\/p>\n<p>Long story short, NumPy is optimized for processing large amounts of numerical data. So it really boils down to performance.<\/p>\n<p><span style=\"font-weight: 400;\">When you have millions or billions of numbers to process, speed and memory consumption are crucial.<\/span><\/p>\n<p>Here is a<a href=\"https:\/\/s3.amazonaws.com\/assets.datacamp.com\/blog_assets\/Numpy_Python_Cheat_Sheet.pdf\" target=\"_blank\" rel=\"noopener noreferrer\"> cheat sheet for using NumPy provided by Datacamp<\/a>.<\/p>\n<p><em>Alright, how about <strong>SciPy<\/strong>?<\/em><\/p>\n<p><span style=\"font-weight: 400;\">Scipy (short for Scientific Python) is a Python library for solving mathematical, science, and engineering problems. You can think of it as an abstraction on top of NumPy (it does actually use NumPy under the hood). <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Some examples of the operations you can do with Scipy are Fourier transforms, numerical integrations, gradients, derivatives, and so much more&#8230;<\/span><\/p>\n<p><em>now after you have all your numerical results, how do you actually visualize these results in a nice-looking graph or a pie chart?<\/em><\/p>\n<p>This is where <strong>Matplotlib<\/strong> comes into the picture.<\/p>\n<p><span style=\"font-weight: 400;\">Matplotlib is a library for creating visualizations, like graphs, bar charts, line charts, pie charts, etc&#8230;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">It can plot 2D graphs as well as 3D graphs.<\/span><\/p>\n<p>Here is an example of how Matplotlib graphs look like. These examples are from the <a href=\"https:\/\/matplotlib.org\/3.2.1\/tutorials\/introductory\/sample_plots.html\" target=\"_blank\" rel=\"noopener noreferrer\">Matplotlib website<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"post-img alignnone wp-image-1777 size-large\" src=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/04\/Screen-Shot-2020-04-29-at-9.24.18-PM-1024x372.png\" alt=\"\" width=\"1024\" height=\"372\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/04\/Screen-Shot-2020-04-29-at-9.24.18-PM-1024x372.png 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/04\/Screen-Shot-2020-04-29-at-9.24.18-PM-300x109.png 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/04\/Screen-Shot-2020-04-29-at-9.24.18-PM-768x279.png 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/04\/Screen-Shot-2020-04-29-at-9.24.18-PM-200x73.png 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/04\/Screen-Shot-2020-04-29-at-9.24.18-PM-400x145.png 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/04\/Screen-Shot-2020-04-29-at-9.24.18-PM-600x218.png 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/04\/Screen-Shot-2020-04-29-at-9.24.18-PM-800x290.png 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/04\/Screen-Shot-2020-04-29-at-9.24.18-PM-1200x435.png 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<h2>3- Machine Learning<\/h2>\n<p><span style=\"font-weight: 400;\">How many times have you watched a title on Netflix just because it was <em>recommended<\/em> to you? I guess it&#8217;s plenty.&nbsp;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">How cool is it that your Amazon Alexa is able to understand you clearly most of the time?<\/span><\/p>\n<p><span style=\"font-weight: 400;\">These, and many others, are some of the examples that are powered by the fascinating branch of Computer Science &#8211; <em>Machine Learning<\/em>.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Though Machine Learning concepts <a href=\"https:\/\/en.wikipedia.org\/wiki\/Timeline_of_machine_learning\" target=\"_blank\" rel=\"noopener noreferrer\">existed in theory since the 1960&#8217;s<\/a><\/span><span style=\"font-weight: 400;\">,&nbsp; only recently has it started to get traction mainly due to the massive availability of computational resources, as well as the plethora of languages that made writing machine learning applications &#8220;easier&#8221;.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Python has become the \u201cde facto\u201d programming language for writing Machine Learning applications.<\/span><\/p>\n<p>So if data science and machine learning are what you want to do in your career, then learning Python is a must!<\/p>\n<p><em>So Karim, tell me, what Python libraries should I learn in order to write machine learning applications?<\/em><\/p>\n<p><span style=\"font-weight: 400;\">There are plenty, but the most popular are <a href=\"https:\/\/scikit-learn.org\/stable\/\" target=\"_blank\" rel=\"noopener noreferrer\">scikit-learn<\/a>, <a href=\"https:\/\/www.tensorflow.org\/tutorials\" target=\"_blank\" rel=\"noopener noreferrer\">Tensorflow<\/a>, and <a href=\"https:\/\/pytorch.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">PyTorch<\/a>.&nbsp;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For one to develop a typical machine learning application, these libraries make the job way easier! <\/span><\/p>\n<p><span style=\"font-weight: 400;\">With these libraries, you will need to understand why you are using an ML algorithm, how it works, and its shortcomings but you don&#8217;t need to worry about \u201chow it is implemented\u201d.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">However,&nbsp; I highly encourage you to understand the math and statistics behind the ML algorithms so that you can reason about the working of the model.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">You see, anyone can learn how to use a library. What is going to differentiate you as a data scientist is your understanding of the fundamental concepts that underpin these machine learning algorithms. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">So keep that in mind, it is only about learning how to use a Python library.<\/span><\/p>\n<h2>4- Raspberry Pi<\/h2>\n<p><span style=\"font-weight: 400;\">When growing up, some of you wanted to build that fancy computer system your friend had bought. But you didn\u2019t because of obvious reasons \ud83d\ude42<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Thanks to the evolution of processing resources, now you are able to buy a <strong>full computer<\/strong> at an affordable price.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For example, a very popular computer system is the <a href=\"https:\/\/amzn.to\/2Ymvma4\" target=\"_blank\" rel=\"noopener noreferrer\">Raspberry Pi<\/a>. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">A Raspberry Pi is a single-tiny-board computer that has all the components a typical computer would have in a single board that is as big as your palm.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">It is generally used for learning purposes, but <a href=\"https:\/\/projects.raspberrypi.org\/en\" target=\"_blank\" rel=\"noopener noreferrer\">that shouldn&#8217;t stop you from using the Raspberry Pi to create some cool real-life projects<\/a>.&nbsp;<\/span><span style=\"font-weight: 400;\">&nbsp;<\/span><\/p>\n<p><em>OK that&#8217;s cool and all but how is this connected with Python?<\/em><\/p>\n<p><span style=\"font-weight: 400;\">Guess what? You can actually program your Raspberry Pi board using Python.&nbsp;<\/span><\/p>\n<p>What I mean by that is not only can you write Python programs similar to the ones you write on a typical computer, but also you can program the hardware itself, interact with I\/O pins, display LEDs, and even external devices. It is pretty cool!<\/p>\n<p><span style=\"font-weight: 400;\">I believe playing around with a Raspberry Pi is a perfect way to learn how software and hardware interact together.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1790\" src=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/IMG_5329_2-1024x768.jpg\" alt=\"\" width=\"1024\" height=\"768\" srcset=\"https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/IMG_5329_2-1024x768.jpg 1024w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/IMG_5329_2-300x225.jpg 300w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/IMG_5329_2-768x576.jpg 768w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/IMG_5329_2-200x150.jpg 200w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/IMG_5329_2-400x300.jpg 400w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/IMG_5329_2-600x450.jpg 600w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/IMG_5329_2-800x600.jpg 800w, https:\/\/www.afternerd.com\/blog\/wp-content\/uploads\/2020\/05\/IMG_5329_2-1200x900.jpg 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>Here is my precious raspberry pi. I am holding it on my palm so that you can get a sense of how small it is \ud83d\ude42<\/p>\n<p>I have been using it predominantly to monitor my real-time google analytics traffic on an external screen.<\/p>\n<p>This is a straight-forward use-case.<\/p>\n<p>Let&#8217;s talk about another more complex example.<\/p>\n<p>One cool project that runs on a Raspberry Pi is PiCroft.<\/p>\n<p><span style=\"font-weight: 400;\"><a href=\"https:\/\/mycroft.ai\/get-started\/\" target=\"_blank\" rel=\"noopener noreferrer\">PiCroft<\/a> is an open-source voice assistant similar to Alexa and Siri.<\/span><span style=\"font-weight: 400;\">&nbsp;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If one is able to build complex projects like <\/span><b>PiCroft <\/b>on a Raspberry Pi<span style=\"font-weight: 400;\">, imagine all the cool projects that you can build on it!<\/span><\/p>\n<p><span style=\"font-weight: 400;\">So go ahead, build something fun, and share it with the world.<\/span><\/p>\n<h3>Learning Python?<\/h3>\n<p>Check out <a href=\"https:\/\/courses.afternerd.com\/\">the Courses section!<\/a><\/p>\n\n<h2>Featured Posts<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.afternerd.com\/blog\/learn-python\/\">The Python Learning Path (From Beginner to Mastery)<\/a><\/li>\n<li><a href=\"https:\/\/www.afternerd.com\/blog\/learn-computer-science\/\">Learn Computer Science (From Zero to Hero)<\/a><\/li>\n<li><a href=\"https:\/\/www.afternerd.com\/blog\/coding-interview\/\">Coding Interview Preparation Guide<\/a><\/li>\n<li><a href=\"https:\/\/www.afternerd.com\/blog\/stock-investing-for-beginners\/\">The Programmer&#8217;s Guide to Stock Market Investing<\/a><\/li>\n<li><a href=\"https:\/\/www.afternerd.com\/blog\/start-programming-blog\/\">How to Start Your Programming Blog?<\/a><\/li>\n<\/ul>\n<div class=\"after-post-box\">\n<h2>Are you Beginning your Programming Career?<\/h2>\n<h3>I provide my best content for beginners in the newsletter.<\/h3>\n<ul>\n<li>Python tips for beginners, intermediate, and advanced levels.<\/li>\n<li>CS Career tips and advice.<\/li>\n<li>Special discounts on my premium courses when they launch.<\/li>\n<\/ul>\n<p>And so much more&#8230;<\/p>\n<h3>Subscribe now. It&#8217;s Free.<\/h3>\n<p><script type=\"text\/javascript\" src=\"\/\/mautic.afternerd.com\/form\/generate.js?id=2\"><\/script><\/p>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":1815,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[13],"yst_prominent_words":[1615,1495,70,1607,1610,55,1605,64,53,1122,158,1616,1596,971,843,1481,846,1603,1604,1614],"_links":{"self":[{"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/posts\/1661"}],"collection":[{"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/comments?post=1661"}],"version-history":[{"count":18,"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/posts\/1661\/revisions"}],"predecessor-version":[{"id":2529,"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/posts\/1661\/revisions\/2529"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/media\/1815"}],"wp:attachment":[{"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/media?parent=1661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/categories?post=1661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/tags?post=1661"},{"taxonomy":"yst_prominent_words","embeddable":true,"href":"https:\/\/www.afternerd.com\/blog\/wp-json\/wp\/v2\/yst_prominent_words?post=1661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}