Python: Extract, Manipulate and Analyze Data with 5 Projects | Yoda Learning | Skillshare

Python: Extract, Manipulate and Analyze Data with 5 Projects

Yoda Learning, Become 4X faster

Python: Extract, Manipulate and Analyze Data with 5 Projects

Yoda Learning, Become 4X faster

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
74 Lessons (6h 47m)
    • 1. Know how Becoming Data Analyst can be a good career for you.

    • 2. 0101 Understanding the significance of programming in your personal and professional life

    • 3. 0201 Installing python on windowslinuxmac

    • 4. 0202 Playing with pip and installing packages

    • 5. 0203 Playing with the python shell

    • 6. 0204 Choosing the right IDECode editor

    • 7. 0205 Writing your first python code and running it under different environments

    • 8. 0301 Dealing with variables and string

    • 9. 0302 Numbers and different operators in python

    • 10. 0302b Numbers and different operators in python

    • 11. 0303 Introduction with important built in types in python

    • 12. 0303b Introduction with important built in types in python

    • 13. 0303c Introduction with important built in types in python

    • 14. 0401 Understanding logical operators and expressions

    • 15. 0402 Making decisions through if else clauses

    • 16. 0403 Repeating or looping the decisions multiple times and stopinng them

    • 17. 0404 Handling the errors and exceptions inn our decisions

    • 18. 0501 Creating your first function

    • 19. 0502 Understanding input parameters and return type in functions

    • 20. 0503 Nesting functions

    • 21. 0504 Calling functions from other function

    • 22. 0505 writing recursive functions

    • 23. 0601 Organizing your code into modules and packages

    • 24. 0701 Dealing with our first file and using write operation

    • 25. 0702 Reading from files and processing the text

    • 26. 0703 handling file errors

    • 27. 0704 Exploring the OS package to play with paths and directories

    • 28. 0801 What is data Science and what does data scientists do

    • 29. 0802 Why python for data analysis and other data related tasks

    • 30. 0901 Introdunction of RDBMS

    • 31. 0902 Introdunction to POSTGRESQL

    • 32. 0903 Installing postgresql on different platforms

    • 33. 0904 Playing with postgresql

    • 34. 0904b Playing with postgresql

    • 35. 0905 Dealing with postgresql using python

    • 36. 0906 Case study

    • 37. 1001 Introdunction with different data sources

    • 38. 1002 Understanding JSON

    • 39. 1003 Dealing with JSON using python

    • 40. 1004 Understanding CSV

    • 41. 1005 Dealing with CSV using python

    • 42. 1006 Understanding XML

    • 43. 1007 Dealing with XML using python

    • 44. 1008 Understanding EXCEL

    • 45. 1009 Dealing with EXCEL using python

    • 46. 1010 excel processing 1

    • 47. 1011 Excel Processing 2

    • 48. 1012 Case study

    • 49. 1101 Brief introdunction to Big Data

    • 50. 1102 What is NOSQL

    • 51. 1103 MONGODB The first inrtodunction

    • 52. 1104 Installing MONGODB on your platfrom

    • 53. 1105 Getting down with MONGODB

    • 54. 1106 Interacting with MONGODB with python using PYTMONGO

    • 55. 1201 Understanding the WEB world Why would need data from web

    • 56. 1202 What is Web Scraping

    • 57. 1203 The Introdunction to Requests and Beautiful Soup module

    • 58. 1203b The Introdunction to Requests and Beautiful Soup module

    • 59. 1204 Creating a simple web sraper using python

    • 60. 1205 Dealing with scraped data using NOSQL

    • 61. 1206 Case study

    • 62. 1207 Web Scraper Solution

    • 63. 1301 What is Data Analysis What are its applications

    • 64. 1302 Brief introdunction to NUMPY and PANDAS

    • 65. 1303 Playing with your Data Frame

    • 66. 1304 Visualizing and understanding your scraped data

    • 67. 1305 Data Visualization Example

    • 68. 1306 Case study

    • 69. 1401 What is EDA(Exploratory Data Analysis)

    • 70. 1402 Introdunction to Data Nitro

    • 71. 1403 Basics Operation of Data Nitro

    • 72. 1404 Charts in Data Nitro

    • 73. 1405 Data Nitro Example

    • 74. 1406 Case study

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

Does your profession require you to deal with large data on a regular basis?   Do you wish you could be better at dealing with those numbers?  This course brings about a solution for you by teaching you how to manipulate and analyse the data in the most basic language, Python. This course doesn’t only seek to teach you about data analysis but also helps you learn how to apply it in real-life situations. Apart from detailed programs on learning the basics of Python and the art of data analysis using Python, the course provides you with five projects that are real-life case studies. Starting with the basics of Python, learn how to analyse big data, visualise them, and become an entry-level data analyst.______________________________________________________________________ Here is an outline of what we'll cover through the entire course: Preparing your environment and software installation Logical and looping constructs Dealing with functions Modules and packages Dealing with file I/O in Python Working on different data types such as CSV, JSON, RDBMS, and Excel Dealing with non-relational database management systems Dealing with web-related data Data analysis and visualisation using DataNitro ______________________________________________________________________ Real-Life Project Work was done with Python: Once we've got a grip of Python and data analysis, it'd be great if we could get some hands-on experience by trying out what we've learned, right? So here are some projects that we'll work on: Project: Data management system using RDBMS  Problem statement: A company XYZ sales deals in solar products and they sell their products all across a country to their customers. So far they have been storing their data in an Excel file. But since their growth has exceeded and in sync with the sales, they need a concrete data management system with an organised data structure Project: Store data from a CSV file to RDBMS.  Problem statement: Take Yahoo finance data in the CSV format and store the data into an RDBMS. ·Project: Dealing with Web Data  Problem statement: Dmoz  is a website, which is an open directory for various websites regarding different categories. We can go to the sports section and get related websites. However, websites keep getting added. So, we need to create a web scraper that automatically fetches all the links in the particular category and stores the data in a CSV format on the file system. Project: Data Analysis and Visualization Problem statement: UIDAI (Unique Identification Authority of India) is an Indian authority responsible for creating biometric data-based identification cards for the Indian citizens. They provide data based on state, gender, and rejection and acceptance of the identification cards in the form of a CSV file. We need to create a helpful visualisation to explore which state, age range, or gender got how much percentage of cards rejected or accepted. Project: DataNitro  Problem statement: Yahoo finance hosts financial data for different companies. We need to implement a solution that can get finance data of different companies and make charts based on the fetched data. We also take you through DataNitro [It lets you run any Python script or library - right in your spreadsheet]. I'm in love with this tool :) [Disclosure - I'm not their affiliate and make no money from their sales]______________________________________________________________________ Important information before you join: Once enrolled, you have unlimited, lifetime access to the course! You will have instant and free access to any updates I'll add to the course. I will give you my full support regarding any issues or suggestions related to the course. Guided practice - over worksheets included for immediate practice Access to all videos 24 x 7 - learn online from anywhere ----------------------------------------------------------------------------------------------------------------- If you have read this far, next action is JOINING this course. Invest 6 hrs. for a benefit of the lifetime.

Meet Your Teacher

Teacher Profile Image

Yoda Learning

Become 4X faster


Hello, I'm Yoda

Yoda Learning is a team of 12+ industry professionals focused on developing "Project-based"learning solutions, which enable the learners explore real world situations and thus, make the learning process engaging and practical. Our Courses on Technology includes everything including Web Development, Mobile App Development, Data Analytics and Design.

The collective work-experience of 80+ yrs. spans across multiple industries like Manufacturing, IT, Sales, Finance, Marketing, Operations, HR and functional domains such as Office suites, Mobile applications, Digital Marketing, Database Technologies, Networking).


See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.



1. Know how Becoming Data Analyst can be a good career for you.: Hello, everyone, My quick question. Do you Are you a programmer? Do you want to become one? Maybe in both the cases, you might say no. Well, let me tell you, With the advent off big data data visualisation and data science techniques, you can't run away from the large data data that requires your attention Analysis. Visualization on the time frame would be very, very less on, because off that coding is something that will also be attached to the solution. Don't worry. Don't assume that the baby we're looking at according a decade back, it's the same level of difficulty that feel free facing why learning some new language. In fact, biting language has been one of the most popular emerging languages, which is very easy to use and at times significantly faster on requires lesser Lang's off court. When you compare it with other languages such a C plus plus java on visual basic, somebody likely said that it's not the language that matter. What you do with them does I like to share that thought with you. People who can court in the world of technology are a lot of them. You'll be facing the crowd However, if you can code in the rim off biology, medicine, finance, physics, government, mathematics history, you'll be respected. You'll be ableto advanced. The disciplines do something that you appeared would not have thought about in the first stance. So as the environment expands, you'll not only work with single function like only finance will be working with several databases. Excel included sequel databases, Internet directories, stock quotations and how do you find one common ground amongst all the answer despite it, So start a learning part where you not only learn the one of the most popular languages called beytin, but he also see how it can be quickly integrated with Excel to fetch you some wonderful data analysis. In fact, to make it more realistic, we have taken five practical projects in our program. One of them is based on Web scraping. If you refer to any website for pulling information such as prices and product names, etcetera, new categories may get either. New links may get added to those websites. So how do you keep updating those information automatically? You have taken another project, which is based on data analysis and visualization. For example, in India, the unique identification authority off India, which is an Indian authority. It has been assigned the task off. Creating biometric state are based i D cards for the citizens off the country. Now. Ah, lot off variables go inside, storing that data. So how do you visualize that is something that we will see in our program. In addition to that, we have taken another Adam called Data Nitro on. It's very much relevant for people in finance, so you have to pull information, which could be based on stock quotation, which could be based on you to majority of different borns. On. That is how your information and decision making dashboards can get updated quickly. Diamonds off essence in the world of finance, so be prepared. So in this program as a comprehensive learning tutorial, we have provided six ours off videos, five projects with solutions, all practical, usable bite and goods that each chapter on, of course, quiz to test your knowledge. So my suggestions go for it. Seeing the program 2. 0101 Understanding the significance of programming in your personal and professional life: Hello, everyone. Welcome to the tutorial on Python basics, and today we're actually going to talk about what is programming. So this is the very first tutorial of this entire Siri's. And let me remind you quickly what we're exactly going to do in this entire tutorial of Siris of Python with basics. So, actually, as per the format says in each and every tutorial, we are actually going to have three basic steps. We're going to understand what is the entire chapter all about and feature out the important keynote off the chapter. Then we're going to discuss about the basic agendas of that particular chapter, which we would be covering in that specific tutorial. And then we will talk about all the nitty gritty details and what you can do along with that specific subject once following the tutorial. So we'll also be having lots of quizzes, programming problems, questions which you want to follow and solved by yourself. And in case if you get stuck somewhere, we actually have a discussion forum as well, where you can post your questions inquiries regarding any sort of topic, you are confused. So let's go ahead and talk about programming if you are not very familiar to programming, and you might have seen lots of programmers around the world, you might have noticed. There are a couple of people who have this daunting looking screen with random colors usually dark and contrast with number of variables running up and around along with a very sophisticated OS. And they're obviously quite busy, often coding any sort of algorithm or program onto their computer, which is out of your understanding. So what I want to first define is program is basically, if you have any sort of problem and you have a way to solve it and develop an algorithm and solve it by yourself, then actually it doesn't matter. You're putting some language into use or putting into computer or not, but you're actually doing some sort of programming. So programming and all this computer stuff is pretty interesting nowadays, and basically the youth is catching up to the various reasons. One reason The opportunity is very big over there. But that's not the only reason apart from that, actually, we have lots of things going on. For example, there have been a lot of movies which actually feature programming and daunting screens, which looks pretty cool to each and every youth, so they try to engage themselves in programming. But when they see that the entire process is pretty complex, often most of them back out and the reason they actually engage their career into the programming field. If you want to see there are lots of movies, basically, theater traction of the youth to attract towards programming, apart from that early engagement with the games is also one of the reasons that actually involves programmers to get it started with. Now. This was about youth. Let's talk about why a particular middle aged man or maybe a man beyond 30 should always gives himself into programming. So before we dive into that, let's discuss the basic agenda as of this chapter. So the first agenda is understanding the nature of programming. And why should you learn programming? The nature of the programming is pretty simple. If you see until in the less you want to engage into some serious sort of programming or do very daunting tasks. Building different E r P solutions or building Web APS building cloud building, ai models, etcetera. The concept of programming is pretty simple. You have a problem in hand. You create steps to solve that problem, and you often somehow create repetitive or reusable stuff, which could be used again and again to specifically solved that particular problem. For example, if we watch a TV, it's also based on different sorts of programs as well. Having said that, let's come to the point that why should a middle aged person engaged himself in programming so we can see that in today's world, most of the people are engaged in corporate activities, which involves interaction with any sort of I t contractor or I t professional frequently and even you have to do sort of daily tasks, which are not entirely programming but user friendly programs, which actually deals a lot with computers. For example, let's say spreadsheet programs, Emmis word, M s excel or any sort of stuff, any Web application. All of them have certain steps which need to be taken to solve your problem. Even if you're inserting a simple formula in Excel sheet, that's also sort of a very basic level of programming. And that is why a middle age person should pursue apart from that, if you are at any age and you want to learn programming. What helps is programming is a philosophy which leads to life in a better way. It gives you a purpose to define your problems in each and every step more clearly than before, learning programming and help you to solve them more efficiently than ever. So why should you engage yourself in programming? Either you are a young person or middle aged person. The basic purpose of programming is to let your life be as easy as much as it would be possible. So what I'm saying is, today's world is actually surrounded by lots of computer stuff programs, Web applications and a lot of other things. So if you want to be yourself a little bit useful in that particular scenario, learning programming of any sort could be very helpful. Now, as you might be thinking, that programming is a pretty daunting task and there are lots of programming languages that doesn't seem to be crossing your mind at all. So how should I get started? So before we get into anything, let me define one of the most ease of programming and easy to pick up programming languages . Python and which is also used for very complex tasks as well. So that's what we're going to do. And this is why all of our course is basically entirely dependent on Python. So we're going to learn python over here throughout the semester course, and also we will try to define different sort of data analysis techniques and how they are achieved using python. In our next tutorial, we're actually going to prepare in a moment to work on python efficiently and without any problems being any sort of operating systems. 3. 0201 Installing python on windowslinuxmac: Hello, everyone. Welcome to this tutorial on python basics, and today we're going to learn how we can install Python on different sorts of operating systems. So the basic agendas air pretty much clear out over here, installing python on Windows on Linux and on Mac, so installing python on windows is pretty straightforward. Let's go to the website. The official website of Python is python dot org's, and what you have to do is go to their download section and you can find the installers for Windows and Mac. So let's try to find for Windows. Now, over here, the installer files of python are given. So in case if you have a 32 bit system, you can download these ones x 86. And if you have a 64 bit system, you can download this one with the word call X 86-64. So I already have downloaded one of the installers for windows, and what I'm going to do is I'm going to double click it or run as administrator. But double clicking will do just fine. So we run this particular program now, it asked me, Do you want install for all users or just specifically you. So I'm gonna go with the option to install for all users. So here's a location which can specify to install python. What I'm going to do is specify D as a location and go ahead with it. This step is actually pretty basic. It's like installing all other software which you install on Windows. So I don't think anyone should have any problem with that. It's going to take a while now. It shows you the package we're gonna install so you can actually exclude packages over here . If you want. We're just gonna let it be by default. Whatever it ISS if you want, then you can add python dot e x c to the path as well, which will be helpful in many cases. So that's the way this installation could take a little while, depending upon the speed of your computer. So we'll have to wait over here. So as you can see, the installation is finally done, and what you're going to do is click on finish and you will go to a command prompt and type python, and it should be over here. As you can see, the Python is finally installed, and you can access it anywhere from the command prompt. Let's talk about installing the python on Lennox actually limits. Already, Almost all of it is closely like Cuban to fedora or red hat, which already comes with Python is preinstalled. Whatever you have to do is you just have to use the standard package manager that a specific clinics destro and just update it. So whatever sort of patches or updates are gonna be there regarding Python. They're gonna automatically get handled more often. The next users are pretty powerful users and already have the basic idea of programming. So I'll assume that you already have Python pretty much set up, so we'll move on to installing Python on Mac. The kernel of Mac is actually off Lennox, so the basic utility is like terminal shell. New utilities are almost the same, and even there is a version of python running in MCAS. Well, but that you can actually update it using the standard package manager. So what you have to do is just go to the same website again, go to the download section and search here for Mac and over here, depending upon the architecture of your Mac book, you can actually select the installer. The process of installing is pretty straightforward, as in Windows, it's just the graphical user or wizard. Actually, the process of installing on Mac is actually pretty easy. You just have to take the installer from here and then put it on your system and run it and follow the wizard, which actually carries out the entire installation for you. So assuming you have installed Python on your Windows or Lennox or Mac and it's up and running, we will go ahead to our next tutorial, which will be playing with Pip and installing packages. This is gonna be pretty interesting because we'll be playing with lots of packages and whatever we can do in Python and will also be running first commands regarding Python, ever as per the scope of this tutorial. So I hope you guys are pretty excited about it. See you in the next tutorial. Thank you. Have a nice day 4. 0202 Playing with pip and installing packages: Hi, everyone. Welcome to this tutorial on Python basics In the previous tutorial, As we know, we learned about installing python in our specific operating systems. In this tutorial, we're going to learn about preparing your involvement for specific functions and utilities in Python. So basically, we have two important agendas in this tutorial. First of all, installing python pipped on your machine and installing any python package using pit. So what is Pip? Let us describe a little bit of python pip Python paper is actually the package manager for Python, and it's mostly used for installing random packages across different times and managing them and removing them from time to time. If you are on a Windows machine and you won't install Python Pip. Luckily, you won't have to do much of a task because python dot org's has already done most of it. So what exactly you want to do is we're gonna go to the command, prompt, and then we're going to the Python directory, and now we're going to the script directory. Most of you know that tab completion feature on the command line, so that's why I didn't have to type the entire path So as you can see here, there's this pip, Dottie XY and pip to dot dxy and luckily it's already been installed here by default. And there's nothing much to be done. However, you might not want to see through this directory again and again. So first of all, let's set up the environment variable for this particular directory so that you can access it from anywhere. For this. We got to go to my computer and then we're going to switch to properties. Then we're going to go to advance system settings. Now the involved variables on the bottom. Right now, you're going to look for this path environment variable, and we're going to edit it. As you can see, there are a lot of variables defined over here, but we have to specifically look for a path variable. And as you can see, there are a lot of values already attached along with it. But we just have to upend our path at the end of this entire path, using a semi colon separator. So, first of all, we want to upend the path C colon, dash python to seven, as you can see in the command, prompt That's the exact directory for Python. Now again for Pip. You're going to again import this path. So in our case, that's C colon, dash, python to seven Add scripts and we are done. Okay, Now, if I restart the command line, I can access python from anywhere. As you can see, I just said to type Python and the interpreter started and same goes with Pip. So here we are. We have successfully set up the pit package manager of Python, and we can start any sort of shell, and we can access it from anywhere. Now let's move on to our second agenda That was installing any python package using pip. So, as you might have seen, there are actually lots of packages. So if you go to python dot org's, you can actually look for something called Python Index So P y p I stands for Python package index. Now we can search for some specific python packages. Right now, what we're interested in is installing beautiful soup package. This is actually html parsa, but we'll discuss it later in detail. So once we search it, here we go. That's beautiful soup. We're going to actually install it in our python interpreter using our pip package manager . So if you try to run this interpreter an import Beautiful soup. Let's see what it says. It says no more dual name, beautiful soup. Very well. Now, what we're gonna do is we're gonna quit this and go to Pip. Install beautiful soup. That is the name of the package and we hit enter. So as you can see, it's collecting the package. As the package was not very large and size, it quickly downloaded it and installed it. Now again, run the Python interpreter and we try to import this beautiful suit package. So as we can see that the package has been installed and if we check the package using P y our command, you can actually see lots of variables over here. There are lots of functions like that and a lot of variables which we will involve later in the video. But for the time being, we will just be looking at this d I r function. Whenever we import some sort of module or package, we can inquire about its entire method which are available once imported, using this de ir command. So this is it pretty easy? And if your Windows user you don't have to do much just the environment, variables and Lennox, it's also pretty easy, but we'll discuss it later on. So this is pretty simple. And we covered the installation of Python Pip and managing packages within Pip. In our next tutorial, we're going to discuss about Python Shell and Python interpreter, and we're going to do lots of stuff, like using the Python interpreter as a scratch pad or a calculator and other things so I'll just leave it here, Thanks. 5. 0203 Playing with the python shell: Hello, everyone. Welcome to this tutorial on Python basics. Today we're going to discuss about Python Shell, how we can interact with it and how we can do activity things while actually working on some project without having to actually type a lot of code and then compile it and then see the output. So the basic agendas of this tutorial, our understanding the need of python shell using python shell is a scratch pad or calculator and using I python shell. So we will discuss about this python shell or python interpreter, and we will then move on toe i python, which is an even more sophisticated interpreter with a lot of other capabilities, which the normal python interpreter doesn't have. For starters, what we're gonna do is we're gonna jump back to our command, prompt and shoot the python command, and it will take us to the interpreter. So actually, in most of the cases, what the scenario is that we have to recall some code and we have to try out a couple of things. For example, if I want to see that if a variable does store a string or not, so it sort of does and doesn't allow single inverted commas in python. So it probably does if you don't follow that. How my storing these variables and how am I using this entirely? You don't need to worry about it for the time being. You just have to consider that this python shell will be using interactive leak code and test out different features of python and maybe doing a lot of other things as well. So we have this python interpreter shell. What I would like to show is something interesting. Whenever you start a python interpreter, you could do something like this. Import this. So the Zen of Python by Tim Peters. It actually points out the basic philosophy behind Python programming. You can read it pretty nicely, and that would be our first input ever in python Interpreter. So congratulations. Now, since we know how to start a python interpreter now we've got to do something along with it . So how about use it as a normal calculator? Let's try it. My apologies. The CLS Command doesn't work out here, so let's try to add two numbers. Okay? Very well, maybe a little bigger number that works out to nicely subtraction works out pretty fine as well. As you can see, it gives me the exact subtraction for multiplication. We basically used the asterisk, and it does the job. Now let's try Division 45 divided by three. Okay, 15 pretty straight. There was no actually a fractional value. Let's try something else. 49 by six. So it's actually eight. However, if we wanted to have the result in decimals, we would have to do something like this 49.0 that's actually made it afloat. And then 6.0. People who don't know actually about float might want to consider for the time being that the integers that do have a fractional value can be considered in a layman's language as a float. But we'll discuss more about it. So once we divide to floats, it actually gives us the fractional part as well, apart from the whole number. Now, let's try something else. It might be some time that you actually have float operates, operates air, basically the term used for the numbers or digits involved in an operation, and the action is basically called the operator and not to try a symbol. So having said that Let's try out a simple division. What I was saying is, actually, there could be cases where you have float operas, but you don't want afloat result like this here happening so you can use it. Another operator called Float Division Operator. That's double slash double forward slash, and when we actually hit it, we see that it turns out pretty fine there. No fractional parts. It has rounded it off entirely. Now let's try some other operator. Maybe. What about module as operator? Most of you might know about module operator. That's a pretty common operator and quite frequently covered in mathematics as well. So let's say if we take eight and does module by two, it gives us zero. Now let's try by seven, and it gives us one. So what the operator does is it returns the remainder of the entire division process, so if we try to divide the eight by two, it gives us zero. And if we try to divide seven by two, obviously the remainder is one. Now this module has to be kept in mind because it is intelligently used in different algorithms at different places to round off large digits and keep them under a loop will discuss that later. Let's now try to do a couple of things which we might want to do. For example, I'm in this python shell and I actually want to see what directory I'm in. Or maybe what are the files in my current directory? Because sooner or later you might have to invoke a function which actually takes a file name or its path is an input, but you can't actually check it for that. You might have to take this entire trouble of quitting this entire interpreter and hitting Enter and then you can have it pretty hectic. We might not be needing it. If we're just talking about Python interpreter, we could have done some other things, like importing the OS module. There are a lot of functions, and as you can see, there's one function called a list D. I R. Again, I used d I r function, so you might want to note that down. It's pretty handy, and you might want to use it frequently. So what I'm going to do is os dot l i s t d I r. I'm going to pass that current directory as a path and it gives me a list of all the elements for all the files which are currently in our directory. So as you can see that it returns a pretty jumbled code and you have to decode it. So yet another hectic way to actually know how many files are over there. Let's take yet another example. There could be cases in shell when you don't have. You just don't want to type the entire name because it could be pretty long. So basically, shells like command prompt or shells and Lennix provide this tab completion feature. So let's check it out. Can we use it in this python interpreter? I just typed the l I s t and try to use the tab feature, but it doesn't work. In place of that, it actually answers attempt. So all in all, there is no tab completion feature as well. So what we're gonna do exactly is we can actually use another pretty nice interpreter called I Python and we can install it using pick package manager For python, the command is pretty simple. Pip install I python, we hit it. And as you can see that the requirement is already satisfied because I have just installed it and it could not be the case in your scenario. And what it would do is it would download all the packages and install them so as installed in my system, I'm just going to start it right away again. Just to clarify this I python package has been kept inside the library package so that library package variable has been defined in our environment system. So we don't have to actually go in some specific directory and invoke it From there. We will just type I python from anywhere, and it will just start fine. So let's solve the first question. Can we see the directories over here? As a matter of fact, we can. And that was just the command ls why it is ls because I python has been created on the theme of Lennox and new utilities. So over there, this package ls method is used basically for listing the files. It's actually different from windows in windows. You can use that de ir command, so just keep the hang of that De ir won't actually work out here is you can see de ir means something entirely different. Moreover, de ir is actually taken in Python already. That's the reason they have to go for l s. Now what other feature can be used? Let's try to see. We can actually clear the screen with CLS Command, which was again the command prompt method, not the interpreters method. So all in all, you can use all of the methods of command prompts over here in this running interpreter, let's try with the date. Since the date is actually a package, it won't run. So it was an intentional mistake, which I made that the names which are already colliding with the Python package names won't actually work out over here. So you might have to actually check a couple of runs to make sure that they're selected commands, which you can use back and forth anyways. What could be yet another feature Lets try to import a package called OS. If you're not sure about what a package is, just consider it as a functionality to import different functions in our later chapters were actually going to discuss about packages and modules in a lot of detail, so you don't have to worry about it. Let's try to check out what sort of methods there are in OS pretty much. Let's go with this special method called start file or let's just for the time being stick with L. I s t D I r peritus. So I python is pretty cool. Let's say if you're confused with any particular package, you can just question market and check the entire projects and all definitions of the package and read more about it. Let's say if you're not interested in this OS package definition or explanation, what you might be looking for is some description of the function called List de IR here it ISS. So whenever you get confused, you don't actually have to go to Google and search for the definition. And what is the basic user job off this particular function? What you can do is you can just write the question mark os dot l i s t d I r. And it will actually tell you what can be done. What you might want to do frequently is go to some particular package and that say, I don't know about, um homis and I goto homis Here is the homis method, I just pointed out. So let's say if you don't know anything about it, but you're pretty lazy enough to go to Google and search about it as well. It's a very common thing. So what you're going to do is exactly you can just type the question mark or ask the name of the method is homis, and it will tell you what it actually does. If it's not very descriptive for you and you want more examples, then you can go to Google. But most of the time you might just want a reminder of what this function used to do in the past. So anyways, this was a very short introduction to the Python interpreter and I Python shell. There are lots of capabilities which can be done using python, which you might want to explore their some nice websites, which you can actually go to and find out about this. I python shell, for example. You might want to search about python pandas. We're going to discuss about this package later on, but you can actually go there, check out the documentation, and in the documentation they have actually explained a lot about here. Tutorials a quick tour of the eye python notebook. If you want to pursue this one you can on your own, maybe you just want to get a little bit mature in this entire course in the next tutorial. The I. D. E is basically a very debatable matter among many coders. But what we're going to do in the next tutorial is we're going to end up with a very perfect I D for you, which will be pretty functional for Python in every way. Thanks a lot. 6. 0204 Choosing the right IDECode editor: Hello, everyone. Welcome to this tutorial on Python basics. Today we're gonna discuss choosing the right I D e or code editor. So let's discuss about the basic agendas in this tutorial. So the basic agendas we have to discuss in this tutorial are what is an I d. And why should we basically care about it, which I d e suits best for your environment, and then we're going to discuss about them. We will try it out a little, and then we will talk about Adam. Editor. Let's talk about I D. I d actually stands for integrated development environment. In most cases, when you're typing some sort of code or doing programming in python, you are not actually gonna always run some interpreter like we just did. We actually have to do a lot of other things as well. You must do all those things like debugging the code and doing profiling of the code. And apart from that doing source a code reduction, re factory ization or source code management. We actually need a lot of tools, and that cannot be done using this Python interpreter. So it's pretty obvious we will have to switch to some I d actually there lots of ideas available for python and that suits them very well. A swell. So if I say I d e, we basically mean an environment where you can actually code and do lots of other stuff is well, for example, you might or might not have a tutorial. You might or might not have an integration of a source code managing system. And apart from that, there could be lots of things which we are going to have to look at right now. Let's talk about the first editor called Vin. Vin is actually a command line editor, and I have just opened the page of this vim. As you can see them, is an advanced text editor as the code to provide the power of the de facto UNIX editor v. I. Actually, it's a pretty hard core editor, and it's basically used by hard code programmers who are very efficient with command line in Lenox. And just for the sake of post completion, I'm mentioning this editor. Let's try it out. Actually, I already have installed them in my system. So what I'm gonna do is I'm gonna just start this so here it is. What we heard about this editor is at no point are you gonna actually interact using your mouse because it's actually command line. Whatever interaction we're gonna have over here is basically done using command line. So let's just say I want to write a simple text file. Now, if I want to enter some text, I would have to First of all, hit I. Now I'm in insert. Now I can insert anything. Let's say this is a sample text. However, I'm writing a simple text over here, but actually you will be typing in a lot of python coats. So now how do we save it? Obviously there is no mouse. So what we do is we press escape and since, as you can see from the bottom left, the insert key word is gone. So now we are in command mode. What we're going to do is use w and name the file as sample dot txt and hit enter. So as you can see the message, the sample dot txt has been entered. Now, if you want to quit this editor, we again have to make sure that we're in the command mode you might want to just press it a couple of times just to make sure that you're in command mode. So now if you want to type queue for quick and here we are, let's see if there's any file called sample dot txt created or not. As a matter of fact, there is a file called sample dot txt, which has been created. We cannot open this file using them again, and we can again press I, which opens the insert mode of this editor. Now we can edit some more text now, since the name has already been defined, we just have to go over here and type W W actually does the saving part. Now what we want to do is we want to immediately quit as well. So what we're gonna do is just append the Q along with it and hit Enter. Now, if we try to see the text of this file, we can actually see that are extra text has been added over here, but this is pretty tedious. Nobody actually wants to go for a long subroutine programming in vim editor. Actually, most of them do, but they're basically C programmers developing core module for Lennox or doing some other daunting task. Most of the time, if you ever see them on anybody screen, he might not be that much of a geek. He might be just trying to schedule away because it's pretty daunting for the beginner. So now let's see another text editor, the Adam editor. The Adam editor is a pretty convenient editor. It's hackable hackable in the sense you can modify it, not in the sense that you can hack through it right. So, yeah, exactly. There is no one going to give the editor, which has been specifically modified toe hack into someone system. So hackable here means that you can modify it to the extent that you want, and it's pretty neat. And that's what I'm using over here, and I prefer it. My preference could have been sublime text, which is also pretty nice and fast as well, but it has to be bought. If you're okay with it, then you can go ahead and download the sublime text three and try it out. However, I won't suggest or support in any way to download software and apply it crack on it or use cracked versions because you know that always creates problems, so let's see what we can have now. This pie charm is pretty popular, and we cannot leave this area without discussing it, because most the programmers use pi charm in their projects. I would suggest if you have a fairly good knowledge of python, you can even try pie charm. I d E E. It does have lots of features, like source code management integration. It has a debugging feature. It has a profiling feature and lots of other features as well. We can try out the difference in a moment, and you can in a moment, in the sense to python environments. We will discuss about it later on, but there's a feature in this pie charm through which you can switch amongst the python environments. However, this is not very common with other I d E. There is intel, a sense and lots of things. There could be yet another option, which is not very popular, but still most people go with it. It's installing on eclipse I D e and then installing pied of over it, which gives a pretty neat edge, and you can try that as well, but if you're not a very big fan of heavy, I de ese, you can either go for Adam them or maybe sublime text, just in case you're ready to pay for it. Believe me, it's worth it Anyway. Let's try out Adam. Let's close everything. And as you can see that when there is no code in the front panel, it actually sort of gives you a suggestion for opening different kinds of things. Now let's create our first site. Or maybe First Python code over here new file. And if we save it, let's save it as first dot p y. However, it's not our first code we have written in Python Hello World, so you can see the syntax. Writing is over there, so let's try to do a couple of more things. I just hit control with comma and it opens the settings window. You can actually check out the packages over here. There are lots of packages installed ones. They're actually 75 community packages. There are none so far. Let's try adding some packages. Many map is a pretty nice package, so to install the package, you have to go to the install option and search up for many map. So it's searching for it, and you can see this mini map. It actually sort of gives you a preview of the full source code on the right portion of the here, so there's some errors. Could be some systems specific errors, but usually most workout. Let's try another package. Many map, find and replace, so it's downloading over here. Meanwhile, let's move to other features as well. Through settings, we can do a lot of things. For example, we can set the fought over here. We can make it smaller or bigger. We can actually set the scroll sensitivity over here. Preferred. Nine. Whenever you're running code after how many characters the new line starts, you can set that over here and lots of other things you might want. Explore that by yourself. But as per my suggestion, if you're not going for sublime text, you must go for this Adam editor. Surely so moving on to our next agenda. Trying out vim. We learned a couple of commands, and if you want to try it out, MAWR, you confined lots of blog's out there, follow them and lots of other features air there, which are pretty nice and can speed up your processing entirely. But it's not a very good choice in the case of doing group projects and other things, you know. But if you're doing a solo sort of thing, you can actually go for it unless you're not scared with command line editing in all and commands trying out Adam, actually, like we just did. So if you want explore it further, you can go ahead. So this is all about editor selection? We tried out them. We tried out Adam Editor, and in our next tutorial, we're actually going to write our first Python code and run it under different environments . 7. 0205 Writing your first python code and running it under different environments: Hello, everyone. Welcome to this tutorial on Python basics, and today we're going to discuss in this tutorial about writing your first Python code. So far, we've been discussing about how to install the python and how to install the Pip package manager. Along the way, we used a lot of python codes as well, but we never did some serious programming. So that is exactly what we're going to do in this task. Let's concentrate on the agendas in this particular tutorial. Our first agenda is to use an i. D. E E to write and edit code that will be doing frequently and running your python code as a standalone script. What, in most cases people dio is. They frequently used the interpreter for trivial tasks, and that works out fine for me. Even I frequently use interpreter, but there are lots of scenarios where you actually have to write the code and store it as a script or compile it or whatever and then use it further to execute it somewhere else, or maybe compiled native binaries out of it and then install it as a software on the system . There could be various scenarios, but for the time being, let's concentrate on writing our first code. I would like to mention a point over here, since I'm pretty comfortable with command line editor. It would be faster if I use it. So on here. I'm going to use Vim only if you're interested. As we have discussed a little bit about Adam Editor in our previous tutorial, you could go for it. It's the same as them, but because in the case of Adam Editor, you actually have to switch between Command Prompt and the editor, which some of you might find tedious. So it's directly your choice. You can go for Adam editor as well, but over here I'm using Vim editor only. Let's hit the Vim editor and let's call it our first program. So let's just right p y first dot p y. That's how I named it. And now we hit Enter. So the Vim editor took the name of the Python file as the parameter and repeated the file first. Now, most of you guys might not have a very detailed idea of Python programming, but actually you do not need to have that deepen understanding of Python programming because it's a pretty simple language. You can actually get started with lots of basic terms and handy methods. So what I'm going to do to switch code is I'm going to write a Hello World program over here, which is customary in many different languages as well, to write and start with. So let's just type print, which does make sense because we're gonna actually print some value on the console and we'll just write Hello world. Okay, now that's it. This was our just one liner Hello World Python code, and that is the specialty about python. The code is pretty much readable, and it's much shorter, and you can do things pretty easily, which actually take hours to dio in languages like Java and C. So I'm going to switch to the command mode just for the sake of every audience. I might code my commands initially, but later on as I'll be using vim frequently, I won't be telling much about the specific commands, but I will be assuming that you already know about them. Anyways, I switched to the command mode and hit the W to command with Colon, which actually saves the file and quits the editor. Fine. Let's see if there's something called first dot p y in this directory or not. Actually there is there a couple of files. The 1st 1 is first loop dot P. Y, which will face later on the 2nd 1 is first dot p. Y Okay, so before we run this file, let's do a quick python interpreter. So the code we entered in the editor file let's run it over here. And it produces Theo expected output. Now, if we need to do the same with just the file that has been created over here, So what we're gonna do since the python environment has been set, we can access the Python interpreter from anywhere. And what we're gonna do is we're gonna call the Python interpreter and just past the name of the file. So, as you can see, the output is pending from the consul. Now it's pretty fair and very simple and straightforward programming that we just wrote. Let's try adding some more commands over here. How about we accept some new input from the user and then do that for the sake of newbies? I'm just writing it over here in the later course, I'm not gonna actually right over here so that you have to be prepared for all the commands . I'll assume later on that you'll be able to catch up if I show you the entire code and not type it line by line. So let me introduce you to the raw input method. The raw input method is the same as print, but what it does is it actually accept some input from the user. So it makes sense that a computer accepts the user's input and shows us the output. So however we display the output, but we should also know where to put the input. So I frequently used this raw input command. I displayed some value which goes inside the parenthesis as inter string. OK, now, once we enter this particular strain for the people who don't know strings are actually are a group of characters combined together a equals and we stored the string into a variable called a. Now we will print this A as well. After printing the hello World now again the same command for saving and quitting the file . Now let's try to run this program as well again the same python first dot p y and we hit Enter. As you can see, it's asking me for some input. So let's enter some. So it first printed the hello world an iota learning. So now you know how to create a python code and save it in some individual file and then run it from the python interpreter. But it could be that in some cases you want to run the code. But after that you want to resume back to the interpreter. That is also pretty easy. You just have to take python and then type into the command line I and then use the file name and then it asks me again for the input. Now, after executing the code, were now again into the interpreter. And a very special feature of this interpreter is that since we ran it with the file name, it actually contained all the variable stored as it ISS as they were in the program file. So if we created the a variable so as per my assumption, it should be there, let's try to find it. We just type a and hit enter. Okay, there is a variable. We actually type Yoda learning which got saved into this variable called a. And here we go. We have a full interpreter running, which took out the values of all there were in first dot P y. Most of you might be wondering what is a variable, and most of you might also be wondering what is a method or a function You might not be able to follow me properly. But in our next tutorial, we're actually going to begin with the basics and discuss basic unit things and atomic things like, What is a variable? What is an integer? So wait for the next tutorial, Best of luck and thank you. 8. 0301 Dealing with variables and string: Hello, everyone. Welcome to this tutorial on python basics, and this particular tutorial will actually discuss a little bit about variables and strings . So the basic agenda of this particular tutorial, our understanding of variable storing different sorts of values in a variable understanding string, trivial operations on string. And how does python handle memory allocations to variables? So what we're exactly going to do over here is we're going to start the interpreter and do most of our operations over here only. So, first of all, let me define what is a variable. We often have to do lots of calculations in python using programming logic and calculations . But often we have lots of inputs from the user or outputs, which you have to show to the user. So for those purposes, if we have to store those inputs and outputs, we need to have a very basic unit, which is actually called a variable. Ah, variable is prevailing in mostly each and every programming language which are out there, be it C sharp Java sea or whatever. So python also has it, And how can we define a variable? We actually have to give it a name. Let's say we give the name A and we input the value as 23. So here's the value 23 stored in a variable called a. So once I enter it again, it actually brings the value whatever it had. Now I can use the print command to print this value. So once I print this A, it actually prints the value 23 weaken store. Different sorts of values in a variable. Let's call it a variable called verre, a very one and story value called 45.674 This is a float value, basically, so this is the value. Now, each and every variable is actually stored in the memory address and that memory address. If you want to print it at any point, we can use the I D function and provide it with a variable name and print it. So this is actually the memory address where this particular variable is stored in the computer memory. We need not go into the all the details of the memory addresses and all. Just for the time being, you should know that if you ever want to print the memory address of any variable in python . You can use this. I d function. So by default, actual memory addresses are in Hexi Decimal. And you can even use the hex function and provided the memory address. And then it will print the Hexi Decimal equivalent off the memory address. Okay, this is it. So this was a very little explanation of what memory addresses are. We're going to deal with them later on in detail. So now let's move on to yet another variable called y two and provided a special value String one. So this is basically a string. What a string is is. Actually, we can consider a string as a collection of individual characters and obviously in programming languages, we have to operate on strings. And quite often we have huge frameworks to build just upon to calculate the strings and the collection of strengths. So a string is a very important feature off any programming language. And as it is with python, once you have a string, there are lots of operations we can do in this particular string. So let's see what we can do Over here. There are lots of functions. For example, see, there is a function called lower. There's a complementary function called upper offer that function as well, so if we print our value of why to it's actually string one. But if we go ahead and try Method upper, it will print the values in the upper case. Now let's see if we want to split the string from I. So let's see what happens will enter. I we hit enter. So as you can see that this string was String one and once we applied the method called Split and provided the value, I it also search for the I, and from that point it split the string into two parts, so this is pretty interesting. Now let's take yet another variable and stores a sentence in it. Now, as you can see, I entered a lot of white spaces in this particular string and that was on purpose. We can use it another method or function regarding strings, and that is called a strip. So once we use this method, as you can see, the white spaces are actually gone from the start and from the end, this is to clearly mentioned that this function doesn't remove the white spaces in between the characters. If we manually print this without applying the script function, it actually prints the white spaces as well. So now what I would like you to do is to go ahead and store different sorts of variables and take strings of different sorts and store them and apply these functions on it, so that will give you a better understanding of variables. Now let's move on to How does the memory allocations off variables happen in python Each and every computer system has a ram. So what Ram does is it actually stores the running off programs in a system. Now this system has this ram memory, and whenever you store any sort of variable, let's say they're equals four equals and this goes right into the ram and occupy Space is over there. So if you want to actually see, you can open up another command prompt, execute the task list command, and over here you can see I Python, which is actually occupying two megabytes of space right now. So this was a very basic level of definition or explanation of how this memory allocation takes place. So be aware that whatever value you are storing it actually goes to the ramp. So whenever in the future, if you be writing complex programs in python, you have to be very careful about your variables. Because if they occupy a lot of space, the program is going to be inefficient and slow down the system. So more on that later. If you have any queries regarding that, you might want to post it on a discussion forum in our next tutorial. Were actually going to talk about numbers and different operators, which we can apply on those numbers. So I think it was pretty easy and understand, and you'll be pretty excited for a next tutorial is Well, see you in the next tutorial. Thank you. Have a nice day. 9. 0302 Numbers and different operators in python: Hello, everyone. Welcome to this tutorial on python basics, and this entire tutorial is all about today's numbers and different operators in Python. So we are actually going to talk about numbers and different operators, and we're going to deal with operations and operations and lots of stuff is going to be there, which is going to be pretty interesting. So let's dive into the agenda of this tutorial understanding basic data types in Python. In my previous tutorials, I had briefly counted most of the data types, which will frequently use in python. But certainly not all of them understanding interred your data types in Python. I will explain about integer data types and also float numbers different operators that can be used in python over integers. We will walk through different sorts of operators. And how do they walk through and behave in certain types of situations with certain types of operates playing with random operations, using different operators? Okay, so having said that, since the bottom line is what sort of agendas we're gonna work upon, let's revisit all those basic data types, which we need to know for the time being. So I just switched to my command prompt and started the python interpreter. Let's take a value and store it a equals 56. This is an integer data type. Now another data type is 56.7, which is actually a float value. So we have an integer and afloat and see We're gonna have a string which we have already talked about. Indy, we're gonna have a complex number and in the variable e, we're gonna have a long number. Long numbers usually end with a capital l That is the basic restriction between a normal integer and a long integer. You can even take a small integer let's say 12 and designated as a long and bitter But when we check its type, it's still long. However, if we checked the type of a normal integer which has not been upended and has a long integer, is, um let's check out, um, the B, which is afloat as we mentioned Type C is a string and type D is a complex number. So these are the basic data types which we will deal with right now, and there are actually lots of data types and built in types in python that makes it a very great language, but for the time being, we're just going to deal with these five types. 10. 0302b Numbers and different operators in python: I bet we have already studied a lot about string in our earlier tutorial, so we're going to skip that. And also this tutorial is specifically about integers, So let's dive into that. Let's check what sort of methods are available for an integer. We have already gone through the imaginary or real number, which brings out the real and imaginary value part off a particular integer or complex number. Actually, in a scenario in a mathematical way, if we define each and every number, that's actually a really number and the real number falls under complex numbers. And therefore, even if we define a very simple integer, it is actually having an imaginary or real part. And that is why we have thes two methods. Now let's dive into some more advanced methods by eggs or method, which basically takes an operate, and it does the eggs or operation between the current variable. So as you can see, I have eggs or a with A, which actually returns me a zero, which is actually true. Whenever we try to eggs or value by itself, it returns zero. Let's try to eggs or this using zero, then returns as 56 which was actually the value of a said eggs or function is working pretty fine. Now let's look at some other factors. The size the variable value stored is 56 the size is actually the bite size of the integer , which is actually 12. Now, if we see the same thing about the large number called F, it gives me 14. Still, it's a long number at 14 bites. Now let's check with E. It is 18 and since we can see that it's a pretty long number, no one deletes a bigger number than the both of them. Now, if you're from some other programming background language, you might be wondering why isn't the bite size of this integer 32? Actually, this is a good thing with python. If we try to allocate an integer, it actually tries to minimize it and dynamically allocate its size rather than taking a static size and applying it to its data tight for other languages. What their interpreters do and they're compiler, does is they take the integer and no matter whatever value is there the integer, they just assign it a 32 bit because it has been declared is an integer. So there is a con of using python. Now let's try some more methods. Let's try to convert this a into its corresponding hex value. So it gave me 038 which if we try to calculate the Hexi Decimal or 56 it will give us 38 as well. We can actually calculate its Octa decimal as well. That's 07 Still, and apart from that, there are lots of other methods which you can go and try. And I will just mention a couple of methods to Let's try to check out the conjugal of this particular number. Now what is a conjugal if you don't understand? If I apply to an integer, let's try applying it on a real number. So real numbers. Actual value was four plus three J, and it gave me a four minus three j. So that is actually the mathematical congregate of the complex number. But since the A didn't have an imaginary part, so it's Kontic, it number was the same as it waas. Now let's dive into another agenda, which was different operators that can be used in python over integers. I think we pretty much covered mostly all integers operators in a very short way while using the python shell as a scratch pad and a calculate. So let's quickly review the plus operator addition. Operator adds to values A plus B gives us 112.7, now B minus A is an entirely different thing. C minus B stands for an unsupported operate because we have applied a string value, and it tried to subtract it with an integer which is actually logically and sin tactically , both incorrect. So it gave me an error. Now let's try to do the same with B minus A. So as we can see that what it actually did is it took the rial part of the integer A, and it subtracted it from its layer part. Since it doesn't have the variable, it didn't have an imaginary part. Therefore, no subtraction was done on that account. Now let's try to multiply those values again. In the case of multiplication, it's sort of a cross multiplication. So what it is is it got multiplied with a constant off both the real and imaginary part in this case, and therefore the value to 24 plus 1 68 And here we have used the asterisk operator, which is basically for multiplication. Now let's go to division. This is yet another operator, and as it's mentioned and clearly visible over here, it divides the value. Let's try the float division operator, which divides the value, but it rounds off the entire decimal points. Having said that, let's also try the modular operator. Let's take the value as I equals 34 and J equals 70. So when I do this, it returns the remainder, which remains after the division of these two values. Now what we're gonna do is we're going to take yet another operate. Let's say I equal 63 and we try to do the same thing. Then we have a remainder as 12 just to keep it in mind, whatever we apply or whatever sort of operate we taken modular operator. This 12 is never going to exceed the J through which we are dividing, which is obvious. So this property is used programmatically quite a lot in different sorts of algorithms. Having said that, now we will talk about playing with random offerings using different operators. Since we have covered that much in this one. Lets try to take yet another leap and try to multiply random values and operates along with each other in our next agenda. We're trying to try random values with different operates, and these ah Prince will have some specific cases, which could be a little confusing to general programmers of basic levels. So let's say if we divide 12 by three, it gives us a fair amount of output as four. Now let's try to divide it with 13 and it again gives us for because it ignores the fractional part. So the main question is, what do we do to secure that fractional part? Let's take both of them into variables 13 and J equals three. I equals J is again four. Now what we're going to do is we're going to type convert this value in tow afloat. This is new to you, all of you. Maybe because what we're trying to do here is we're taking afloat and we're passing the integer value, which what exactly it does is it converts this type of integer, therefore type conversion and get it converted into afloat. Now we take another variable and we also type converted and then we see the output. So as you can see, since both of them were floats, the output was preserved. Let's try to keep only one of them as a float. Even then, this thing works out again the same so as per the conclusion. Either one of them should be afloat. Therefore, the result of the operation will be a float value. Now there could be cases that we have float operates, but we don't want the long fractional part of the result output. Rather, we want just a decimal place to round it off. So what we're going to do is actually take some float values and try to divide them. As you can see, the result has a very long, fractional part. What we can do is we can use the float division operator, which I had just discussed. That gives me 1.0 as the output. Now that is pretty basic. So far we had just two operations and at most one operator. Let's try to combine a couple of operators and operations and see the output. So in this output, what we have seen is rather than five plus four equals nine times three times 27. What it does is it multiplies four by three and then adds it with five, which is mathematically correct. Now what we can do is in a few cases what we want is we first want four and five to add first and then get multiplied with three. So what we can do is we can apply the parenthesis and therefore giving this plus operator precedence over the multiplication operator. Now this is 27. We can do that with division as well, since the division of three and two returned one and it got subtracted by six. Therefore, we got the result five Same here we can put parenthesis and we will get the result one. Now we can extend this operation and we could even do something like this or weaken, surround it with a parenthesis and give it a precedence. So what happened in earlier cases? First of all, six minus three got calculated giving the result three. The division between three and two occurred because division mathematically has a precedence over a multiplication operator. Now, once we got the result one, it got multiplied by three and gave us the result as three, but in the next one, What we've done here is we override ID the precedence of the operator using parenthesis and six minus three equals three and two by three equals six. Therefore, three divided by six could have been a value less than zero and some fractional parts. But since it is an integer type data, therefore the fractional part were ignored and we have only zero as data. So I think we have covered enough cases for integer and operations and different sorts of combinations. What I would suggest you do is go to the python dot org's website and check out their documentations. They have a pretty clean documentation. Apart from that, I would like you to go to other websites as well and check out the specific cases which may occur in case of these sort of operations. Remember, programming cannot be achieved or learned in just one day. Therefore it requires a lot of practice. So I think it was fun. And in our next tutorial, we're going to present introduction with built in types in python. Well, this is gonna be a lot of fun because built in python data types and other types are so interesting. That is why the pythons having a better grip on programming and development rather than other languages. So having said that, thank you all. 11. 0303 Introduction with important built in types in python: Hello, everyone. Welcome to this tutorial on Python basics today we're going to deal with on introduction with important built in types in Python. We're going to go into detail with built in types, and they are frequently used in different programming algorithms. So the basic agenda is going to be pretty straight and simple. We're going to talk about couples list and dictionaries, and we will treat the string as a list and discover how the string, which we have just been thinking about as a group of characters, can be treated and internally, actually is sort of a list. So, starting with couples, let me switch to my command prompt. Now let's hit the python interpreter again and try to understand what a couple is before we actually create one. A temple is actually a sequence type data structure, and it is actually on immutable sequence data type structure. So what data structure does in python is we usually have a lot of data because that is not normally the case that you will be having one or two values. You'll actually be having a sequence of values. So to deal with such sort of data structures, we have sequence data structure types and a topple is one of them. And the basic distinction about a couple is that it is a new immutable sequence. So having said that, let's create a sequence called Couple Topple. One is what I will call it, and it actually starts with a parenthesis, and we can assign multiple values of different data types. Here you can see that I have created a couple with two values as a string and two values as an integer. It doesn't matter what sorts of values air input, it could all be integers. It could all be strings. It could all be complex numbers, or it could be all float numbers. So let's do that now, as you can see that I have just created a topple. Now, the biggest question is how to access this topple or access it as a specific element off this topple. What a couple does is once it creates the number element, each and specific element can be indexed by a specific number called its index. Let's say couple one has a length of four. That means there will be four index's 012 and three. So if you're planning to access the value at a second index. What we're gonna do is this and hear this true? Same. We can do that with two and three now, as you guys might remember that I said it is a nim you doble sequence. Therefore, if we try to change the value off this particular element at this index, Bennett throws that the tubal object does not support item assignment and that is because it is an immutable sequence. Now will create a couple too. And ah, we'll give it some numbers. Okay? Now, since we have yet another tubal, we can contaminate both of them and it will not be a problem at all. So as you can see there, what this operation did is it can caffeinated the next couple into the end of the first couple. But let's consider it on. A few of them, first of all, try to access the range of indexes. Sorry. The variable name error Okay? Topple wanted to is Onley too. So I've actually given to indexes over here. The 1st 1 the 2nd 1 The 1st 1 means including this integer and excluding this integer index , if we might have done something like that, then it gives the two integers. Let's try to go a little fourth and give us all of the values. Here we go. So in this way we can do the slicing of this topple. Now let's do something which we haven't done yet. Let's try to access an index which hasn't been actually created or doesn't exist in the tubal. So it gives me the error of the tubal index out of rain. Now, do one other thing. We're going to do the slicing of the Topple out of its index, and actually, it gives me an empty tubal. That is because there is no such trouble with these indexes. However, it is noticeable there is not any sort of error thrown. And this is a very important point, and it has to be kept in mind as well. Now that we're going to do this, we're going to apply Ah, little method over it and operators over it. For example, topple one is multiplied by four. So what it actually does is it actually appends three more same couples and the end of the 1st 1 in sort of a way it multiplies the tubal four times. We can actually check if some specific value does exist in the topple or not, Let's say one in topple one. It returns true because one does exist in it. Let's try to access the value which does not exist. Then it will return us as false. We can actually traverse. The value of this temple is well, by using the syntax like that, we actually ran a loop and printed all the elements off this particular couple. Few functions we have discussed about couple. 12. 0303b Introduction with important built in types in python: Now let's jump up to the list. Lists are actually pretty much the same, but the basic distinction is. Lists are also sequenced type but mutable. Unlike couples, they can be mutated at their element level. Let's create an element called list one. Let's assign it some values. Here we go. We assigned three values over here. If you check the length, it should be three right now. Unlike couple, we can actually change the value. And if we print the list one, we can see that the value has actually been altered. That is the basic difference to an A list and a couple and distinctly how they're categorized from each other. Now we're going to try concatenation on list to for that purpose. We will create yet another list now, As you can see, the concatenation operator works out here pretty well, and so does the multiplication. Now we will try to access the element ranges using slices operation in list. So what we're going to do is 1 to 2. It gives us five let's try it with zero index, so it gives us from zero till two, excluding the to and including the zero the same way that works out in a couple same way. It works out here as well. And it also throws the error out of index. And in the same way, if we provide a slicing and we try to cross the topple range, then it doesn't throw any sort of error. But it returns an empty list, so I guess both are pretty much the same now there is one important thing which I would like to mention List can be accessed with negative indexes as well. So it actually starts with negative one on the negative side. So what we do is from the right side, we start counting from negative one, and we keep decreasing further negative to negative three negative four. So if you're actually accessing negative one, we're accessing the last element of the list, and we can access it until negative too. My apologies. Actually, the minimum number should be on the left, and the maximum number should be on the right so we can do a little more less number. Okay, So you have seen that if you don't specify the last operate over here, it stretches back to the full length and displaced all the elements after negative three. So this was a pretty basic slicing operation in python using list 13. 0303c Introduction with important built in types in python: Let's now deal with dictionaries. A dictionary is actually a Keep Airbase data structure, key value pair based data structure which stores a key value pair, and it creates something like this. We, first of all, take a key and using colon, we assign it some value. Then we give it a comma and then again create yet another key pair value and so on. As its name suggests, it attach is a value toe a key. It is the same like a word with a specific meaning. Here. We need to know one thing that the keys has to be specific and unique. However, the values can be redundant in case of dictionary. So if you want to see all the keys over here, we can do that using the keys method off the dictionary. And if you want to see all the values over here, then we can use the dicked dot values method. Now let's try to change some values. Since the dictionary is mutable, therefore will try to change the value of the key one and name it as you know. Now, if you have done the dictionary again here, the value has been altered pretty significantly. Now What we are going to do exactly is we're going to dump out both the key and values using the items method off dictionary. So here we go. It returns me a list of topples. This is about dictionary and there are lots of other methods regarding dictionary as well, which you might find out in documentations online on the python dot org's website. This is a very basic level interaction, so if I try to exceed with the basic level exposure, it might start skipping. So what we're going to do is I will leave the rest up to you and proceed with the string treatment as a list which is actually the last agenda off this tutorial. Treating a string as a list so we just create str one that is a string and call it yodel learning. Now it seems to us like a simple string, but actually it's well. Individual characters can be accessed by the particular index since it actually has a length. Therefore, the first element starts with zero, and the last element is length negative one that is 12 in this case. My apologies. So we access both the first and last element off this string by treating it like a list. Now let's see if the strings sliced thing works out here as well or not. We start from zero and try to exact till four only, and we got the Yoda, which is the actual group of characters between 0 to 4 index. Therefore, the slicing works out as well here. So once I try to access the negative one index, that is actually the last element of this particular strength that it gives me G. Let's try to reduce it further and keep it moving to the left part of the string. Let's do something like that, and we have the part of this particular string using negative index slicing so as we can see that a string is pretty similar to a list as well. And lots of operations, which are common with strain, are actually common with lists as well. So having said that, what I would like you guys to do is go to the online documentations and find different exercises and try to solve them. I think we've explored more than enough about the python data built in types. So in our next tutorial What we're exactly going to do is we're going to study about logical and looping constructs, and then we're going to meet them in detail and do some programming exercises. So til then, keep coding and thanks for listening. 14. 0401 Understanding logical operators and expressions: Hello, everyone. Welcome to this tutorial on Python basics. Today we're going to deal with logical and looping constructs. So what, exactly what we're going to do in this tutorial is we're going to understand the logical operators and logical expressions. And how do they evaluate to some true or false value? Our basic agenda is going to be different types of logical operators, making logical expressions to compare to values and combining two or more logical expressions. So, first of all, I would like to list how many types of logical operators there are, which we can use for different sorts of operations. So I'll go to my command, prompt and let's see, I just created a couple for the same. Now let me walk you one by one with each operator. First operator is greater than before. I go ahead with the logical operators. Let me clearly define what a logical operator exactly does. A logical operator is the same. Like a mathematical operator, however, it establishes a logical relation between the operations it has given. So, for example, if you are given to ah prints over here like 45 67 then it establishes a greater then relationship between them. That means if 45 is greater than 67 however, this statement is not true. Therefore it will result to a false value. There is also the logical operator called less than which here is depicted as well. 67 is less than 89. Therefore, the value of this logical operation is true, greater than or equal to less than or equal to, not equal to is equal to Okay, so these are the six types of logical operators you will frequently use across the programs you will ever create in python. Moreover, there will be some relationships as well. The 1st 1 widely used is the armed relation. The 2nd 1 is or relation and the 3rd 1 is not relation. So what we're exactly trying to do over here is we will take the logic operators and these expressions and try to make complex expressions to result into some true or false. Why do we need these logical operators? And these expressions is the main question as well. In our programming, we often have to make decisions in our daily life as well. We have to have many decisions. For example, we have to turn left or right. We have to catch this train or that trade. We have to do this work or first of all that work. So there are lots of decisions which we need to make in real life is well, even in the program. This is the same scenario. In many cases, you have to evaluate the input and make a specific decision. For example, if we got a price, is it going to result into some profit or loss? So I just introduced you with the logical operators. Now let's jump up and try to compare two values in different fashion and let's see what happens. So what I'm going to do is I'm going to start the Python interpreter. Let's take a very simple expression. 34 is greater than 57. It results to false, which is obvious. Let's try to do the inverse and it results to true. Now we can see that in the first case we applied a greater than logical operator and 22 operas, 34 57 34 was less than 57. Therefore, the result was false. In the second scenario, we had the less than operator. And since the condition evaluated a true therefore it returned a true because 40 three's obviously less than 57. Let's try to come up with something else greater than or equal to this, obviously results to false. Now let's try to do it this way. What will happen if I try to compare 44 with 44? With the greater than operator, it returns false because obviously, 44 is not greater than 44. It is neither less than it is actually equal to. So if I just apply the greater than equal to operator over here, it gives us true. Same goes with the less than or equal to operator. It also returns true, but if I try like this, that is also a false Okay, now let's proceed. Toothy is equal to operator. That's fairly reasonable, because 44 is equal to 44. Therefore, the is equal to operator worked out well. Now let's try out the not equal to operator, since both 44 44 both left and right operas are equal. Therefore, it returned with a value false when applied, the not equal to operator. Now let's see if we can try something else, since 1 21 is not equal to 32. Therefore, this expression resulted in tow a true value. Now let's try to do something else. Let's take a string. These operations, I mean these operators also works on string operates as well. Since Yoda learning was not equal to Yoda. Therefore, we got a false value over here. Let's try to change the operator over here. Now this expression seems to be true. Therefore we got the value True in the same case, if it is this expression, it also returns to true. But that was about is equal to and not equal to, operator. Can it compare regular strings as well Using other operators? Let's try to see. So it returned me a false value. What? I tried to compare a with B. Now if I inverse this sign, it returns. True. Since a comes before B, therefore be is considered greater than a in this scenario based on their values. So obviously we can compare two strings as well. Now let's do something like this. This value turns out to be true. But how so? The comparison was made per character, the A was compared, first of all, which was equal, so there were no changes made. Now be was also equal. But see was less than D since C comes before D. Therefore, the ABC is actually less than a B D, and this comparison is made on the basis of the placement off the characters in the alphabet. Siri's. I think this is enough with logical operations, and we pretty much understand how this works out. Now let's add some relationships and make some more complicated expressions. For example, let's try the end up now you can see that there I have put a keyword called and between two logical expressions. The first expression Yoda equals your learning is false. However, the second expression 1 23 greater than 34 is true. But in case off, and if we have two expressions, both need to be true. Otherwise, the result. It will not be true. So let's see, let's take the same expression and make both expressions true. In this case, it is true. Now let's check out the or operation. Now what actually happens in the case of or expression is either of the expression has to be true. So in this case, both expressions are true. But let's try to make one of the expressions true. I mean, let's make one of the instruction false. Even then it returns. True, however, one of the expression is false. So what are actually does is it takes two expressions, and if either of them is true or both, are true, Onley then or results a true value. Otherwise it will result a false value. Now let's do something else. Let's try the not operator, not operator, actually takes on Lee off logical expressions and gives it a true false value by inverting the result off that logical expression. For example, let's take 45.67 less than 67. It's fairly true, as it seems apparently, but let's apply the not operator now. It is false because the result in value was true. However, the not operator entirely inverted it. Okay, let's try to use this not operator along with this and operator. So I do something like that. So as you can see over here, Yoda is not equal to Yoda learning. So this statement is actually false, but they not operator, along with it makes it true. Therefore, the first expression turns out to be true. The second expression is anyway true is apparent. So both expressions are true therefore, and operator resulted into a true result. So this was all about week unfairly catch up for the logical operators and logical expressions. I think it should be enough that we have tried to combine two logical expressions. And for the sake of simplicity, we're not going to deal with complex logical expressions for the time being. We will meet them and encounter them later in other units. Now, in our next tutorial, we're going to take thes logical expressions and make decisions using, if else causes, because the sole purpose of understanding these expressions is to make decisions. I hope you learned a lot from this tutorial, and what you have got to do is go to the website and different documentation Web based websites, which contains the documentation of python or examples, and try to find different logical expressions and try them out on your own. This will help you enhance your skill on this, and obviously we're going to cover lots mawr in the next tutorial. Thank you 15. 0402 Making decisions through if else clauses: Hello, everyone. Welcome to this tutorial on Python basics. Today we're going to deal with logical and looping constructs and making decisions through , if else clauses. In our previous tutorial, we discussed about what logical operators are. How can we make logical expressions, which results to a true or false value? In this tutorial, we're going to have some basic agendas as well. Our first basic agenda is understanding the structure of, if else clauses. Then we're going to make decisions based on those, if else clauses nesting, if else clauses and else if ladder. So these are basic agendas for this tutorial. That is what we exactly are going to encounter frequently in case if you are trying to create some, if else condition in Python. So let's hit the command prompt. I already created a tutorial. Let's try to see over here So this is a sin tax. This is a very basic syntax oven NFL's place in our first case. What we have tried to do is we have tried to create an if case example we have compared to values and based on the logical operation and the resulting value, we try to execute an arbitrary code, and in this case, we're trying to print we just compared to values. Now, if you see 23 is certainly less than 45. So if this condition evaluates, either it's true or false. And if it's true, then it executes the code, which is followed by the colon operator and indentation. So this is the basic syntax. Be careful about the indentation and also this colon operator, because people usually make mistakes of forgetting them. And in our next example, there is this that we have used this else clause as well. So in the first if clause we have a condition, then we have this colon, and after that we have written the code, which we want to execute. So in this case, I'm trying to compare two strings. And if the strings air equal that, I'm executing the first code. But if conditions are not equal than this code falls to the else clause and then executes the else block code, so the syntax is pretty simple. We're going to have, if else clauses, you're going to have a logical expression, and we're going to have a code block specific to each if or else clause. So as you can see that in our first example, I didn't mention the else clause. So just keep in mind that there could be if Klaus without an else clause, which is logically possible, you know? But there cannot be an else clause without an if clause. So let's try to execute this code as you can see, the output it just printed me with just compared to values. If you remember, when going into the code, we actually had this condition which evaluates to true therefore prints out we just compared to values, which was the code block of the If Clause. Now, in the second case, we have both if an else clause is. But since the condition is not true, therefore the flow of the program falls to the else clause, and it executes the code block of the else clause. And therefore that is why it printed both strings are not equal, as you can see over here. So this was about a very basic syntax of If clause, let's take one more complex example. Let's take the same code and modify it a little. For example, let's try to put yet another. If else condition inside the else block and see if it can be done or not. So what I'm going to do over here is if I have created yet another condition inside the else and what it does is it compares. Moon equals eclipse, since both strings air not equal. Therefore, as per our assumption, the code block should fall to the else clause, and it will print false. Let's try to run this code and, as you can see, that it printed false. That was because our code went into the Els block and it again encountered on if else condition case so it evaluated. Moon equals equals eclipse, and that is false. Therefore, again, the code fell into the else block and it printed false. We can do this and we can. Nesta's much as possible, theoretically, but practically. You rarely find a case. Where is that much of nesting? Maybe two or three levels. But beyond that, if you're trying to implement a code which does contain a lot of nesting of if else cases, maybe probably you're doing it wrong. Or maybe you need an else if ladder Now, what is an else if Ladder, Let's have a look at it now. In most cases, we have a binary decision. For example, we can have two cases. We're going on a road and there are two turns left or right. We have to decide Either we go to the left or to the right, so both of the decisions might have their consequences. But that is not the case with real life. There could be a lot of possible decisions. For example, there could be four turns. Or let's take yet another example. There could be subjects which you want to opt for your curriculum. So let's say, if there are three subjects, visits, chemistry and math and you want to opt out any specific one of them now, this is not a binary decision because there are actually three values physics, chemistry and math. So a decision has to be made and an action has to be taken as per that. So what? In this case, we can do one thing we can do a nesting of, if else cases. But the issue with nesting is that the code becomes complex and not readable, so therefore we use else if ladder, Let's take an example here we have a very fair example of an else if ladder. And here we get introduced with the method called raw input. What raw input actually does? Let me describe it a little. It takes a value from the user. It pauses the programme until the user doesn't enter some value. And then it stores the value into the variable applied and the values here you see in the parenthesis. This is a string which this method shows while taking input from the user. Now, if a equals Yoda, then we print Yoda, which is the first case. Then we have another case. If B equals learning, then we print learning, which is a second case. So there are two cases. If it had just been about Yoda and learning that means binary case, we might have simply put an else if case. But we cannot put over here on else if case because we have yet another third condition called a equals python. So we can put multiple conditions like that. Maybe we want to add yet another condition so we can put conditions like that on and on. And in the last case, we can put an else clause. If none of the conditions works out, however, you can omit this else. But in logical cases, you might want to keep it just to fall back from all those conditions. And in the end, you want to execute something. So let's try to execute this code and let's see what happens. So it's asking me for a string. And as you can see over here, enter any string which of the same string, which has provided to the raw input method in the parenthesis. Now let's try to enter Yoda. So let's print Yoda as per expected. Let's try to put something else, maybe sample. Well, there seems to be some error in the code. Let's try to find the bug. Well, very luckily, this is our first bug. Let's see what we have done wrong in the code, Not this one. Here we try to print the sample. Now let's try to execute the code again. Let's enter, sample and print out a sample. The air occurred because I didn't apply the quotation marks around the sample string. Now let's try to do something else. Let's put any other string, maybe random string, and then see Well, this was not extracted. Which, as we can see it, is the same code which is mentioned in the else clause of this else, if ladder. So I just explained the if else clause the nested if else clause and the else if ladder and this is sufficient for the time being, there will be more complex cases in our next tutorial. But for the time, we will move on to our further tutorials. So in our next tutorial, what we're exactly going to do is we're going to take lots of test conditions, and we're going to repeat them again and again, using a cold block. So what you have to do is to take real time life decisions and turn them into if else clauses and see that if it works out for you or if you're stuck somewhere 16. 0403 Repeating or looping the decisions multiple times and stopinng them: Hello, everyone. Welcome to this tutorial on python basics, and in this tutorial, specifically, we're going to study about logical and looping constructs. What it is exactly about is repeating or looping the decision multiple times and stopping them. So let's check that out. We're actually going to learn how a loop works in Python, what range function is and what it actually does, executing a particular code block again and again and understanding how to break through the looping constructs. So before I go ahead, let me explain it a little. What looping construct exactly does is it takes a particular cold block and it repeats it again and again over multiple attrition. So what I'm going to do is I'm going to hit the Python interpreter and run a code. It might not be making very much sense to you, so let's try to break it down. And individual units, the looping construct in python is implementing using the four key word. So what I have done over here is I have taken the four key word and I have taken a counter and I have taken the range method. What it actually does is it creates a range of 10 numbers. So once the 10 number range is created, then for each number, this print loop is created. And therefore, since we have 10 over here, if we count it 0123456 so it should be counted around 10. Now let's try to check out what the range function is and what it actually does. As you can see, the range function takes an input and creates a list of numbers for us. What is a list as we have discussed in a previous unit as well? So I don't think anybody should be having a problem with lists. So over here range took that 10 as a parameter, and from 0 to 9 it created a range, a list of numbers or a sequence of numbers we can take to operations as upper and a lower limit, and it again creates the sequence for us. So as we can see, the first value is included in the sequence, and the second value, which is the larger limit, is excluded from the sequence that has to be kept in mind. Always now, in our previous example, if we print this particular integer rather than the string. Let's see what happens. So as we can see what four keyword does is it runs in a loop Based on this integer value, let's try to increase the value so it prints still 99. There could be a case now for this loop. We have printed around 1000 values, but as you can see, it creates over a particular range on Lee. What if we want to break out at a specific point, right? For example, let's see if you are going through the entire 1000 Siri's. But we want to break out at 901 So what are we going to do and why do we need to break? Let's understand this. In many cases, what can happen is we may have a loop running and it could run in tow. Endless situations, and what can happen is we might want to break the loop before it runs into a particular condition. Let's see this. So what we're trying to do over here is in this example is we are printing 200 numbers, it rating over them, and then if any of the number is 14 then we break the loop. Otherwise, we don't break the loop. Let's try to run it as we can see. The counter started with zero and ran till 13 but when the 14 was encountered, the loop actually broke and the loop couldn't go further. Let's try to modify this code a little bit. Okay, let's keep it as 56 and then run the code. Now. It again ran till 55 stopped at 56 so this was a way to break through the loop. I think it's fairly easy to understand. Let's encounter yet another type of Luke called Wild Loop, which is fairly important as well. So let's take an example of this test condition. This series is yet another kind of loop called Wild Loop. What it does is it actually doesn't take any range like for loops rather than it takes a condition. And until and unless that condition is true, we actually run that loop endlessly. So you have to be very careful because if we cannot operate or evaluate the condition properly, then this loop will keep running endlessly. So let's see, what we're trying to do here is if I equals one, then we compare the I and check if it is less than 45 or not, and we print I over here now, we're also incremental. I that is we're adding I with one each time the loop is running, since the loop is running, and each time we are adding this value toe I at some point it becomes equal to 45 then this condition I is less than 45 becomes false and the loop stops. So if we forgot to add one to this, I every time the loop runs, this loop will run endlessly. Let's try to execute it. So it ran till 44 after 44 it stopped. And why did it stop? Because of based condition. Let's try to modify it a little and do a little horrible task and try to run it endlessly. Let's just omit this condition and see what happens. So as you can see, it will keep printing one again and again and again. And the program will never stop until and unless we give a keyboard, interrupt and interrupt the entire process, which is running through python. So this is a very simple case of while loop, and you have to be very careful with the base case. Otherwise, the entire code is going to run endlessly. So that was all about loop, and we're just trying to keep the things simple. And therefore we didn't introduce many complex cases in later tutorials. We're going to encounter many complex cases based on the's constructs. In our next tutorial, we're going to meet with a very exciting concept of handling the errors and what are exceptions. So for this tutorial, what you might want to try is to go online, as I always suggest, and find as many examples as it can be possible for Loop. And while Lupin Python, the people who are coming from other programming backgrounds, might be wondering that the four and while loop works a little awkwardly or differently than other languages. So just keep learning, and we will see the benefits in our next chapters. Thank you 17. 0404 Handling the errors and exceptions inn our decisions: Hello, everyone. Welcome to this tutorial on Python basics again, and today we're going to deal with handling expressions in our decisions. So what happens is actually when we try to execute a program, in many cases we encounter some special cases and those results to some sort of exception. What are exceptions in Python, or what are exceptions in general? This is what our main agenda is of this tutorial. So let's review all of the agendas of this tutorial. First of all, our first agenda is understanding exceptional cases in Python programs and then handling exceptional cases in Python program. And then we're going to take a look at the try, catch and finally, structure in python programs. Actually, exceptions are very general in any programming language, be it python or any other, and there should always be some sort of construct or way to lead in any programming language. So let's try to check a case where we have an exception. So I run the Python interpreter. So first of all, let's talk about a case where we can deal with on exception. So our first case is let's take a variable 123 and store it. What I have done is I have taken a string 123 and stored it in a variable A. Now, as you can see, that 123 is, however, treated over here as a string. But it is actually a number, but if you check it its type, it will tell that it is a string. However, in a few cases you might want to convert this string to an integer. So how could you do it? I just did the explicit type conversion over here, and we got the value. Let's check. It's tight now and see if the type actually got converted or not. OK, Bravo. This got converted into an integer. Now let's take another string and again store it in a variable anyway, since this is a string, therefore, we cannot convert it into an integer because it's both illogical and error prone in python . But still, let's go ahead and try it. So as we can see when we try to convert a string type into an integer and that string type was not actually meant to be converted into an integer, we got a value error over here, mentioning that invalid literal for end with base 10. So this is what an exception actually looks like. Yet another example of an exception could be let there be a number called 45 we divided it by 23 we got one. This is a very simple division case, but where is the exception? Let's take yet another number 45 try to divide it by zero, which doesn't make any sense mathematically, but still go ahead. And what we found over here is a zero division error. Now, if we can see this is yet another exception that we just handled. We actually didn't handle it. We just encountered it in our code. So what if such sort of code conditions fall in our codes? However, you have a zero in this case, but it could be at some places. The zero isn't a constant. It could be a variable, which is vary ating over some sort of loop attrition or something, and you could have no control over it. But you still want to do something regarding a special case where this value gets equal to zero, then how will you do it? So, first of all, We got an understanding of what is an exception and how it actually looks like. Now let's try to handle it. I actually created an example for the same purpose. So here in this example, what I have implemented is a try. Catch finally block in python. If you're coming from other backgrounds, other programming backgrounds, I mean, then you might be seeing that rather catch. I have used the key word except over here. So in Python, we used the except keyword and finally and try remain as same for those who don't have any idea about try catch. Finally, let me try to explain it in a brief way. First of all, whatever code is supposed to be error prone is kept in the try block, like one divided by zero and a equals n 23. So there is a type conversion and there is a division, and both are error prone codes and code cause an exception. Therefore, they're kept in the try block. Now we haven't except block for the specific zero division error. So what we're looking for is we are looking for we are expecting a zero division error. Therefore, we have tried to catch it over here. And once it has been caught, or any sort of zero division error is caught inside this, try block. The code jumps to this except block. You try to print with zero that Koegel print you try to print with zero. If any sort of zero division error is encountered now, also try to catch the value error exception as well. And here I have tried to print that wrong value type assignment, and in the finally block, everything went better than expected. So how it actually works is you have a try, you have a catch and you have a Finally, once you encounter an exception and try, it jumps up to the catch block. And once you go through that catch block or you don't go through that catch block, the finally block is bound to be executed. So let's take this example and try to execute it. So, as you can see, it prints me a message called You tried to print with zero and everything going better than expected. As you can see in the try block, we try to divide this with zero, which turns out to be an exception therefore, zero division error exception is caught and the code blocks jump over here and print this as we saw in the console. And it doesn't matter if the exception is caught or not. The finally block is executed and it prints everything went better than expected. Now let's fix this exception and then try to do it, since there was no exception in our code. Therefore, the code runs successfully, but still the finally block got executed and it printed. Everything went better than expected. Now, as you can see, this code is exception free. So therefore, let's try to create yet another exception. What I have tried to do here is I have tried to convert a string which doesn't have a based and literal into an integer. Let's see what happens and it gives me an error of wrong value type assignment, and then it executes the finally block. Therefore, in this case, we got the value error and the expected cold block was executed. This is basically what you need to know about this. Try and catch block and there will be a lot of examples will be giving in the discussion forum, so just go through them or try it on your own and find other examples of try and catch exceptions or maybe generate your own exceptions, for example, yet another exception could be if we create a list. My apologies. There could be a problem. Here it is. We forgot one inverted comma, double noted comma. Okay, so this list one is prepared, and as we know it, it does have three elements. So if you try to access the index four, we again have an exception. And this exception is called index error. Since this error is caught, we can also implement and accept block. And what I want you to do is to create this exception and handle it by your own code and go ahead with it and write it on yourself. Well, this is it for this tutorial. And as I said, the more you try, the more you'll get a grasp of the entire concept. So go ahead and try to find more examples and run them on your own and see if you can get a hang of it. I hope all of you are going good along with this, and in our next tutorial, we're going to deal with a very important part of python and those air functions. So get your belts tight and be prepared. See you in the next tutorial. Thank you. 18. 0501 Creating your first function: Hello again, everyone. Welcome to this tutorial on python basics. Today we're going to study about functions and we're going to create our first function on her own. So the basic agenda of this is understanding the basic structure of the function, understanding, naming criterion for the function and creating a very simple function. So let's jump to the command prompt. Let's have a look at the basic structure of a function. So I already have written a code which you can see over here. But there are actually three functions. But let's start with the more simple one, the first function named as Hello. As for the convention of writing a function in Python, we first of all start with a deaf keyword. And then we provide the name of the function, followed by the parenthesis and then a colon. And after an invitation block, we tried the code block for the python function. Now, as you can see, we have named this function as hello, and in the cold block session of this function, we have just executed a print statement pretty easy. So what function actually does and what function is? Actually, it often happens that we have some sort of functionality or code editor in python or any other language, and we want to execute it again and again without rewriting it. So what we do is we take a unit called Function and we organize our code over into that function unit. By doing this, we can actually call that function again and again. And that improves the code organization. And it also improves the usability of the code to somewhat level. And here we have created a function and we have put functionality print Hello, world. Over here, however, it is overly simplistic and weaken type print hello world again and again and it is quite equal to just typing. Hello. But in a long run, it turns out to be a very useful practice. So let's take this code and try to execute it. Now, as you can see, that nothing happened and we just have the interpreter and why So? So, To understand this, we have to first of all understand that once we create a function and define it until and unless we don't call it, the function doesn't execute. So obviously, if there is a function that has to be called that could be called by any other person just like me, who is running the interpreter or that could be called by yet another function. We will deal with that case later on. But first of all, let's see, where are our functions? So, friendly friend, the de IR function will help out in this case too, as you can. Apart from the other variables which we can ignore, we can actually see the Hello keyword over here. So this is our function. So that means when we executed this first function dot p y python file, our function got imported. So let's try to run it to call this function, we will just type its name followed by parenthesis and hit Enter. As you can see, the cold block of the hello function got executed. So now what we have to understand is a function can have a lot of things for a very basic reason. I will explain this in a very simple term. A function can have an input value or input values and a function can have a return type is well, it just acts as a very basic processing unit and with every processing unit. What we exactly have is a way to put input and a way to accept output end the same with function. We haven't input and we get the return. However, in any of the functions I showed you so far it doesn't have any return type. But in the later function, which I'm going to describe, we're going to have a return value as well. So let's quit it and check out those functions which does have some return type. For example, let's check the is on function now. What this function does is it takes an input and call it in. Now this end is check through a case condition off if it's an odd number or even number practically if we divide any number by two and the module is operator return zero, then it is an even number. Otherwise it is an odd number. So that is what we have done. And we have taken the end and applied the modular operator over here. And if the output is zero, therefore this numbers. Even so, the function returns false because in this function we're checking for odd, not even, but if the condition isn't so, will fall to the else block off this function and we will return true. Okay, so let's try it out. Now let's again hit the de ir. My apologies. And you can see the Izod function here as well, which has got imported. So let's execute it. Since we can only check over numbers regarding the even and odd condition, we're going to pass a number over here. Since this number is actually odd, therefore, the function returned true. Had it been even, it would have returned false as it is the case. So this is yet another very simple function. Let's go back to our file and check yet another function. The convert to interred your function here. In this function, we have kept a try catch block and what it does is it actually looks for the value error. And what we're doing here is we first of all, take a string which contains an integer, actually, and not an integer. Actually, it contains a number, and we try to convert it into an integer and return it toothy user. And if any sort of invalid values is applied, then this returns string and it prints on the screen invalid value conversion and it returns us nothing So python dot p y again and again if we want to check just to make sure there is the convert 0.2 integer function and we got to supply its, um value, let's try to supply it 123 and it returns us the integer 123 So if it returns it, can we use or store it in a variable? The answer is yes. So let's store this value in a and just to make sure that it returned an integer or not weaken type, check this and we get that. It's an integer type. Fine. It's working fine so far. Let's do something like this. And as you can see, it prints me the error called Invalid Value Conversion, which I actually put the message in the except block of this function. So I think we're good for functions. For now, this was a very simple description of functions, and we encountered with input values return on type and defining the function. What you can do is you can go online and check out form or functions. In our next tutorial. We're going to understand the input parameters in detail and return data type in detail as well. Thank you 19. 0502 Understanding input parameters and return type in functions: Hello, everyone. Welcome to this tutorial on python basics. In our previous tutorial, we were discussing about pythons functions, and in this tutorial we will continue with the functions as well. And we're going to understand input parameters and return type and functions. So basic agendas are understanding input parameters and setting a default for an input in python, understanding the return type in python and create a function with input parameters in return type. Actually, most of it we have done earlier, but we're going to reintroduce them just for the sake of a better understanding. So let's say for the purpose of this tutorial, I've already created a few simple functions. So here we have a function called X Power. So what it actually does is it takes a base and then index J, and it gives us the power. For example, if you're giving a value I called to and J called four, it raises the two to the power of four and returns the give and that is the value. So as you can see in the first function, we have applied to parameters. Actually, there could be endless parameters, theoretically, but if there are lots of parameters. What I would suggest you do is passed some list or sequence rather than just variables. This is going to be an easy task for you. Better than typing a long list of input variables. We will come to that later on. But for the time being, as we can see that we have calculated the power and now we return this integer. If we try to run it, X power equals, let's say the basis to and let's say the power is four. Then we get 16 which is actually correct. Now let's try to see our next function, X Power one. What we have done over here is we actually did some calculation along with the return statement. So even you can keep any sort of function over here for any small cold block. Or you can even return a function which we will deal with in our next tutorial Now, in the next function. What we have done is we have put default parameters and how does it work out for us? We're gonna have a look at that. Just keep in mind that rather than just passing I NJ, we have also specific constant values to them and then return the result. So let's have a look at it. If we run X Power one, it does the same thing. But however, the implementation is a little different. Rather than calculating the value and keeping it in 1/3 variable, we have directly returned the calculation, and we have embedded the calculation along with the return statement. Let's try to do something which we didn't do so far. Let's just not provided in the parameter. So as you can see, there is a type error because no parameters air provided. Right now, let's try to do the same with X power to function and see what we get. Okay, this is interesting. We didn't provide any sort of parameters, but it still came up with the result. How did this happen? As you might remember, let's jump to the code as you may remember, that we have put here default values since these values are already defined for I N J. It doesn't matter if we provide them value or not. It's still returns the calculation based on the default values and in the case, if we define parameters, let's say two and five then it calculates based on the given values. So this is it. We're going to introduce more interesting concepts regarding the function in our next tutorial. So let's have a look in our next tutorial. We're going to study about nested functions. This is a very small but a very useful concept which you might frequently encounter while programming with python. Maybe not that frequently, because it could not be a very good idea for nesting the function inside of function of this. Of course, we're going to get acquainted with them. What I want you to do is, as you can see in our code, what I have done is I have actually thrown a type error, and this type error was caused because I didn't pass any parameter or while returning the values. Let's say if we call something like this, then there is a type error, So what I want you to do is, as you have already introduced yourself with the exception handling, I want you to catch this exception and create a try catch block for it. So, best of luck, have a nice day 20. 0503 Nesting functions: Hello, everyone. Welcome to this tutorial on Python basics. We're studying more and more about functions, and in this tutorial, we're going to have a look at a very handy, very small topic called nesting functions. And if you've studied function, nesting could be very handy in a few cases. So there is only one basic agenda of this tutorial. We're going to understand and implement a nested function, as I've already created a tutorial for the app, and I've already created a code for that as well. So let's go ahead and try it. So here we go. We have a function called outer. It specifically does nothing. It just prints of value. But as you can see, what I have done over here is I have created yet another function called inner inside this function. And through that function code, I'm printing the string value. And then, since this function is just defined, we have to call it as well. So I have called this function over here. Let's try to execute it. Okay, so we have to run out of function. And, as you can see, it executed its statement as well. It executed the nest of function as well. So let's do something. So just for the sake of understanding this coat, let's remove this inner call and let's run the outer. And as you can see that since we didn't call the function inner, it doesn't actually run and print the method. Now we have to understand a very important concept over here. So far, we've been calling the method through the main Python program. But since the inner was defined inside the outer in this case, the outer actually called the Inter Function. So there is a concept of calling and called function over here, which we're going to deal with in detail in the next tutorial. The calling function is outer, and the called function is inner, so just keep in mind what are calling and called functions. And now this is it for this tutorial. What I want you to do is, as I have always been saying, go out and find out more descriptive and useful examples off nested functions and try them out on your own. It could be really helpful for your practice, and moreover, you get more insight into the python programming as well. So in our next tutorial. We're going to do a calling function from other functions where this concept of calling and called functions will work out. And this is it for this tutorial. Thank you. Have a nice day. 21. 0504 Calling functions from other function: Hello, everyone, welcome again to this tutorial on python basics. And in this tutorial we're going to understand the function calls and understand how calling from another function to another function works out. So the basic agendas of this tutorial, our understanding function calls and calling a function from another function. So let me explain it in a little detail. Calling and call functions are very basic common scenarios which we will find in programming very often. In fact, most of them are created once and then called by yet another function which maybe we create on her own. Or maybe someone else has created it already. So the function, which calls is actually called the calling function and the function which responds to the call and gets executed, is called the called Function. And calling a function from another function is not a very complex task. I've also created a tutorial on the same and let's check out the example. So this example has three functions, actually pretty short functions. And in case if you're wondering why these sort of functions are being introduced here, is because there are a lot of methods which might not be very clear to you. So let me tell you the purpose of this program First, what it does is there's a website called de mas dot org's, which is open here. What we're trying to do is actually look out into this website and get all the links possible in this particular Web page so it can be done easily in Python. And this process is called Web scrapping, and we will discuss more about it later in other tutorials as well in detail. So let's go ahead with it. We have a method called get Data, which actually uses a module called Requests, which has been assigning aliases are Q and yet another package. Beautiful soup has been assigned an alias as B s, and now we have a method called get Data. Now what we do in this get Web data function is we take the website and said an http request and get the response, and then we return the response HTML data. Now in get all links, it actually takes the html data and parse and returns us all the links in the particular HTML page. Once those links air generated the work of display links, method is to check out these links and print their H rtf tag. In case you might not know what an H r e f is, it is actually the section where the link address off the link is stored. So let's go ahead and let's implement the rest of the functionality. What we have got to do first is first of all, we have got to use get web data to get the data now, since it will return as the response text. So what we can do is we can use yet another function over it, get all links. Now, since I have all the links, therefore we will do one more thing. Okay, Now it seems pretty clear that first off were calling the get Web data and this get whipped data is called by actually get all links. Now this get all links is called by display links. Therefore, once we run the example, there seems to be some sort of error probably might have been some Internet issue with my connection. Anyways, we will go to that exception. What you can do is actually you can go ahead and check out for this particular exception and try to catch it if you can. It's entirely up to you anyway, since we have all the links printed over here, the main purpose of the method is not to actually see how can we fetch data because it could be a little out of our hand for the time being. What you might want to see is how the functions air called. We call it in a little awkward way. Let's do something like this. We go here and we call the get Web data method from the display links and will store the text in a variable called text. Now we will get all links, and we will call it as Web links. Now, once we have Web links, we may actually eliminate the input over here because we don't need it anymore. Now, as you can see that this function called First of all, get Web data and get all links, the names air pretty explanatory. So I don't think anybody would be having any problem following it. So once we have these Web links, what you might want to do is observe how we have used the four loop over here so far in the loops tutorial. What we have done is what we actually did was we took a number and created a sequence out of it, and then it created that over that number sequence using a for loop. But Web links actually is a list, and the way we and list is also actually a sequence. And if you remember, the range function also generated a sequence Onley, which was actually a list of numbers. So as we attributed over that we can attribute over this as well. So let's say if the Web links have 100 elements, so once we are parsing it through a four loop for link in Web links, so what it does is it goes through all the links one by one and executes a code over them. So this was pretty simple. We just had created two functions and called them one by one. And yet another function called display links. There are lots of functions you can create and then call them in your own function. So what I would like you to do is go on and try to create simple functions using your own. They might not be as complex as it is they could be simple. They could be a fuse or no use. But what I want you to do is to understand the syntax properly and how to implement this calling function functionality in our next tutorial, what we're going to do is we're going to study about recursive functions. Recursive functions are pretty interesting topic, and we often meet them in programming scenarios. For example, if you are writing a very big module and we want to do some clever work around it, then maybe we might use a recursive function. And in the next tutorial, we're going to study about them in detail. Thanks for watching. Have a nice day. 22. 0505 writing recursive functions: Hello, everyone, welcome again to this tutorial on Python basics under this particular tutorial, what we're going to do is we are going to study about recursive functions in python. Actually, recursive functions are in almost every language, and there are like scenarios where you can use the recursive functions. First agenda. What is Ryker Shin? We're going to talk a little bit about Ryker Shen and how it works, and we're going to create a program to compute the factorial of a given number. I'm pretty certain if you have any little mathematical background, you'll know what a factorial is. So let's proceed. I have created a code for the same. But before we go to the factorial session, let's try to create a program which actually is very simple. Ryker Shin and that will help us to understand what Ryker Shin is exactly is so when we call a function from itself, then it's called Ryker Shin. So when a function calls itself, then it's actually the definition of Riker Shin. So far, what we did is we actually used the functions we used to call other functions, and that's how it happens all the way. We created the get links. We created the get Web data and we get the display links functions in the previous tutorial and call them one by one in another function. But when a function calls itself, then see what happens. What we have done over here is we have created a function Hello and printed Hello, word in it and call the function in itself. Let's see what happens now. Let's call the function Hello. As you can see. First of all, it printed Hello then it resulted into an exceptional error and the error is a runtime error. Maximum Ryker shin debt exceeded. How did it happen? Let's look at the code. First we had a function and we call that function in itself. So what actually happens is first of all, hello is called Then again printed Hello world. Then again it called itself. Now what happens is when it called itself it again printed hello word and then called itself again. So it's sort of forms an infinite loop which keeps on running. Ah, very important thing which I maybe four to tell you so far is when we call functions the function call addresses are placed on a stack. For those of you who don't know what Stack is, Stack is a sort of data structure in which the first in last out paradigm works out. So let's say you can imagine the stack data structure like a stack of books placed over each other. So let's say if you put book one book to book three, then you have to. First of all, take Book three. Then you will take out book to then book one. So this is a very basic definition of a stack, and that is how function actually works. So let's say First of all, hello is called then second, hello was called in itself. So when the hello was called, it was placed at the bottom of the stack, which is in the memory of our computer system. Now, when the second hello was called, it's placed up on it. Now the 3rd 1 is again placed on top of the 2nd 1 and so on. So this is the way it actually starts filling up the memory and the stack grows out of rain . And actually, in the past, what used to happen is once you try to run some sort of code. There used to be a huge system malfunction because there was no sort of check toe actually catch such sort of exceptions which are trying to occupy the last memory section off the computer using the stack area. So what would actually happen is the program would crash, causing a lot of opportunities of exposing vulnerabilities Anyway, back to the top. Since we always cannot call functions like this, we need to have a base case which actually holds the function at some time. Otherwise, we will endlessly keep calling the function in itself, causing an infinite loop. So how do we achieve it? How do we create a base case which actually stops the calling infinitely? Let's have a look at it. So we look at our factorial function. What we're doing over here is we're having an integer end, and here we have actually a base case which actually determines if the end is less than one or not. If the end is less than one, it returns the one as value. Otherwise it executes itself again, reducing the end to yet another one number, and then it returns a number. So as you can see what actually happens is first of all, Factorial is executed. Let's say if we give it a value five then since it's not actually less than one, therefore it would go to the else clause and go over here and before it can go to the next line. What it will do is it will first of all, execute this factorial which would execute on five minus one that is four. Then again, that factorial will work on three, then two. Then when it will be one, it will actually return one which will be used by the factorial function, which is on the second top on the stack. And that will have a value of two. So there will be two and here will be one which will result into multiplication and that will return. As to now, this return number is again returned to the third top factorial function on the stack and so on. Anyway, I think it's pretty self explanatory. Let's try to execute this code. We get a value is five and see what happens. So there it goes. Actually, the factorial is calculated over here and actually is pretty fast. And that's why Rickerson is used quite often. Let's give it a little higher value. Okay? So as you keep on increasing, the number of the factorial increases exponentially. This is enough on Rikers Shin. In case if you have more curiosity belt Ryker Shin, I would suggest you go online and search for more functions regarding function. Or maybe find a case scenario and implement your recursive function in our next tutorial. What we're exactly going to do is we're going to study about modules and packages, which is yet another interesting and simple concept of python, which could be really powerful in case if you're working on a big project. So see you on our next tutorial. Thank you. Have a nice day. 23. 0601 Organizing your code into modules and packages: Hello, everyone. Welcome to this tutorial on Python basics again. And in this tutorial, we're going to discuss about organizing our code in Python and how we can organize our code into packages and modules. Understanding Python code organization. How to create modules and packages, importing packages and modules across your code, studying few most widely used packages in python. Okay, first of all, let's understand the need off the so called package and module. Why do we need them? So then, let's have a quick look at our code. These are actually the python files we have just created so far along the tutorial and there are lots of them, and I actually don't know how to categorize them into a logical hierarchy. So what I'm going to do? So that's why actually these packages and modules work in what actually happens is we take modules, as in these python files, and we organize them in a package. The package could be taken as a name space equivalent to other programming languages. So if you know name space and probably if you are from yet another programming background that maybe see sharp or java, you might know about name spaces. What name spaces? It actually contains a lot of classes and categorizes them into a logical group. We're not actually going to discuss about classes over here, but packages could be considered as a container for python modules. And what Python modules are thes individual python files. So this is about packages and modules. Let's try to visualize it over here. What I have done is I have divided our code into two packages. Package wanted package to If you're wondering why I have created these directories, so actually there only packages and the's are literally called the packages because they contain all the functions. But how can you call a directory as a package in python? If in Python you want to make some directory as a package? What you have got to do is put this in a file in it. And if you open this file and check out, there's actually nothing, so we can also define constraints over here. But for the time being, we don't do it, and we will keep it simple. So just keeping on in a dot p y file over here, make this directory as a package, and these are all the modules. Same in the package to I have created these modules. Each individual python file is called module, and the directory is called Package because it does have an innate dot P y file. Now let's try to test this out. Does it actually work or not? So let's switch to command prompt. Okay, so if we switch to goes to directory, we can see package one package to let's try to import the package one. If any of you don't understand what actually importing a package means is you might have noticed a couple times I wrote the import keyword and along with it gave it a package name . So actually, as I told you, that Python is pretty famous for its vast repository of packages. And as we can see, there are lots of packages for doing every sort of tasks, maybe data analysis, Web scrapping or system admin or anything. There are lots and lots of packages which make python so amazing. So we use packages because they are sort of a name space equivalent, and it organizes our code. Now let's try to import this package one so it's imported. Let's check it out There's nothing in it so far. Let's see. What else do we have in here? Import from Package one Import first function. There's a spelling mistake. Apologies for that. Now, Since this first function is imported, let's try to see what functions it has. So, as you might remember, in our previous tutorial on functions, we created these three functions and converted it to integers. Hello is odd. So now we can call them over here where first function is actually in module. So the function is working pretty fine. Okay, so this is basically the hierarchy of packages and modules just for a quick recap. Packages are the directories and python files inside it, our modules. But packages should need to have an innate dot p wife file if it needs to be called a package. A directory alone cannot be called a package. Doesn't matter if it does have lots of Python files until and unless it doesn't have an innate dot p y Python file. And to be clear in eight dot p y, the NH should be surrounded by double underscores Let's see a few of the most famous python modules. So when I talk about the most frequently used Python modules. The one module which comes to my mind is OS. It does have a lot of functions to interact with the operating system. Let's try to run a few, for example. Let's see get cwt what it actually does. As I told you earlier, we can use something like this. You can use the help method toe actually get help on the function, and this method tells us that gets CWD is used to get the current working directory. And since we are in the user So iota directory, this function seems to be working correctly. Now let's see a couple of more methods. M k d a. R could be a pretty nice function, so let's try to use it. But before we use it, let's check with the help says. It says that this method is for creating a directory, and it takes a path as the input. And also it can take the permission mode for the directory. So let's first of all created, create a directory called Testing One No error. So it seems like the function has successfully executed. Let's take a look here we have this testing one function. Turns out that the M Katie ir function worked just fine. Let's try out more. There is also a function called rmd ir, which takes the name of the directory and removes it. The function ran just fine. So I'm assuming that the file might have gone since its I python. I can actually print ls over here and check out all the files and the directories over here on Lee. So as you can see that the testing one is gone, that means that the RMD IR works fine. Yet another important module could be requested. We use it in the function tutorial and it is very useful. In many cases, it could be used to fetch data from online websites and store the HTML data wherever you want. It actually sends http request data toe websites and gets the http response data in return . And not just that. It actually can fetch the headers as well. Http. Header specifically and it can do a lot more than that. So first of all, let's just dive in and see what all the methods we have got Okay, Seems pretty good. So we have lots of functions over here So let's check out the get method, which is over here. We will access it like requests dot get. You might be wondering why I used the de mas dot org's and why didn't I use google dot com or any other website? The specific reason is that actually scrapping data or accessing any sort of websites from automated codes are not actually legal practices. And that is why, if we try to crawl Google using such a code, maybe thrill loop, then the Google often bands your I p for some specific time, and it restricts your i p address to access the Google website. And since you know that Google is everywhere and you cannot do anything without it. So my suggestion would be just to use this package very carefully. Since de mas dot org's has allowed people to access their websites through such codes. Therefore, we can go ahead and check it. Now let's check out what a has A has a response of 200 which tells us that http 200 response code has been generated, which means the data has been access successfully. Let's read the HTML data, or maybe let's check whatever we have in this object. Lots of things are over here. Let's check the headers. There are lots of headers and it tells us that the website was hosted on an Apache server and the last change was made on this date. And there are lots of things and the content type is text. Html Car set equals UTF eight. If you want to see the HTML data, then we just typed text and it will give us the HTML data. So this is it for the modules and packages. What I want to suggest is just go out there and check for the Python package index. So let's say we went to python dot org's and will go to P Y. P I. And here we can look for lots of packages over here. Just search for them, try them and enjoy them. And just to inform you, this is the end off the python basics tutorial and the next tutorial we're going to start. So this is it. We covered a lot of ground on python packages and modules in our nets tutorial. What we're going to do is we're going to deal with file Io and python and this is gonna be fun. What we're exactly going to do is we're going to deal with a lot of files and we're going to apply all of our knowledge that we have conceived so far. So I hope to see when the next tutorial Thanks a lot. Have a nice day. 24. 0701 Dealing with our first file and using write operation: Hello, everyone. Welcome to this tutorial on python basics, and we're going to deal with file input output in Python in this particular tutorial. So the basic agendas of this particular tutorial, our understanding, the stream objects and files resource is in python, creating a file using python and writing into it. If we follow the standard tutorial on the website of python dot org's, then we're going to find out that, basically, for reading and writing files, there's a method called open that is used and it returns a file object. So let's describe this method. It basically takes two parameters. The 1st 1 is the path of the file, and the second is the mode in which we're going to open that particular file. There could be multiple modes in which a file can be opened. It could be read right upend, read binary right by an airy etcetera. So I have created a very basic Python script for executing a task of writing a file onto our system. Before that, let's understand what actually open method does actually we have open method, which creates a file called sample filed dot txt in a right mode. Now what happens is it actually returns a file object which contains the handle of that particular file which we just opened. Now, this file handle object handles Theo entire file input output stream for us in other languages. It could be a little bit more code to handle the stream manually, but in Python, it's entirely done with the object written by this open method. Once this open method returns this file handle object, we can use the right method of this particular file handle and right any sort of data into the particular file. And then we have to use the clothes keyword off this close method of this file handle so that we can close the particular filed resource now for you can attempt the same code. Then what's going to happen is the same file is going to be over written with the same data . So what do we do if we want to upend some sort of data after the latest content of the particular file? So, for that particular task, we're going to use the A pen mode off open method and get the file handle. Then we're going to do the same task. We'll just use the right method and pass it some string and then we're just going to close the file stream, so it sounds pretty easy. Let's try to run it. I ran it and it ran successfully without giving any sort of error. So I'm assuming that the file must have been written by now. So just to be clear, the file is supposed to have this text, and after that, at the end of that, there should be this text appended over there. So let's see. I have opened the same directory in my Adam editor, So let's see if we have the sample file dot txt or not, here it ISS, and it does have the same data which we actually try to right over here. So this was pretty simple. What I would like you to do is to go to the standard website of Python and find out more modes for accessing the files and give them a try and see what happens. And this is it for this particular tutorial on what we're exactly going to do in our next tutorial is we're going to read from the files and process the particular text which has been read. Thank you and have a nice day 25. 0702 Reading from files and processing the text: Hello, everyone. Welcome again to this tutorial on python basics. And in this particular tutorial we're going to describe how can we read data from files choosing python and processing the text? The basic two agendas of this chapter are creating a file object using existing files in the system, reading the file content and processing them. So I have created a Python script for the same task. Let's go through it. So we are again going to use the open method and pass it the name of the file. And this time we're going to use the mode of the file as our which means read now. Once we have the file handle, we can go line by line and process each and every line off the particular document. In this case, we have a very simple sample data, and it is in a format called C S V. C S V stands for comma separated values. And in our later tutorials, we're going to discuss about see SV in a lot of detail. But for the time being, it is just some data values separated by comma and new lines. So what we're going to do is we're going to go through this file line by line and print. It's lines each and every time. Then we're going to print closing file. Resource is, and then we will take that file handle and use it close method to close the particular file string. Now, it could be fairy tedious to close the file every now and then. Once you open the file handle and sometimes you may forget and in some very specific cases it may happen that if the file is pretty heavy, you might run into some memory issues because this file resource is actually unmanaged resource. So to make it simpler and the disposing by default and automatically, what we're going to do is we're going to use the with keyword. The with keyword is very common. And in languages like C sharp, there is the equivalent keyword known as using. So we're going to write it like that with open sample dot C S V. R is the read mode as the file handle here is the alias of the file object as file handle. Then we take this file handle and do whatever we want, and in this case, we actually didn't have to close the file handle because it's going to get disposed itself as soon as we lose the scope of this particular with keyword. Okay, so far, it sounds good. Let's try to run this particular file. It turns out that I didn't say the file properly, so I just saved the file and I'm going to run this command again. Now we're going to have a look over here. First of all, what it did is it processed the document line by line and printed each in line. Now it closed the resource, and we have the message over here called Closing the file resource than dealing with the file object using the with keyword. And again it does the same task. But in this case, it uses with keyword. So I think it was pretty easy to follow. If you want to know more about this particular reading modules, what you're going to do is you're going to either go to this website of python dot org's, and maybe there are lots of other resource is as well. You might want to go over them and try out other methods of open keyword and see how they work out for you. So this is it for now. And now, in the next tutorial, we're actually going to deal with the exceptional cases, which we often run into when we are dealing with files. So this is it for now. Thank you. Have a nice day. 26. 0703 handling file errors: Hello, everyone. Welcome to this tutorial on Python basics again, and today we're going to discuss about errors which we might come across while dealing with files in Python. So the basic agenda of this chapter, our understanding possible errors while accessing a file object and using file io specific exception handlers. So it could be a scenario where you want to access a file and you're reading data out of it . But you've run into some issues. It could be a memory error, or it could be that the file doesn't even exist. And it turns out that in a few cases when the file has a very large size and you try to at all at once load the entire file onto the ram, along with other resource is the program often crashes or runs into an exception. So in this scenario to explain this in a better way, I have created a script which actually defines two methods. The 1st 1 is called Read File, and the 2nd 1 is called Greed File, too. In the 1st 1 I've created a scenario where you can pass the file name and what the method will do for you is, it will read the file and show you its content and the same goes for read file to. But what I've done in refile to is I've actually caught the exception Io error. And in a case, if any sort of Iot error is encountered, we're going to print this message. So let's go ahead and run this file. I should have applied the flash I command line. Now what we can do is we can actually call the read file method and give it some file name as the parameter, and it actually reads the file first. Since sample data dot C S V is present in our current directory, there was no error, but let's try to give a random name which actually doesn't exist over here. Let me see if Yoda dot CSP exists or not. So, as you can see, an error has been encountered. No such file or directory exists. Let's try to call the second method using the same input parameter and see what happens in this one. What we have done is we have simply printed a message regarding that no such file exists, so we have taken an account that we can actually catch the Iot error or the input output error. And rather than just printing a message such as no such file exists, we can do some other things, maybe create that file or maybe something else. So it's entirely up to you what you want to do in this particular code block. So what I'm going to do is I'm going to let you try to find out by yourself how to more efficiently handle this error, so it's going to be your effort, which you'll have to put in. I would also like you to try out the websites and search out for specific cases regarding thes file errors. You might not just be interested in Io Errors, which deals with Onley when the file name doesn't exist. You might also be interested in finding out what sort of exception occurs if the file is pretty large so you can use it as an exercise for yourself in our next tutorial. What we're going to do is we're going to explore the OS package and play with different sorts of paths and directories and see how we can manipulate them. So I think this was pretty much it, and you got the entire concept of errors and see you in the next tutorial. Thank you 27. 0704 Exploring the OS package to play with paths and directories: Hello, everyone. Welcome to this tutorial on Python basics. Today we're actually going to talk about how we can use the OS package to play with paths and directories and files and get the attributes using python. So the basic agenda how you can create a directory using python, how you're going to list the contents of a directory using python, telling if particular file exists or not telling if particular directory exists or not getting absolute paths of all contents in a directory and getting name extensions and other attributes off the files and python. So they're going to be pretty straightforward methods for doing whatever we're trying to do here. So what you have to do is just switched into your command line and start the I Python interpreter. The very first step is going to be importing the package called OS. Now if we check this out, there are lots of methods in OS actually, which you can use every now and then for doing regular tests regarding file system or OS. So let's say we want to create some directory, so what we're going to do is we're going to use the m k D. I R method of the OS package and pass it the name of the directory. So it seems like the directory has been created. Let's check it out as we all remember that in I Python we can actually run the command, prompt user commands rather than python specific commands. So once I ran the Errors command, you can see that their files over here and directories to So we created the sample directories, which is over here, so it's fully created. So if we check out this OS package again, we can actually find similar methods called Rmd IR, which stands for remote directory. So if we use it, let's see what happens. As per my assumption, the file. The directory should have been removed, so we check it again. There is actually no sample directory anymore. There's just a file called Sample, but there is no directory anymore, so that was pretty easy. Now let's move on to our next agenda that is, listing contents off a directory using python. So the way you use ls, you can also use python inbuilt commands to list the contents, be it the file directory or anything regarding a particular specific location or path. So the method to do that is de ir, and you have to pass it the path or directory, which you want to list. So let's say we are actually in our current directory. And in the current directory there is a folder called Tuts. So once I hit Enter, I can see there are lots of files over here, and that is basically the directory, which I used to keep all the examples regarding pythons. So it works pretty fine, as you can see that it returns me actually a list of all the file names and directory names . So let's go ahead telling if the particular file exists or not. That is also a very trivial task we will against which to the OS and will use it. It's module called Path and a method called Exists and passed it the parameter. So if you remember, we had a file called sample dot txt in our current directory. So we're going to pass the name and it returns. True, that means the file exists. Let's go ahead and do the same with the particular directory and the TUTS exists as well as we can see it from here, the tuts and the sample dot txt Both of them exists. So let's try to find something which doesn't exist. So the Yoda folder is not over here or any sort of filed called Yoda is not over here, so it returns me the false value. So what else can we do? Actually there lots of options we can do. But let's stick to our agenda telling if particular directory exists or not In Python, we just did it. Now let's talk about getting Thea Salute path of all contents in the directory. So how can we get absolute paths of all contents in our directory? Let's talk, first of all, about getting the absolute path of one content or one file in her current directory. So before I go ahead, let me define what is an absolute path and what is a relative path. In our directory, we often switch to lots of directories and go to different sorts of locations in our file system. So let's say if we're in some specific directory, it's obviously going to have lots of files and directories as well. So as you can see over here, there are lots of files and directories. But what we have to do is actually we don't need to actually type the full length of the absolute path of the path. For example, if we're inside the sea directory and a folder called Users, then a folder called Yoda and then a folder called Tuts, and we want to access the file inside our current folder, then we don't have to write the entire path of the particular file. We just take the name of the file. And as for the relative absolute relative path, it actually fetches the file and could access it. But if you want to specify the full path or the particular file or directory, you'll have to use a method for python, which I'm going to show you right now. So always dot path dot a B s dot path is the method. Let's pass it the name like sample dot txt. So it returns with the absolute path of the particular file. And, as you can see, there are double backslash is because back slashes are special characters and it needs to be backed up using a backslash anyway. Now let's talk about how to get the absolute paths off entire contents in our file directory. So what we're going to do, we're going to use a loop over here for the content in os dot list de IR and we're going to pass it a parameter as dot the dot stands for current directory and double dot stand for previous directory. Now, what we're going to do is print os dot path dot a B s path and pass it the file name or directory name. So, as you can see, once we did it, actually, it printed the absolute path of the entire directory, so that was easy. Now let's try to do yet another thing. And that is how can you get the name extension off a particular file? That is also a nontrivial task. If you want to fetch the extension of a file, you might have to do lots of calculations, maybe string manipulation. Not a lot of but a couple of. But you might not need to do that, actually, because Python already has a method for that. So we're going to use the method os dot path that split e x t e x t stands for extension and pass it the name of the file. Now, as you can see, it returns me a couple with the name of the file without the extension and with the extension as well. So if I store this topple in a variable and call it a, then you can access the extension of the file like this. Actually, there are lots of programming scenarios. You have to determine the extension of the file so that we can go ahead and do the specific file operation based on its extension. So this is all of the contents were actually going to cover regarding OS module. And what I would like you to do is to do some exercises on your own and go to the website and find mawr examples. What you can do is you can actually try to find if there are any ways to find the files or other attributes or not. So this is basically the end of the Siris on Python basics tutorial. In our next tutorial, we're actually going to get some advanced features of python and understand how we can do the basic data analysis in Python. See you in the next series of tutorials regarding python basic data analysis. Thank you. Have a nice day 28. 0801 What is data Science and what does data scientists do: Hello, everyone. Welcome to the tutorial on data science through python and in the specific tutorial. We're actually going to talk a little bit about what data sciences and what data science specifically does. So it could be a complex question to answer in just one minute tutorial, because there are lots of tasks which actually covers the entire circumference of what data science says. So let's try to brief it and divide it into specific agendas. Basically, let's try to answer the first question, and that is going to be the first agenda of this tutorial, and that is understanding data science. And we're going to answer what data scientists, daily tasks are and job opportunities in the data science field. So, first of all, let's dive into some data and let's see what data science says data is around us everywhere . Either it be the banking applications or taking data from a team machines or about tweeting and all sorts of tweets and facebooking posting comments or even G mailing. Maybe going somewhere with your location history on in the Android application, which is actually signed into your Google app. Google count. So each and everywhere in today's world we are getting or receiving data of any sort. So this data is actually going through or from us, and it's actually getting loaded somewhere. It could be servers. It could be some other machines where there are actually lots of people who take out this data and make enormous amounts of calculations and manipulations somewhere. So what could be a very good example of this entire process? So let's talk about it. First of all, this is basically the Google map application. And once you go to your account in your Gmail, and once you go to your personal info owes, you can actually track out there and how can you see this specific map? And if you see carefully, there are basically maps about my location, which is linked to my account, and you can see that it's actually pinpointing the areas I've been into. So if you might have seen, like a few months ago, there were actually giving the location through which you have been. Maybe, let's say I have been living in Nordea and I've been frequently traveling to Gorgon, and then they used to actually show the tracks. I don't know what the reasons are they stop doing that. But the point is that they're collecting data on a daily basis. Just imagine that you have an android phone and its GPS is on, and you're frequently exchanging a lot of data through the Google server. And the same is going on with all of the Android devices, which are length with some specific Google account. Now all this entire data is going to a specific server if we try to figure it out. Actually, it's petabytes. Sometimes it goes to petabytes or terabytes easily because it chooses the data and a lot of data and to process it. Actually, we have to be very careful. It's not a very normal data where some sort of our TMS works out. We just pop in the server rdm s and the things go pretty easy. Whatever solution, whatever algorithm we use, it has to be very scalable and other sort of technologies has to be applied to keep the things straight. Now this all comes under data science. So let's say if we just put in our location over here, or let's say I have been there in this specific area, so all of that information is actually recorded in process somewhere. This is actually one example of what exactly data science is and what it can do. Let's move on to some yet another example called Twitter. So what Twitter does is it? Let's say if we have some sort of incident and news phenomenon in a particular area off any specific region, let's say India. Then what? Actually, sometimes we have to do in Twitter is they basically crawl through every tweet of the people over here and try to find out what the exact phenomenon which has been occurring a lot nowadays. So let's save someone, processes something about a president or PM Then what Twitter does, is it? Actually, it's called Crawl, and it crawls through all its pages for the specific Ward PM. Let's say Narendra Modi. So all those pages which contain the particular string Narendra Modi are now going to turn up to the Server two tweets. So this is an enormous amount of data which needs special algorithms and very carefully managed servers to process and to result into a specific conclusion. So what could be the entire conclusion of this entire process? Let's say if There's a lot of tweets which are exactly targeting to a specific news phenomenon. Then Twitter has to set a word that is going to be trending or not. So there are lots of decisions which actually has to be taken over and to do them. We actually do a lot of data science. Same goes with the Yahoo finance data. As you can see over here, this is basically the website where you can actually put the dates hit, enter and get the specific data. This data doesn't seem pretty much, but if you just say, let's see if you put in monthly or let's say daily and give the interval a little bit more , then the data increases as per that. So now what the problem is, Let's say if you want to make some sort of prediction over that, what data scientists do on a daily basis, then it's going to be pretty difficult because the data is in pretty much quantity and you need to have a specific algorithm to arrive at a particular conclusion. So all in all, the conclusion is data is everywhere around us and we have to manipulate so that we can give a better surface. It could be a software service or could be a some sort of Web application. So there's always a product for that data. And to develop it process that particular product, whatever technologies air used that actually comes under see subject of data science. I think this is it that we're talking about understanding data scientists, daily tests. What are the basic job opportunities in the data science field? So basically, if you talk about the most cool jobs off, the 21st century is actually data science. People running towards that, and mostly the people of I t are pursuing data science because there are lots of opportunities, as data analysts, data scientists or doing some sort of calculations using big data, etcetera. So all of these short terms are actually pretty trending. And if you try to seek an opportunity, there are lots of scope and pretty good salary and career as well. So, apart from that, I think this is pretty much it, which we need to discuss about data science. So let's move on and see what is going to be in our next tutorial. We're actually going to study. Why do we use python for data analysis and other related tasks. And why is it so specific? Why is it trending nowadays that white people are picking up on python for data analysis? So this is pretty much it. And I'm pretty sure you are pretty much excited about the next tutorial as well. Thank you. Have a nice day. 29. 0802 Why python for data analysis and other data related tasks: Hello is your one. Welcome to this data science tutorial through python, and today's tutorial is actually going to be all about python, for data analysis and for other data analysis related tasks. So we have basically two agendas embracing pythons, flexibility and python modules for data analysis. So the primary question is, Why are we choosing for Python if we're going to do some sort of data analysis? Aren't there other frameworks to do that? Or if there are than what are they? And why is Python so flexible in terms of development? And how does it speed up the entire process? And what are the most famous available models for Pike on data analysis? So let's answer the first question. Why do we exactly take Python? As you might have observed so far, that when you check codes in python, the code is so autumn ized and readable that it actually takes pretty less development time . For example, you come up with some random idea and you want to implement it, and it's not going to take much time is compared to Java, Sea or any other language. However, the downside of Python is that it's a little slow, but with proper optimization and specific hardware. That issue can be overly done, and therefore ultimate performance can be provided through python. So why data analysis and why? Data analysis Through python. Basically, when you worked as a data scientist, you often have to come up with certain sorts of algorithms, which you need to apply on some fresh data. Now these things keep happening so randomly that often you need to write scripts quickly and speed up the entire development process. So the good thing is that a vast library modules of python are actually so spread out that if you want to do any specific task, you've got to just search a specific package for doing this. So in Python and differently, 90% chances are that you are going to get some sort of package or to resolve some sort of task. For example, if you want to look out for some specific package which solves the issue of data analysis, for example, if you want to look specifically for solving a problem like how to deal with the issues which you handle while dealing with HTML data, which is scrapped through python, so what you're going to do is you're going to make a quick search, and there are lots of modules which will help you out. You might also be willing to handle threads or multiple threats easily and wondering that if I had to manage or code it or is there yet another efficient way or any sort of package or module, which handles the threads for me in a multi threaded programming moment? So, yeah, there's a module for that as well. So the good part about that is we don't have to write a lot of boilerplate codes, and everything is pretty much prepared. And moreover, the data scientists chooses python over other languages because it also integrates pretty well with other languages. For example, let's say, for example, you want to write some code in Java and you want to write some code in python as well, and you want to get the speed of Java. However, you want to stick with some specific modules of python. Then you can write Johnathon, which is a way to integrate python and Java, and the same goes with Cy Thon. That is a way of integrating see and python, and there could yet be another thing like, for example, that's consider statistical computational module called Our, which is pretty famous. So once you take our and you want to make operations on it, using Python their modules for that as well and their modules for Harrow and Cassandra's well to integrate well with Python. So all in all the good thing about Python is it does have a vast library of modules, and apart from that, it integrates with all other data analysis frameworks pretty well, so it makes an ideal language for actually doing any sort of data analysis. Now, as you might be wondering that this explanation is not pretty precise and therefore what I'm going to do is I'm going to take the rest of the chapters coming up in this tutorial, basically concentrating about data analysis. So then you're going to realize how easy it is to pick up any sort of simple data analysis using Python. So our next tutorial is going to be on RD BMS, which actually stands for relational database management system. So we'll actually be storing a lot of data in our database management system. Most of you have heard of database management systems and how they work out. For those of you who don't, we will actually be covering a lot from scratch about rd bms and do basic operations on it . So this is going to be a very crucial chapter. And you better buckle up your belts because it's going to be a pretty nice tutorial about RD bms. So see you in the next tutorial. I hope you're pretty excited about that as well. And this is it for now. And thank you and have a nice day. 30. 0901 Introdunction of RDBMS: Hello, everyone. Welcome to this tutorial on data science through python and in this specific tutorial we're going to study over here. What are de PMS is and what actually makes it a relational database management system. That is the full form of rt bms. So the basic agenda of this entire tutorial are what is tabular data? What is schema and basic essence of rd BMS. So let's study about tabular data First, a tabular data is a sort of data which is arranging tables, that is the basic and very simple meaning of tabular data. So let's see one of our tabular data and this is the you i. D ai website, Unique Identification Development Authority of India and they are actually assigned for creating at our cards for the people of India. And they actually host a lot of data regarding those cards online, which can be downloaded just by going to the website without any sort of authentication. So let's download the data for all India District wise saturation report. Once it's been downloaded, we can open it. As we can see, this is opened in an excel file and this is basically a table in which we have columns, and we have rows and sales which are made by intersection of these rows and columns. So this is a very basic form off a tabular data. Now, since this is a tabular data, now let's talk a little bit about schema. What is schema? Basically, we have tabular data, mostly in any sort of database management system. Their tables, however, not like Excel file tables. But there are lots of tables, and in most cases there is some sort of plan. Or what you can say is a little bit of constant applied over those tables. For example, you might see these tables right. Some values could not be applicable, and some values could be empty as well. And excel can't do anything about it. Or maybe if you look at it, this is a popular census. You might want Teoh Um, we can also enter any string as well, and Excel will do nothing about it. For example, let's say we enter Yoda learning, and if we try to save it, there won't be any sort of error. But in a real database scenario, doing such a mistake could be really devastating. So a scheme is designed specifically for what sort of data is there going to be and what will be its data type and how columns will be there and how Rose will be there, etcetera, etcetera. So such a plan, which is applied over tabular data, is called a schema. Now let's talk about our D. B. M s already be a mess, and it's very basic. Essence means a database management system based on a relational model. The relational model was actually invented by E. F. God from IBM, and the relational model is specifically about relating the entities in a database management system to each other. Before we talk a little more about rt BMS, let's understand what is a. D B. M s, which means what is a database management system. As you can see, there's an Excel file open. If you have a very small application which processes these Excel files regularly, then it could be a very simple task, and it won't matter how fast it is or how slow it is to process the Excel files. But let's say if we have the data of entire India for all these at heart cards than process in thes Excel files, maybe processing yet another no pen file or any other file could be really slow and could take a lot of time and could be error prone as well. So specific software are created like D B M s, which actually record these datas and using different algorithms they make. Accessing these data is very fast now, why relational and what is a relational model? Let's not go over a very complex definition. Let's go to a very simple definition. I'm opening here flip cart, which is a very common website, and most of you are aware of it. So as you can see, there are lots of products and I can buy products over here. Let's try to buy something. We have to select a size. So let's say if this is a fit size and we buy it now, so it leads you to the It asks for email address. Why does it asked for email address? Because each user has a specific email address. Now, if we try to realize, then this product is actually, um, related to the user of who was buying it. So this product, since it's actually stores information in a database. And now this database will also be having information about all users. And now this entity, which is a product, and a user are related to each other. So obviously we need to have a mechanism in which we can relate entities with each other by means of specific keys. So this is a very basic term. We can call it a relational model. That is why we need relational database management systems Now, since we have defined RD bms, there are lots of arty BMS software out there which are pretty popular. We can take, for example, Oracle Oracle's product, and we can consider my SQL as well M s SQL server, Post Gray SQL or SQL Light. So in this tutorial, Siri's we're going to post gray SQL because post gray SQL is pretty fast when it comes to integration with Python. So I think you have got a little bit of grab of what is already BMS what is schema and what is tabular data. So let's go ahead and see what we have in our next tutorial in our next Siri's. We're going to discuss about post rescue well, and we're going to go through all the nitty gritty details about it before using it. I hope you find this tutorial interesting. If you want to know more about rd BMS, you might want to go ahead and search online on RT BMS Software's and choose out your favorite one which suits your needs. And this is all for this tutorial. Thanks. Have a nice day. 31. 0902 Introdunction to POSTGRESQL: Hello, everyone. Welcome to this tutorial on data science to Python. And in this specific tutorial, we're going to exactly discuss about post grass ski. Well, so what? ISS, Post grass QL. And we're also going to discuss a little bit about SQL. So the basic agendas of this chapter are a brief discussion about Post Grad SQL. And what is SQL? So first of all, let me describe to you what is post gray SQL as I've already told you, that out there in the market there are many rd BMS packages which you can use for managing your database and post gray SQL is one of them. It is actually open source and it is pretty fast and acts literally lightning speed along with python. And for nowadays it's quite recommended as far as your using some sort of arty bms along with python. So what does post Grass ski well look like? The G A Y interface of post grad school looks like this and the command line interface. We actually have to start this p SQL show. But before I tell you all this, let me describe to you a little bit more about Post Gresko So, like every rd bms package post grace, he well actually uses SQL, which is, which stands for structured query language. We'll talk about structured query language a little bit more after a couple of minutes. But before that, let me tell you that post grass que L is considered pretty neat nowadays and it's highly scalable and that's the reason it's quite used. Nowadays, along with Web applications, the python framework for developing for applications is sango. So if you use dango, it's quite often recommended to use post rescue well, along with it as backing. So since you might, there could be an audience range off audience over here, which is not even introduced very well with Artie BMS. So let me tell you on that level that first of all, post gransky well is an rd bms. And it uses structured query language that is SQL to manipulate, calculate and do any sort of operation over data. And there are lots of cool features along with post grass que Well, which few off the rd BMS packages don't have like it does have a post G. I s the Post G. I s is actually module which comes along with post Braschi well, which can be used for dealing with geo special data. What is geo special data? In a very small term, I would define it like the data which is concerned with our geo coordinates that is called Geo Special Data. To sum that up, we can say that post gray ski well is pretty efficient rd bms package, which is open source and run in different types of operating systems. So now let's talk about what is SQL. SQL stands for structured query language, and it's basically used to control the data or manipulate or define the data in a relational database management system. Let's say that if we have some sort of data in a tabular form and you want to do some sort of calculation or let's say we want to query some data from the data table, then we'll have to run as specific SQL for that Now, these commands, which SQL contains, can be divided basically into three categories. The 1st 1 is DTL that stands for data definition language. The 2nd 1 is D. M L. That stands for data manipulation language, and the 3rd 1 is D. C. L That is data control language. What we actually do is, once we use an RD BMS package, we actually have to create lots of things like database tables and rows columns frequently . So once you are defining the data, let's say if you're creating a table, then that would come in. Some specific command would come under the DDO. Now, once the data table is created or the database is created and some sort of values is stored into the database, or let's say that the data set is stored into the database, then we often have to query it so that we could actually process the data. And those commands, which actually manipulate the data from the data table, are called D M L. Now what's Decio? Since we're using database and data table, there should be a very high emphasis on the topic that is actually accessing the database and that comes under authorisation. So authentication or authorization part off the database and lots of other controls over the database are controlled by the D. C. L. Now, since we know a little bit about RD, bms and SQL. Now, we're going to deal with Post Gray SQL and install it in our systems. In our next tutorial, what I would like you to do is go further and find out other rt bms packages and see what features they have and what features and compare them with the feature list of post grass ski. Well, it will be pretty nice exercise. And now this is it. I think you can grasp a little bit into the concept of rd bms and post grass que well. 32. 0903 Installing postgresql on different platforms: Hello, everyone. Welcome to this tutorial on data science with python and in the specific tutorial, we're going to talk about how you can install Post Grace que well server on different sorts of operating systems. So the basic agendas are pretty clear. We will look after Windows Post gray ski. Well, installation the Mac post gray, ask you Oh, installation and then post rescue. Well, insulation in linen. So what we will do is we will go to the official website of Post Gray, ski well and go to its download section. As you can see over here, there are lots of variants available for downloading. So once we go to Windows one, there is this graphical installer already linked even over here. So we will download it for the sake of convenience. I've already downloaded it. The rest of the thing is pretty easy. So you just have to double click it to start and it will start by itself before I go on further that this installation has to be observed very carefully because each and every step is very important and be whatever the operating system, this graphical installer is pretty same in each and every one and you have to select the same operations and options. Whatever it be, either it be Mac OS X or Linux or Windows. So here we go. You might have seen the Microsoft Visual C plus plus screen right before starting this installer and this will show up in Windows only not for Mac and Linux. So you don't have to worry about that. Next, we will choose a location for installation, which is okay for the time being. The next position is actually for the data. You can also select it in the different place. Now we will click next. It will begin the installation so wants this set up is complete. Actually, in my system there were already a post gray SQL server install so it didn't ask for the port number and password. So what you'll have to do Another thing is, if this is the first time post grace que well is being installed on your system, you will also have to define the port number which will be 5432 by default, which has to be entered, and they also have to select the password and then you can go ahead now since this installation is complete, you can see a stack builder over here. You can either uncheck it and finish this and there will be no other installation apart from that or you can check it and then go ahead. It will start the stack builder for you. So you have to select the server, which is on a local host only and will click next, and it will show us the application list which comes along with post Gransky. Well, for example, for geo special queries, we actually have post G. I s The database drivers are over here for different sorts of programming languages. So we're not going to get that. And for the time being, we are actually just going to stay whatever we have installed. So let's check if we have successfully installed it or not. If you have successfully installed it and search for post grass key well, it should come up and something like that, where you have to select the local host post dress port number, use your name, which is going to be post GREss because it is actually by default, wants the post gransky well servers installed. And then you have to enter the password. When you successfully enter the password, it will start. So this shows that we have successfully installed on Windows. Now the same process actually goes with Lennox. You just have to come over here to select your free de ir open BSD be it 12 db in red hat. If it's fedora, you might want to choose other whatever detail. Let's say, for example, if I selected a bun too, it will show me the binaries. But I'm more interested in the graphical installer and we will download that. And in the case of Mac OS X, we're going to go ahead with a graphical installer only. So just keep in mind that you have to go for the graphical installer and whatever operating system. Regardless, your installation process will be the same throughout. So I think this tutorial was pretty helpful in installing post grayscale server in the next tutorial. We are actually going to play with post grayscale while using different techniques and see what else we can do with post ghriskey well and how we can learn different sorts of queries . So thanks for watching. See when the next tutorial. Thank you. Have a nice day 33. 0904 Playing with postgresql: Hello, everyone. Welcome to this tutorial on data science through Python. In this specific tutorial, we're going to play a little bit with post grass que well, using SQL that stands for structured query language as we studied in our previous tutorial . Now let's point out the basic agendas of this tutorial. Our first agenda is to talk about different database objects and how they fit in the hierarchy. Often rd bms, creating a database in post grass ski well deleting database in Post Rescue well, and creating a table in post grass que well and deleting table in post gradski. Well, let's talk about database in a relational database management system. We usually have a database, and there are lots of database objects which come under that database. So if you have to store some sort of data, maybe a data coming from a website or maybe data that you can actually want to store into your database management system using software module or something. First of all, there has to be a created database under which we basically have a lot of database objects . For example, we have tables, views, functions, stored procedures, etcetera, etcetera. So this project and to keep the project under scope of python data science, we are actually going to talk about tables only and leave the rest of the database object. However, I would recommend you search for other database objects and study them on your own, if interested. So let's talk about database. But before that, since we haven't sold a post grayscale server, then we should first of all, start the P SQL. That's short for post grayscale shell and see what we can do and how we can start that shell. So I'm gonna search for P SQL in my Windows system. Now, as we can see here, there is P SQL shell Over here we will start it. First of all, it will ask for variables as an input to make the connection with the database Post Grace you'll server. So for the time being, since the post grayscale server is installed on our local host, we're going to leave the servers local host Onley in our database. Once we create some sort of post gray schools server, we're going to have a default database post grad school on Lee and leave it as it is and we're not going to enter. Any option over here is well, by default. The port number for post grayscale server is 5432 If you're wondering exactly what is a port number, actually, when we connect to a server, we actually do connect them through a socket socket, as in a web circuit. And if you're connecting some sort of server through a socket, we actually have to specify some variables. For example, what is the address of the particular socket and what is the port number in which we're going to connect? So in short, we can consider the server as an address as the connection cable of your home. And we can consider the port number as the channel number, which you're actually usually switching. So we will leave this field as well. Blank. Then we will go ahead for user name once we'd solve a user name called the Post GREss Default created. And for the time being, we are. And once again, we're gonna leave this field blank. If you remember, we entered a password while installing post grayscale server. We're going to insert the same password over here. So as you can see once I enter the password, it connected to the post Gray SQL server and it showed me the show. Now, first of all, we're actually going to take a look at, um, a few commands, which would be handy. We're going to have a look at the basic command called back slash L. And once we enter the back slash l command and hit enter, we can actually see a list of databases which are currently over here in post dress. There are the default databases, which are actually created by default. Once you install the post rescue will server. So as you could see, there is post breast and there are other databases as well. We're not going to do anything with them now. 34. 0904b Playing with postgresql: we're going to go ahead and understand how to create a database by your own with a specific name. So the syntax for creating databases, we first of all, inter create and we used the key word database, and then we go ahead and enter the name of the database. Let's keep it test and semi Colon and we hit Enter. It's taking a little time now since our databases created the message is shown as create database, which actually means there is no error and our database has been successfully created. Now let's hit the back slash l again and see if we can find out database in the list of those databases. So as you can see over here that a test is now included in the list of the database. So congratulations, you just created your database successfully. Now we're going to connect with the database. Since we have started with Post GREss by default, we actually need to switch to the next database. So the command to enter and connect to the database is backslash C and the name of the database. Now, as you can see, the prompt has changed and from post dress, it has actually become test. That denotes that we have switched from the database called Test Now, since I just mentioned that a table falls under the database and thus it is called a database table database object. Therefore, we're going to look at how many tables are over there in this database, so the command for that is back slash d. So it says that no relation found that's because actually, there are no tables for the time being, since we just created the database. So now we're going to look upon creating how to create a table. So the basic interest for creating a table is something like that. As you are going to see on our first line, we have created a table called User Info in which we're going to store info regarding a user scenario. So for the time being, you'll just consider a scenario where we need to store the information of a user. So what we're actually storing now the first column is I D. This is a very care. Their care is in a sort off care whose length be variable. We're going to talk about what fair care and care actually means but for the time being, were signing a column off a type there. Care with the max. Length has set his fifth, and we have just loaded a keyword called Primary Key. Over here. We're just going to talk about it in just a moment. Now we have a second column called as name, and it's also a fair care, since the name is going to be text. So we have to put their care over here again, and we have defined a constant over here. The constant is that the value cannot be know what it means is we cannot leave this field empty or no. I would like to mention that no and empty. Both are entirely different things, and we're going to talk about that later in a little bit of detail. Now, age since ages, always numeric, so we have kept it as int and stands for integer. Now again, we're going to store the role of the user. So yet another column, with the data type as very care and the max length is going to be 20. That means that the character is not going to be more than 20. So what are we going to do is let's copy it and create the table. Let's hit enter And it showed me the message as create table. So there is no error, and that means the table has been successfully created. Let's check it out if it has been created successfully or not. So we're going to again enter the command back slash d. And here, as you can see, there is a table called user info, as we just created. Now, since we have created this table, we should be able to insert data into it as well. Now, what is the general syntax for inserting data into a table? We're going to have a look at it. So general syntax starts with insert, and we're going to use the keyword into user info. Now we're going to use the keyword values defining what sort of values were actually going to insert. So first is I D. That is I D. One second is the name as we defined it in our table, that is Raj up for In this case, 3rd 1 is 34. That is the age, and it's defined as an integer now the Fourth column, and it's called role, which is having a very care and max length is 20 is going to continue in the field called Programmer. So here we go. It sounds pretty nice and pretty easy. Let's go ahead and insert this command over here is well, and run it so it sounds like we have just inserted some value into this table. Now, how do we check this value? And how do we query this value? We're going to enter the command as select asterisk asterisk stands for all from the table user info. We can apply different sort of parameters over here and get filtered it as well. But more on that later on. So we paste over here and we hit Enter as you can see that we just got the values which we inserted. Let's try to fiddle a little bit. We create yet another We change the i d. We changed the name as well and would change the role also, the H and we hit Enter and we again hit the command. Select the command from all user info So you can see again the field and the column values are inserted over here. So why are we changing this, I d. Let's try to understand. So what primary key is actually, in each and every table we have a column which is unique and identifies each and every row . Uniquely, this is important because once you are filtering data at a very large scale of data and you have to set that particular specific row part, then you should have some specific primary key. Otherwise, you'll never be able to identify that particular road uniquely so. In our case, this particular row is I. D one now. This particular road can be specified by the constant called primary Key. Once we define the primary key, it automatically cannot contain any know or empty value. So if you try to do something like this, then we get that empty value over here in the I D. Now let's try to do something over here like this. Let's create a row with the same data and see what happens. Now. As you can see, the duplicate key value constant has violated since we tried to use the same idea again. Therefore, we will have to change this I d. Every time. Now See now this row has been inserted So again, let's understand what not know Constance is for we have this not know Constance here. Let's try to see what it does it mean. Actually, I put a value called No, and it again says that the null value in column one violates the constant. No, it's actually is a type we put in some specific database column or sell if we're not sure what we will be going to insert of it here. Or it could be the case that once we're programming and that data source, which is coming, might have some gaps in the data so that specific field could be no in a few cases. So this is specific data type, which defines that this value doesn't contain any value but is simply no, which means nothing. So as you might have seen that I just run an insert query over here, which actually had nothing in the primary key field. As you can see that entering empty over here basically creates yet another row, which wasn't supposed to happen because it was a primary key and there has to be some value . But once we enter the primary key constant into some column it actually gets two sorts of things. The first is that it should be unique and it cannot be duplicated. The second thing is that it cannot be No, since empty is not know therefore, this insert commands worked out fine. So therefore, this is the restriction between the null and empty. We should never confuse no value with an empty value. Now let's talk about deleting this specific data table. So delete thes specific data table. We're actually going to use the delete key word, and we're actually going to type the table name. Now. Since we have created this table user info, we will need to drop it as well at some point. So to delete the specific data table, we're actually going to use the keyword drop, then table and the table name and hit enter. So the table has been dropped and we will check using backslash t again. There is no table, therefore, that our table has been successfully deleted. Now, this was all about so far we could actually cover under the scope of this course about database and post rescue. Well, so what we actually did is we created a database we deleted a database in Post Rescue. Well, we inserted lots of values in the table and we created the table is well, and we learned how to drop the table. So however, I cannot cover all the database objects in this tutorial. What I would like you to do is go find the tutorials for post gray, ski well online on different websites and check out databases, object as well, and give them a spin on Post Rescue will show so that you could be able to learn a little bit more about it. And it will be handy in the future because we're going to use other commands in the rest of the tutorial as well. I think this is about the database post Ghriskey will tutorial. And in our next tutorial, we're going to actually deal with post grass ski well, using python, which is that we're actually going to take some values and insert in a post grayscale database specifically using python and its modules. So this is it for the tutorial. Thanks for watching 35. 0905 Dealing with postgresql using python: Hello, everyone. Welcome to this tutorial on data science through python and in this specific tutorial were exactly going to study that how we can deal with post Gransky. Well, using Python libraries. In a previous tutorial, we studied that how we can run basic SQL commands in post Rescue. Well, shell now, this is time to do something regarding python along with Post Rescue. Well, you should be able to decide that what you can do with python programmatically, which could take a lot of time to do that manually in SQL. So the basic agenda of this tutorial arm we're going to discuss about psycho PG to package . I'm going to install it in our machine and we're going to make a connection with the post gray ski well server using Python and Psycho PG, too. And we're going to use the object called cursors in Psycho PG two pythons. So first of all, let's see what psycho PG to is. So I just open the website link for Psycho PG two. And as we read Psycho PG is a post grace cable adapter for the Python programming language . It is a rapper for limpy Cue, the official post grass que well client library. So let me tell you what. Basically, adapters are in h and every programming language. We should be able to connect with the database server. And to do so, the official vendors give these library for connecting with the database server by means of some adapters which we can use in programming languages. In the case of Post Rescue, well, in Python, we have thes package called cycle PG two. So, first of all, we should be able to install it in our machines. If you're using a Lennox machine, basically, you can install the psycho PG to package using this command. Or you can also use a command pip install psycho PG two. We have already covered it. How we can install packages using Pip so it shouldn't be a big deal. The package name is psycho PG to now, in case if you're having some problems while installing the package or after installing the psycho PD to package on the next machine, then you might want to consider installing the package called lippy que hyphen Dev using the standard package manager off your linens machine. In the case of Fedora, it could be Yum. In the case of a Bantu, it could be pseudo a PT. In the case of Mac OS X, we're going to either use Fink package or we can use the Mac ports. So for both of them, the command is relatively easy. However, you have to install it, so you'll have to download those packages which you can download over here. Now, in the case of Microsoft Windows, what were exactly going to do is we can actually use the pip command, but it might run with some problems if you don't have limpy que installed in your windows. So what we exactly have to do is we're going to first click this link Windows Port of Psycho PG to an open it in a new app. Now, depending upon which version of python you have installed on your machine, you either pick 64 bit or 32 bit since I have python 32 bit installed. So I took this one because I have python 2.7 32 bit installed. Therefore, I'm going to pick this one package which has already been downloaded on our machine. So let's go ahead. Now we're going to download directly, and then we're going to enter the command easy install psycho PG and then the name of the file, which we just downloaded and we're going to hit Enter. So the installation has been done. Let's fire python and see if this module has been installed or not. So the module has been imported without any sort of error. So sounds great. Let's do one thing now. I just created an example tutorial for you. Now the next question is, how can we make the connection with the post gray school server using Python in Psycho? PG, too. So I've already prepared a Python script for you so they can do the same. Now let's check this out. Put there. Is this importing of the package Psycho PG two. Now we're going to use the connect method of Psycho PG two module, which takes database name, user name password hosts and the port as the input parameter. Once the connection has been successfully done, you will get a connection object, which you can store any variable. However, here I have stored that connection variable into con. Now let's understand what cursor is. Once the connection has been implemented. We can take cursor object to execute different sorts of commands in Psycho PG, too. So what we can do is the connection object Will return will have a method called cursor, which will return an object cursor, which you can store it in any variable. Now, using the execute command of this cursor, we can run different sorts of SQL commands over that particular database. So what I've done is I have used a d d l for creating a table called user info. And using this, I will create a table with these five fields. Once the table is successfully created, it will print a message called Table Created Successfully. Now, since the table is created, I will use the same cursor to execute yet another command to insert some value in this particular table. So, as you can see, I've inserted one row into this table, and after entering this one row, I have executed a print command as value inserted successfully. So let's go ahead and try it. Here is our script server con dot p I, but before we do, let's open the PS key well, shell and check out if there is a stable user info or not. Otherwise, we might run into some problems. We have already discussed how to establish a connection to the post grayscale server using P SQL Shell, so it shouldn't be a big problem. Now let's list the databases. We have this test database, which we also mentioned in our connection script, so we'll have to be careful about that now. What we're going to do is we're going to use the slash c backslash C Command to connect to this database. Now we have switched to the test database. Let's see the tables over here. There are no relations as yet, so I think we're good to go along with the script. Now let's run our script So the values printed, our tables created successfully and value inserted successfully. It turns out you can see those two methods are executed. And if we make a connection with the database server and switched to database and lists the tables, you can see that there was no error in our code. Still, there was no table created, so this is a common mistake which people usually fall in. Now we're going to take a very important step, which we have to keep in our mind. I intentionally let it be because it should be learned by example Onley that if we don't commit the changes after executing the cursor commands, then there won't be any effect on the database. So once we're done with executing the SQL commands using the cursor, we should use the commit method of the connection, which actually commits the changes and reflects them on the database server. So let's go ahead quickly. Run this again. Sounds good. Now let's see the tables. There is the table and let's see if it has the same values or not. Turns out it has the same values. Now we have went through and it fills it how and as you can see, that the values which you inserted in our python script are successfully reflected on the database and this is it for this tutorial. What I would like you to do is go and find out different methods and functions regarding this psycho PG two and see how you can do different things that create different sorts of databases, objects like views, stored procedure, functions, indexes and execute different sorts of SQL commands to Psycho PG two. So this is about the entire tutorial. In our next tutorial, we're going to actually going to get introduced with the intriguing case study about how we can deal with Post Grad School Python. And in this specific case study, we're going to meet with the problem statement and find a specific solution and implemented by yourself. So see in the next tutorial Thank you. Have a nice day. 36. 0906 Case study: Hello, everyone. Welcome to this course on data science through pythons. And in this tutorial we're actually going to talk about a case study regarding RD BMS system. So this case study consists of a problem. So the problem statement is X Y Z deals in solar products, and they sell their products all across the country to their customers from different countries and states. So far, they have been storing their data in an Excel file. But since growth has exceeded and so far, the sales, therefore they need a concrete data management system with organized data structure. So when lots of organization in firms, this is a very general case study and a very practical one as well because usually from the start with a very low sale and usually a very low infrastructure as well. So usually they don't create complicated software's like database management systems and applications, which access those databases and store the data. They usually start with Excel Ortelli to keep their data, and they usually keep it very simple. But as for the growth and the sales increases, they usually run out of the ease which they used to have in those systems because now the data is increasing. Since the data is increasing, you have to store and manage it in a very concrete system. Could be an rd bms or could be non relational. So what could be the possible solution? I suggest a solution is what we can do is obviously it's sort of a data and data regarding sales, so there will be products. There will be vendors. For example, the product A belongs to this particular vendor and the product be belongs to this particular vendor. For example, Nokia belongs to Microsoft or any other product like Dell's belongs to Dell in photo. So these kinds of masters should be created and master in the form of a table in an RGB mess and stored in an RGB mess like post grace que well, which we recently learned so would be our best option for us. Also the table for specific entities, like how much sales went on, how many customers came. So we need to be able to maintain the customers list and how many actual products have been sold to those customers. And that's all. This is the data that we need to store in the form of tables in our already BMS system so that later they can be fetched using some sort of application or any sort of code. So let's see. Let's have a look at something. I would like to ah show you before we do any sort of structure in soft table. We often have to create an e R diagram like this. And as you can see in this particular er diagram, they basically have products, shops, sales vendors, customers, etcetera. So first of all, before going ahead and creating any sort of tables or masters, you should be able to first keep clear what sort of data you need to define. So even if you don't know that your diagram, what you could do is take pen and paper, draw very simple diagram, and then go ahead with process. Ah, simple diagram like that will also help if you don't have any sort of idea regarding the data which I'm going to show you. Actually, So here's an example, which I've well recently recovered. So this is basically an excel file, which the X y Z enterprise might have to show their sales. So, as you can see, there are lots of entities for example, a dealer's name. X y Z. In that case, and also there's a status four. There is the product name. There is a product merchandise code, and it's also called a vendor's code. And who is the requester? What is the customer's name now? This is the customers entity. What is the address of the customer at center, etcetera? So what? It will be giving us an opportunity to solve this problem by yourself. And most probably most of you might not be able to solve it. So into the discussion forum, there is actually a link for the get hub project for this entire case study. You can go there and find different sorts of materials, which will help you to solve this problem. Also, there's a little bit of code written in SQL through which you can actually execute this entire case scenario. So this is it for this particular case study. See you in the next tutorial 37. 1001 Introdunction with different data sources: Hello, everyone. Welcome to this tutorial on data science through python and in this specific tutorial. Well, actually going to cover what is going to be the main purpose of learning all source of data types like Jason, See SV XML, etcetera. So the main agenda we're covering over here is what is the data transportation and exchange problems, Web server, client architecture, Web services and other scenarios where these sort of data types could be used or useful. So let's talk about the main problem, which is data transportation or exchange, or what is the data transportation exchange problem? Basically, whenever we're on the Internet and we have got lots of points between which we've to transfer data, it could be one one of the PS, or it could be server from client or from client server. So in such sort of scenarios, we actually have to transfer the file. And if the file isn't efficient or lesser in size, you won't be able to transfer it that quickly, which we usually dio. So, for example, let's say if we have Jason XML or CSP, they are optimized in such a way where lots of metadata has been removed so that they're perfect for transporting from one point to another on the Internet. So our first case scenario, Let's talk about Web server client case scenario. It's a very common scenario. You might be accessing lots of Web sites on a daily basis, and you might be having to enter the U URL addresses of them. So what actually happens is, let's say we have a server. Look at some 0.2 over here and we hit the U. R L. And it goes to some sort of http requests and it processes the requests and then it gives us the response. Now, think to notice is actually meanwhile generating the response most of the time it accesses the database. So obviously the database couples and rose are pretty heavy and there lots of metadata attached to it, and we can't just send them over just like that, we often have to strip off data out of it, which is actually not useful while transporting over the Internet. So obviously will have to come up with some sort of data exchange format if it could be actually efficient and exchange over Internet speed. And now also there is one more issue that once it has been exported or imported or to and from the client, the client side technology should be able to process it pretty easily and in a swift manner . So whatever data sources what we've been talking about so far, for example, see SV, Jason or XML, they're pretty efficient in that manner. So let's take a live example. So we have a website. Basically, it's a France based website of real estate agents on what it does is this is basically a search box, and I would like to open the console for monitoring the data packets, and we will switch to the network tab. Now if we go for and search for specific term, we actually see suggestions. You can say that I entered I L L E. It shows me some sort of reasons for suggestion and all. So all these values are actually stood in database and they are not transported as it is. They are actually first of all, converted into some sort of data transport exchange format or something could be something like CSP or Jason. So let's take the network tab over here, and you can see that we have some requests going on over here. So once we check the header of this request, this is basically an Ajax request. And if we check out the response, let's copy it. And if you try to see the previous of this particular response, you can see that it's basically a Jason a key value pair for each and every specific value which has bend returned from the server, which was again stood in a particular database. So even they choose Jason because it's pretty efficient and fast. So this entire framework, which processes the data and serves in a form of Jason service, is called our wrist ap I. But we're not talking about that right now. So the main purpose was to show that these exchange formats are pretty used in most of the scenarios. Now, this is one sort of website We can talk about soap, which is yet another protocol to exchange data between data and server and client. So instead of Jason, this soap service uses XML, and it's also a sort of Web service. So as you can see over here, simple object access protocol and it actually uses XML. So again, XML is also sort of a data exchange format which actually uses quite often between Data server and the Data client. Now let's talk about CSP. Actually, we're talking about once we some sort of data exchange format, what should be the specific attributes of it? First of all, it should be pretty swift and lightweight so that it can be transported from the point quick and easily. And it should also be able to be accessed from a client site in a very easy way. For example, Jason is actually processed by JavaScript, and it is pretty easy to manipulate and so goes with XML. But C s fie actually is just a comma separated value. So we've been talking about Web server and client architecture and how these exchange servers are actually used between Web server and client in the form of Web services. So as we talk about rest a p I, which actually servers Jason in the form of data exchange format so that the client side can easily process it, which one point of view and the other point of view that once thes exchange formats are actually processed on the client side, the ease of how easily they're actually processed also matters. So CSB actually not easy to process because it actually same text file and it might take a lot of a little bit of more programming rather than Jason or in XML. So where is it used? We've been frequently talking about you I d ai website, which actually provides data in form of CS VCs V stands for comma separated values. So why CS fee? That is the main question. We could actually download this entire data through Excel as well. But CSP is pretty lightweight and there is no metta around it. So the good part of it is, let's say, if you have downloaded it some sort of CSP file and the same amount of data is stored in a file, the Excel file would be pretty large comparatively. Now you could say that nowadays there's actually provision where you can store the file in a form of binary format of excel which actually decreases the false eyes to quite extent. But we can do that as well. But again, the point of view from which that particular binary file has to access on the client side that goes in a pretty complex way as far as the binary files are concerned of. Excel. So see, SV is again pretty successful of a here. That is why lots of websites provide their data in the form of CSP. So once they have to provide in some sort of a p I, for example, this French website called Seliger, they do that in Jason. Now let's talk about yet another scenario where CSP quite is frequently used. See, SV is quite frequently used for importing and exporting data from database server. So I've just opened my PHP my admin demo website. It is actually a tool to manage your database of my SQL, which can be sink along with PHP and it is pretty helpful in creating websites based on PHP . So you don't need to go that deep over here. You can actually see lots of options. For example, data piece SQL status. Don't get confused with that. Let's get to the database. Over here there are lots of database. So, for example, let's check one of them now You can see over here there are a few options over here. For example, let's check out the export option the and see SV is also over here, so let's go and download it now. It has been downloaded. We can actually check it. And that was actually not a huge database. So you can go over here and download lots of data, tables and format of CSP, and you can even import in the form of CSP. You can actually select lots of formats over here. Maybe. Why am l xml CS via Jason? But in all of dem CSB will be the most efficient. So this was it for this entire tutorial. What? My main point was to do that The bait problem was a data exchange and data transportation is actually solved by these formats, and they are frequently used across databases Web servers over here. So I hope you found this tutorial. Pretty helpful. See you in the next tutorial. 38. 1002 Understanding JSON: Hello, everyone. Welcome to this tutorial on data science for Python And today we're actually going to talk a little bit about what is Js a win? So Js Owen actually stands for Java script object notation and it is a very lightweight data exchange format which has been frequently used in Web services and rest AP eyes. So actually, it's just a javascript object through which we could actually arrange entities and give them some sort of relationship. One of the examples of J s a win can be seen over here. As you can see, that this actually looks like a Java script object, but it can also be related as a key value player. For example, we have a key called I D. And we have a value called to Same goes for the name and these are the keys. Now, as you can see in this specific case, the keys can also be assigned yet another jessalyn object. So this sort of nesting is pretty much possible. Therefore, it helps to create complex relationships and nest them further on in our next tutorial. What we're exactly going to do is we're actually going to use the Python J. So when Library and process some Jessa when using python. So this is gonna be pretty short tutorial because we just have to deal with one j So when file and go ahead with it. So I think this is going to be pretty easy, and you guys must be catching up pretty nicely. So just go ahead and read a little bit about Jessa went online. See you in the next tutorial. Thank you. Have a nice day. 39. 1003 Dealing with JSON using python: Hello, everyone. Welcome to this tutorial on data science through Python. And in this particular tutorial, we're going to discuss about dealing with Js Owen using python. So the basic agenda of this chapter are basically to First of all, we're going to discuss ah, little bit about the Js Owen Package and Python and then we're going to pass a sample data using this Js Owen library here. We're having actually a sample python file which I just created through the same task. What we have done over here is we have imported a jsa went library and then we have created a string which is actually a Js Owens string. And then we have stored that string in Python's string object. Then again, what I've done is I have created a list of three dictionaries and these dictionaries have key pair values. And as you can see that these key pair values are mentioning the information about an employee and in this case of this Js Owen string, you can see that this waas basically data regarding Facebook. So these air messages, This is the idea of the user name and then again likes and dislikes status created updated time, etcetera, etcetera. So this is a very common format of Facebook data found You can find it on different websites by searching over it. So what we're exactly going to do now is we're going to hit the Python interpreter and see they're what we can exactly do find out about the Js Owen library. So jsa one library is basically having lots of methods and coder decoder, dump load and many more. So for that time being, we're going to concentrate upon two methods that are loads and dumps thes air, commonly used methods used for loading the string off JavaScript object notation data and then converting equivalent python type. How does that happen? Let's see. So if we can see that once we enter this Js Owen string and hit enter, it actually gives me the string of the Java script object notation data. So what I'm going to do is I'm going to use the loads method of Js Owen and passed this string as an object parameter and store the return variable store the return value into a variable called parsed J s a win. Now the jazz Owen has been parsed. Let's see what actually happened into the parsed data as we can see that it actually parsed the entire J so invariable. And it gave me the data and equivalent to the python data types. So let's see, what sort of data types is this? Returned value. This is, of course, our dictionary. Now, let's see how many keys are there in this dictionary. There is only one key called data, so we can see that as well. Again, it dumps the entire data except this upper part. Now, if we check this one out, this is actually a list. So the entire Js own data once converted into an equivalent python data type is actually just a nested list and dictionaries and nothing else. So it could be that there are lots of dictionaries which are listed under a particular list . Now that again, this list is actually nested under a yet another dictionary and so on. So if you want to pass the specific list and dump all of these values, you can again use the for loop and print it so as you can see again, it prints a lot of dictionaries over here, and those dictionaries again can either have single values or they can have some other list as well. So using this combination, we can create a complex combination of different sorts of data. Now let's see, we have yet another Python equivalent data type over here, and we need to convert it to some. Jason went so the name is data VJ. Let's dump. It looks like a list made of three dictionaries. Let's check it out. Okay, it's a list. Now what we're exactly going to do is we're going to use the jazz. Someone dumps method to dump this particular python equivalent data type and see what we get. Now, if you can see it dumps the entire same data. But there is a very basic difference. The difference is that prior to this one, the other object was actually a list. As you can see that the string is actually surrounded by a single inverted comma. So this isn't exactly a list. This is actually a string, and it's in the format of Jason when so let's see what is the tight. So, it turns out, is just so when str however you might find that it's a bit difficult to tell the difference between actual python and this dump Js Owen. The reason behind this is because of the syntax is entirely the same. There could be a little bit of confusion, but you can always use the tight method toe. Find out if it is some data type object of python or is it some Js Owen? So I think this is all over. And the Jesselyn and python Jason when data package. So what we're exactly going to do next is we're going to study a little bit about CSP and more detail, and we're going to deal with it along with the python CSP model. Meanwhile, what I want you to do is to go to different websites and search for Jay so on data samples and maybe parse them and get the values and form of the list and topples. And what you could do next is you can use some sort of arty bms and install the psycho package to and then use it to store those fetched parts. Jessa when and store them into rd bms. This is going to be a little more hectic for you, so you can also check out other sources and just simply download the jazz so and data and parse them on the python interpreter. So all in all, what I want to say is that you should keep practicing, because otherwise there isn't gonna be of any use of this entire concept. So the next topic is going to be pretty interesting. See you in the next tutorial. Thanks. Have a nice day. 40. 1004 Understanding CSV: Hello, everyone. Welcome to this tutorial on data science through python and as you are studying about different sorts of data types and what could be other possible data sources, so in this quest, we're actually going to introduce you to CSP. What C. S B stands for is comma separated values. Now comma separated values are actually, they are basically, let's say, if you have some sort of data and it has to be, it could be in some sort of tabular form as well, so that data can have specific values separated by a comma and yet another rows separated by a new line. For example, if you want to get an example of a CSP file so it might look something like that. So let's just say that this Data's and it's actually the place. And there's this name and there is a specific address, and there is it's legal status. So the issue in some sort of spreadsheets thes fields are actually going to come up in specific columns, and these are going to be the rose. So CSP is pretty lightweight as well, and it's frequently used for importing data into different sorts of data analysis. It works pretty fine on file systems. And it's actually pretty, Yeah, you don't need to have any special sort of code to open it. Any sort of spreadsheet program can easily open it and you can analyze it even for data analyzing. We're actually going to use see SV as an intermediate format. So I think it is very interesting to go ahead and try it out. So this is my specific agenda about CSP. It was a pretty short tutorial. You already heard a little bit about CSP earlier. And next we're going to cover is how we're gonna operate on a CSP using python. So this is going to be a little bit interesting because we are going to import the CSP module of python and do the processing. So I hope you're grabbing it pretty nicely. And all these data sources are pretty actually small to handle and very convenient to program. As in the next tutorial. As I told, we're going to study about dealing with CSB using python, so get ready for and have a nice day. See you in the next tutorial. 41. 1005 Dealing with CSV using python: Hello, everyone. Welcome to this tutorial on data science through Python and today we're going to deal with CSP using python. So this chapter is basically all about CSP, so there are basically two agendas in this particular chapter. The 1st 1 is CSP Package in Python. It's actually a module in python, which can be used for parsing and writing CSP files, which could come in handy in most of the cases while dealing with different types of data. The second agenda is parsing a sample CSP data. So as I've already told you, that CSP is basically stands for comma separated value, they're basically values which are separated by a specific delimit er by default, which is a comma. Otherwise, it could be any other delimit er, but just in case, if you're specifying any other delimit er, then you have to explicitly mention in the python library. Otherwise, it might cause an error. So let's talk a little bit about CSP module in Python that so the CSB module in the python is basically having lots of methods, which could be frequently used for parsing and writing CS fee files. So I have created a Python script for the same task. What I have done over here is I have downloaded the data from W H O. And it's in a format of CSP. So basically lots of organization and websites provide your free sample data. For example, we talk about the organization in India which generates the at her cart. It provides you a lot of varieties of data regarding those at our cards in CSP format. And if you remember, in our previous tutorials, we even fetched one CSB file from the website and we parsed it. So for the time being, what we're exactly going to do is this particular script is we are going to put the CSP module. Then there is one method called dump past data. What dumb past data does is I have stored a file called C S V data sample, which is a data downloaded from wh a website, and I have opened it in the read binary mode. Now, if we recall that in our tutorial regarding the dealing with files, we actually learned that how we're going to use the with keyword with the file handler and then read the string. So we're going to do the same over here, but in this case, we're going to parse this file string object to the CSP reader. Now the CSB module contains the method called Reader, which actually reads the file string and then loads the entire data into yet another object . So we have stored the data into an object called reader object. Now we're parsing this object row by row and then printing the row and just to identify what sort of data is there in each row. I have also printed the data road type, so I think it sounds pretty easy now. In the next method I have done, I have created a list of yet another list. And then I have used the CSB right method to write this list to a sample CSP file. So let's go ahead and run this script. So here we are. For the time being, the CSP module is loaded and the method dump parse data and right list into CSP are also generated. So let's hit the dump past data method. As you can see, it's pretty long file, but you may also notice that after dumping each and every row, it also dumps the type of particular data type, which is there in each and every roll of the CSB reader. So as you can see, it is basically a type list, and you can see here that basically the list which is actually mentioned as a row in a CSP file. So if you want to see the CSB file, you can actually go over here and check this out. So here's the data, and it's certainly pretty long, and that same data is dumped into the console. Now, you could take this data and use it for different purposes May be some sort of calculation . Or maybe apply yet another data analysis module over here, which we will study in future tutorials. Now let's go into another method, as you can see, that there is yet another method right list into see SV, and we're going to execute it. And once we have executed, there is a file created called Sample once we open it. So here is the same data which we actually had in our Python script and which is now return to the This is actually the CSP file, but it can be open and excel, So this is pretty easy. And if you want to find more about the CSB module, I would like you to go to the official documents off python and check for the CSP module. And there are lots of methods mentioned over there and I would like you to implement them on your own so that you get a better grab on this module. Our next tutorial is going to be about understanding XML and dealing with XML using python , which is going to be pretty simple as CSP Js Owen or J saw. But we will use yet another module called beautiful soup. You can also use l xml. But for the sake of simplicity of this tutorial, we will discuss the module called beautiful Suit. So I hope you're interested for the next tutorial. And I hope you grabbed everything in this particular tutorial about see SV and would be interested in willing to explore more about it. Thank you. Have a nice day 42. 1006 Understanding XML: Hello, everyone. Welcome to this tutorial on data science through Python, and today basically, we're going to talk a little bit on XML Files. XML basically stands for Extensible markup language, and it's pretty self explanatory that what it does XML stand for. Actually, when we try to define a some sort of data source in XML, what we actually do is we create lots of tags, and when we create tags, we actually define those tags. Unlike in HTML, their pre defined tags and an XML, they are actually weaken do sort of nesting along with tech and create our own tags to define the elements and their attributes. So if you want to see an example, the example from the W three schools is pretty standard one. So let's say we actually called a tag called CD. This is a preformed tag or prevail herbal tag, which actually is made by us on Lee. And yet this title, another tag, is inside a tag and a couple of tags later, we can actually have some sort of attributes Over here is well, so let's say if I go to yet another X m l and I probably I can see over here is that their description is pretty long and it's still nested inside the price or below the price, and the enter tag is again nested inside their fruit. So this is basically how an XML is formatted and that syntax basically starts with a root element, and then the nesting of the tags goes further on, or it can follow a specific order. We can even put some attributes like we do in HTML over here, and those will be defined by us on Lee, not defined or anything else along with it. So XML is basically used in soaps services, but it actually comparatively stronger than Jason. Therefore, it wasn't it didn't get very famous, however. Still, few people use soap surfaces, which actually uses XML. XML is also used in different scenarios where you have to keep configuration into some sort of definite tags. So whenever the basic use of XML nowadays are to keep the configuration of a particular set up or run your software system or still used in soaps, services and many more things. However, in Python, we actually have an XML module and XML module as well. But in our next tutorial. We're actually going to deal with Python using yet another HT mail parcel called beautiful soup, which is actually pretty able to pass the exit. Melas. Well, because XML s also and a sort of having tags and attributes same like HTML. So as in our next tutorial, we're going to do a lot of dealing with XML Python. I hope you're pretty excited about an exit or Eolas. Well, so see you in the next tutorial. Thank you. Have a nice day. 43. 1007 Dealing with XML using python: Hello, everyone. Welcome to this tutorial on data science through Python And today we're going to talk about how we can deal with XML data using Python. In our previous tutorials, we already talked a lot about XML data and see what it exactly means. The XML, as we know, stands for extensible markup language. And what sort of library can be used in python to process this XML file and get sort of informations from them? So there are basically two agendas over here First is that we're actually going to talk about beautiful soup package in python and we're going to pass the XML in our example to get the data out of it using beautiful soup. Let me mention that if you are coming from a python background and you might have seen a couple of other modules that could be on XML or L XML, they're pretty neat as well. But for keeping this tutorial pretty simple and to simplify the entire idea of parsing XML , I have used the beautiful soup instead of XML or L X amount. So to do the same, I have created a script as well Let's head over it and As you can see, we have a file called XML data example dot xml in our current directory, which is over here. So it is actually basically a collection of catalog items and catalogues. So what you can see over here is there are tags for catalog items and their tags for product. And there are tags for other tags as well. For example, price, size, color, swatch, etcetera, etcetera. So what we actually do in this particular tutorial is again with the keyword. We open a file and read it in a binary mode. And using that string, we passed through the beautiful soup object of the beautiful suit and that beautiful soup returns the object and we store it in a variable called soup. And then, using that particular soup, we find all the elements inside the particular XML file which are called catalogue and dumped them. Now, let me tell you what sort of parse er is beautiful suit. Beautiful soup is basically a d o M B sparser, which parses the XML and creates a document object model. What document object model means is that the entire elements of the particular XML are now arranged in a document, and each and every document has a set of objects in a particular hierarchy. So, for example, if I run this script what we're going to get, let's go ahead and find out. Okay, so I run this particular code in an interactive interpreter De bugger. So we have the soup object and we can check it. Now let's say if I want to go for a specific tag called Price, So what I'm going to do is I'm going to use the find all method. And as you can see, once we enter this particular method and gave it a parameter called price, it returned me a list of all the tag elements, which does not have the tag name as price. Okay, so it sounds pretty neat. Why not get the actual price inside the price tag? That could be more useful. Let's take this loop and let's take this list and parse it through four loop. Now we're going to use a method get text, which, actually what what it does is for each and every beautiful soup object. There are set of methods which we can use, for example, to get the text inside this particular tag we had to use the get tagged method sounds good . Now let's dump the soup again and look for other important things. For example, as you can see, there are tag elements called size. Let's try to dump them and see what do we get so we get a long list of sizes. Now let's say I'm not interested in all size tax. I may be interested in Onley those size tags, which does have a description as medium. So what we're going to do is this is the final method, same as it was. Apart from that, we will take the name of the attributes and parse it the value of the attributes and, as you can see only the size with the description as media is dumped over here. So apart from that, let's say if I want to dump the values of the specific attributes, which I don't know, then what are we going to do? So as we're talking, let's try to dump the sizes of all type and print their descriptions. So for that, we're going to first of all, a trite over this particular list, which the final method returns for all those sizes and then for each and specific list, we're going to print actual value using the get method. So here are this way. We're going to actually get the description of that particular size. So let's try it. So as we can see that all sort of descriptions for the size are printed over here, So it seems pretty easy. And that is the basic reason that I didn't introduce XML and L XML so far. But in our future tutorials, we're going to talk about those modules as well. So what I would like you to do in our future modules we're going to use extensively this beautiful suit module. So what you can do is you can go into the website of beautiful soup and try to find their examples, use them by your own and have fun with them in our next tutorial. We're actually going to deal with Excel data, which is quite interesting because we have seen lots of Excel data and we come across them very frequently, and we might want to automate a lot of tests regarding them. So I think you would be pretty excited about a next tutorial and you had a lot of fun in this tutorial is well, Please go ahead and try this particular model. Beautiful soup on your own and get ready for the next tutorial on Excel. Thank you. Have a nice day. 44. 1008 Understanding EXCEL: Hello, everyone. Welcome to this tutorial on data science through Python and in the specific tutorial, we are actually going to talk a little bit about Excel. Microsoft Excel is a spreadsheet program created by Microsoft in its Microsoft Office package, and it basically stores data in a tabular form. And it's sort of pretty much is able to do lots of various calculations in a pretty fast manner. So the general format in which the Excel stores its files are basically XLs or XLs X. So in corporate scenarios where there are lots of cases where actually the data is stored in excel and you have to get it out. That is why lots of programming frameworks have module and data libraries to connect with those Excel files and manipulate them and do calculations on them. So what we're going to do in the next tutorial is we're actually going to use Python and it's module X, L W T Excel RD. To operate on those Excel files and extend their functionality further. So I think everyone is already aware about the Excel format pretty well. So that's why I'm not going to take much time on this video But still, if you have any questions, you can discuss them on the discussion forum, and they will be answered as soon as possible. So, however, we're going to have fun in our next tutorial because Excel, wt and Excel rd are pretty cool modules that give full and entire functionality over excel . So I hope to see you in the next tutorial till then. Thank you. Have a nice day. 45. 1009 Dealing with EXCEL using python: Hello, everyone. Welcome to this tutorial on data science through python, and basically what we're exactly going to do in this chapter is we're going to deal with some Excel files using sump icons. Specific modules. Basic agendas of this chapter are installing Excel, WT, Excel Rd and Ex Utilities Package. Parsing the Excel data using Excel Rd Package and running into Excel data using Excel WT. Package. So let's talk about the installation of these packages. If you're on a Lennox machine, you can always use pip, and the same goes with each and every package of python, which do provide pip by default. So for Windows were going to do the same thing, which we will do for Lennox or Mac, we will go into the shell. We will go for the pip install, and we will write the package Excel RD, followed by Excel WT and then Excel utilities. So as you can see that since I've already installed these packages, they say that requirement already satisfied. But in your case, what will happen is it will download the package from the online repository and install it on your system. So what we're exactly going to do now is I've created some examples. So let's talk about this first example regarding the XLR d example dot p y. So what I've done in this example is I have first of all imported the Excel rd package. Then I've created workbook using the X LRT open workbook method. Now, in this method, we have to specify the name of the existing XLs file. So since I have downloaded this file and this is my current directory, I'm actually what I will do is I'm simply going to provide the name over here. Otherwise I would have to give the full absolute path of the XLs file. Now, since the workbook is created, we're going to dump the sheet names over here. So for the sake of completion, let's side print here is Well, now what we're going to do is for the specific sheet that is on our first index. We're going to get that sheet by its name and get the reference of that sheet in a particular variable called current sheet. Now we have that particular sheet in which we have the specific data. What we're going to do is we're going to dump the data off Cell four, comma four now, first of all, we have to remember that first the row comes and then the column. Now you might be wondering why I have written data of Column five and Row five cell over here, and then I'm entering parameters as four comma four. So to clarify that actually the index starts with zero in this row column indexes. Therefore, we had to subtract it by one before entering the actual index. So it sounds pretty clear, and this is it to access the particular cell we have given the row and column index and dot value is for fetching the value Now for what we're going to do with were actually going to parse through all the cells, which this particular sheet does have and print their values individually. Now, see, over here I have used current sheets dot en rose variable. What this variable contains actually is it contains the number of rows in that particular sheet by default, and the same goes with the dot in coal, which is pretty self explanatory. It actually takes the number of columns sheet and prince it. So what we have done is we have taken the 1st 4 loop, and we have created a sequence of numbers for the entire number of rows current, particular she and so we go with the column index, and we generate the sequence of all the column integers indexes. That's possible now. What we have done again is we have printed the current sheet dot cell for each and specific row and column combination. So it could be a reason that for some values, they may have some Unicode errors. Why they have a unicorn error is because since the data is supposed to have at any time, some sort of Unicode value. And since we're dumping the data on her consul, which doesn't support Unicode values, then therefore there might be a couple of errors. So, having said that, let's try to run this particular example and see what do we get? So actually, it's a seven MB actual file, so it might take a little bit of time for loading. Now, as you can see, the value of each and every cell has been dumped over here, regardless of what index they had. So there are lots of other stuff you can do along with Excel RD. But that will be out of the scope of your course, and we will keep it concise and just discussed the methods which we actually have for this time. What you can do is you can actually go to the interpreter, export the XLR d by yourself and then play with all the variables it does have by listing all the methods using the Ire command. Now let's go to the Excel wt. Example. Excel W T stands for Excel Writer It's pretty explanatory. What you're going to do is we're actually going to create a workbook. In this case, we actually don't have a workbook, so we'll have to create one. So we create a workbook. Then we add sheet called first Sheet, and four will generate a range of 1 to 100 numbers. And then we'll call that each range number and we're actually going to first of all, right on the left side as the particular number. And on the right side of that particular number, we're going to write it square. And once the sheet that right method is done with all the numbers between 1 to 100 we will save that particular template in an XLs format and print message called XLs File generated successfully. So it's been all simple and straightforward. Let's go ahead and try to run this particular file once I run it. As you can see, it already printed Excel File generated successfully. Now let's try to cross verify it. Here we have a file called 10 dot XLs. So what we're going to do is when I go to the particular filed called 10 and open it So as you can see, it starts with 11 24 39 printed the square root till 99. So it looks pretty easy. And it worked out pretty neatly now regarding Excel WT. Actually, there're lots of methods which does a lot of self formatting or adding style or color or lots of other stuff, which you could do with excel. WT. So what I would like you to do is go ahead, explore the Excel WT package and by your own means search four. The specific methods which actually style the cell element or maybe removed the value errors, etcetera, etcetera. So I think this is it for this tutorial, and we have covered enough ground to process the Excel and other data sources as well. So by this time, I think you would be a little bit confidence about different sorts of data sources and processing them with Python. If you're not, then don't worry. What you just got to do is keep a little practice on other data types sources, and once you're comfortable with it, you can try out other modules as well. So let's talk about what we're exactly going to do after this tutorial. So in the next tutorial, we're going to deal with a case study regarding this particular chapter, and let's keep it at a surprise for the time being. But we'll have a problem statement and arrive to a specific solution. So I hope you'll be pretty excited about the case study we're going to face next and see you in the next tutorial. Thank you. Have a nice day 46. 1010 excel processing 1: Hello, everyone. Welcome to this tutorial on data science to Python. And in this specific tutorial, we're actually going to do a little bit of exercise along with Excel in Python. So I guess you already have Excel format and to process with Python in our previous tutorials. But in this particular tutorial, we're actually going to take an Excel, which will be having multiple worksheets. This is the Excel file called Branch Underscore Ex employees dot Excel SX. So if I open it, you can see that are multiple sheets over here. The 1st 1 is branch one. The 2nd 1 is Branch two, and the 3rd 1 is branch three. So it could be taken as a simple case scenario where there is a particular company called X Y Z, and it has multiple branches spread across different countries or reasons or whatever. So each of the branches has employees, and those details are actually stored in this particular excel. So what we want to do is we actually want to come up with something like this. This is an output dot XLs. So, as you can see that all of the data which was spread across the previous Excel in different worksheets. Over here it's segregated in just one worksheet and saved as a workbook. So how will you do that in Python? Let's have a look at that. So first of all, let's have a look at the code again. We're using the XLR D and Excel WT modules, which are currently hope that you might have already installed so XLR d and excel W t Now what we're going to do is XLR D that stands for Excel read. We will use the open workbook method to open the particular XLs file, which will be used as an output. And we create a list now traverse through all the sheet names which that particular workbook has in this particular line. And one by one, we take all of the sheet and process their cells and columns and upend the data in data list. Now, once this process is actually done, we will just create another workbook using the Excel wt that stands for Excel right and store the difference of the object in a variable called new underscore W B. Now, in this particular workbook reference, we're actually going to use the method. Add underscore sheet, which actually adds the sheet to the newly created workbook. Now we have a sheet called sheet Work added in this particular workbook, and its reference has been stored into new underscore sheet. We're actually going to process the data list, and we're actually going to store the data list data into this particular workbook and thus save it with the name called output dot XLs and then print a message that she created successfully. So before I do that, let's switch through a command line and delete that output dot XLs just to make sure seems like the file is still open. So let's close it over here now. Once it's closed, let's delete it and check it if it's there or not. So as you can see that the output that XLs is actually not over here anymore, So let's try to run this particular file process worksheet dot p y. So it seems like the command and the entire program ran successfully. Let's check it out. The output that XLs seems to be there. Let's open it and see if it actually worked out in the same as we expect it or not. So yeah, it worked up pretty nice. And over here, we can actually see all the values. Now, you might be wondering that in our example worksheet, which was used as input, we actually had these headings name, age, destination, salary. And they're actually not over here in our output. So that is actually not a mistake or a bug, But I've introduced this particular problem intentionally so that you can try to resolve it on your own. So I hope this is a pretty intriguing idea. And it gave you much more in depth knowledge of how to process the excel sheets using python, XLR, D and Excel Wt So thanks for watching this particular tutorial. See you in the next tutorial. Thank you. 47. 1011 Excel Processing 2: Hello, everyone. Welcome to this tutorial on data science through python and in the specific tutorial, we're actually going to talk about how we can process excel, files using python in a more detailed way and apply styles and do lots of other operations along with. So we have a very simple case scenario, X Y C Enterprises, which actually has a bill format like this, and they keep different fields over here and here and here. And as you can see, the format, a few of the fields are actually in bold and colored, and the entire format has to be kept whenever creating this particular Excel using excel. WT So how are we going to do that? But this is not We're actually going to do one more thing. We're gonna have a male like this which will actually be having the entire details off all the clients or customers who actually bought those products and per row. We actually have to create a bill and how you actually I'm going to do this. We have this merchandise code for each and every product, which is very common case scenario, because whenever you buy a product, we actually have a merchandise code and our merchandise name as well. So we're going to arrange this particular Excel file of thes bills, first of all, by Branch. Then buy merchandise code and then byproduct name and how it will be done. That's first of all. See the output. So for the time being, as you can see, there is no other folder over here. And let's see, in the particular file, we actually have this file off 11th March 2015. Just keep that date in mind because we're going to generate a folder over here over here, which will contain the list of all