The world of Python

Automatic Summary

An In-depth Look into the World of Python

In this article, we will explore the essence of the Python programming language and why it is garnering more attention compared to other languages. We will delve into how it focuses on developing solutions instead of just dwelling on code syntax, a feature that makes it popular among developers.

By the end of this article, you will understand the various applications of Python, why you should consider learning it, and a fascinating story that emphasizes its significance.

A Snapshot of Python

Python is a high-level, object-oriented language that supports diverse applications. If we were to concur with some tech enthusiasts, we might as well describe Python as a world that functions better without braces.

But why Python and not other languages such as C, C++, Java, or JavaScript? Python offers the following unique benefits:

• The language is easier to learn and use, but largely this depends on an individual's preference.
• Python ensures clear and readable code.
• Python focusses on solution-oriented development rather than syntax.
• Python enables you to write fewer lines of code and do more, which enhances productivity.
• Python is versatile. You can use it in different applications like web and game development, data science and data analytics, artificial intelligence, web crawling, and embedded systems, amongst others.

Next, you may want to accompany us to our warm-up exercise involving short questions, where you can test your knowledge on Python. Let's keep the interaction lively.

Web Development Using Python

Python is an effective language for web development. Some popular frameworks include Django, Flask, and web2py, with Django and Flask being the most popular.

For instance, websites like Instagram, Mozilla, Pinterest, Air BNB, Netflix, Uber, Samsung, and Patreon have incorporated Django and Flask into their development.

We then have a practical exercise using the Google Translate API to build a translator that converts English text to Spanish text. For this exercise, we use Python request libraries and codecs libraries.

What top websites say about Python

Various high-ranking websites have nothing but praise for Python. For instance, YouTube appreciates Python because it is easy to maintain and more fun. Industrial Light and Magic laud Python's ability to handle machine learning and deep learning tasks.

Python in Predicting House Prices

In the next section of our story, we use Python in predicting house prices. Our model involves using the Linear Regression model. Two methods of prediction are applied; Multivariate regression and Independent variable regression.

In conclusion, the prominence of Python is justified. Python continues to dominate the development space because it makes developing solutions easier, more efficient, and faster.

If you have questions about Python or want to know how you can start your Python learning journey, feel free to drop your comments. Your feedback is important to us as it helps enhance our audience's experience.

Code snippets, suggestions, and corrections are also welcome. Let's continue learning together and taking advantage of Python.


Video Transcription

OK. So uh let's get started. So I'll be speaking on the topic, the world of Python.Uh uh So uh what my talk will uh consist of is how Python uh like other languages, not just focuses on the syntax of the uh code, but focuses more on how we develop the solution and how clearly and readable is the code. So, mm, you can uh uh visit the slides and collab file the codes which I I'll be using through this website. If you want, if some of you want to follow along, you can uh you know, create the copy of the collab file and you can call like we can go together. I'm waiting for a half minute so that if anybody wants to open the slides of the coal, they can in, in the other tab. OK. So let's move forward. So what exactly is Python as someone has already said, l better without braces? So why not agree to that? Uh Python is uh uh Python is uh high level uh high-level language. It's subject object oriented. And uh yeah, it can be used for um like various application. We'll, we'll see each of the application in the upcoming slides. And yeah.

So uh uh why Python, why not some other languages like C C++ Java Javascript? And there's many more, right? So here are some of the reasons why you should be learning Python and uh uh and, and you know, um not some other languages, but uh it's like more dependent on the individuals, like who, which languages resonates with the individual. I'll share an interesting story at the end.

So yeah, uh we um as I have already uh discussed how Python focuses more on the de uh more on developing uh solutions rather than focusing on the syntax, the same thing which we can write in Python and few, a few lines of code, suppose uh two or three lines of code, the same code requires um like in some of the some of the other languages, we need to write uh the same code for the same thing needs to be written in 10 or 15 lines.

So, yeah, it's better and it's more clear we can uh use Python for different applications like web development, game development, the data science and data analytics. Um And there are many uh uh you know, so Softwares with support big data analysis on using Python like Apache spark.

And um many of there's so many more and artificial intelligence like we can do um machine learning, deep learning or um we can use Python for reinforcement learning as well. Web crawling is a very good example, like web crawling. Uh, uh, almost every website websites even Google uses web crawling to crawl and rank, rank the searches according to the, um, according to the data which they crawl. So, yeah, the Python can be used for web crawling as well. And we can also, uh, use Python to program, uh, to create embedded application which can be used for embedded system as well. So your next. Ok. So before we move forward, let's have a quick warm up exercise. I'll in this, I'll be asking some uh, questions and you have to, um, put in the answers in the chat options and let's see. Ok, so yeah, here's the first one you can uh answer them in the chat option. I'll be waiting for a half a minute on this line. Come on, you can answer them on the chat option and, and please let me know if the phones are visible. Ok. So I've got a few answers here. Yeah. Uh Lipin Lani. Yeah. So are you ready to see the answer? Ok, let's move forward. So, yeah, this is the answer for, for who I've guessed right? Has something. Ok. So we'll move forward to the second question. Hi.

Anti, you can answer the, this question, same as the first one you can answer down in the chat options. I'm waiting for half, half minute here as well. Hi, Jennifer. Hi, Nikita. Ok. Should we move forward? Uh I haven't got answers. So OK, let's move forward. So the answer for this one was zero. OK. Then the third and the last one, are you, are you guys ready for this? Let's see. This is the last question for warm up. Then we'll move forward to different technology stacks and how we can use Python for web development and machine learning. Yeah, I'm getting some answers. Keep answering. We'll see the answers in a moment. OK. So should we see the answer? I got few answers in the chat option.

Yeah, you have few of them have guest to, right. Yeah, this is the answer. Let's have a small celebration. OK. We'll move forward to. OK. So we can use Python for web development as well. There are many frameworks like uh Django and uh there's micro framework like Flask and then there's portal web two pi and others as well. Django is the most popular one and Flask too. There are many websites which are um you know, many websites which uses D Django to develop some of its features. There's uh you can see in the slides as well, Instagram, Mozilla and Pinterest. And then uh some, some of the websites use flash for, for developing its features.

Uh There's Air BNB, Netflix, Uber, Samsung, Patreon. And there's many more uh you can, you know, develop the pa um website choosing Python and then it supports CML, CS S and javascript for front and you can use up in front and, and yeah. OK. So as we are talking about web, I mean, let's let's just implement a small uh small code using API. So in this one, we are going to use Google translator API to build a translator which converts uh English language, test text to Spanish language text. So are you guys excited? Let's move forward. So yeah, here I have used Python request libraries and codex libraries. As, as you can see here, I have uh taken a source as English language and target is Spanish language. And here is a query which we, which we want to convert from English to Spanish. Here I have created a function. What it does is it takes a query and it converts all the special characters to its uh to hex code so that it could be taken as input to the uh Google API. We move forward and we have called this fun create query function with the argument query which we have taken. And then uh payload is just a combination of our query target and the source languages. And then I have created a function, translate it.

Uh It uh what it does is uh takes the U endpoint, Google uh Google translate endpoint and takes the header I have, you know, hidden the API key you can get, get your API key through rapid API or, and you can also test the same API if you are following along then uh you can uh you have the code and on Google collapse in the uh end section.

And here it calls the que, it uses the Python request library and it po uh it uses a post function with the, with this URL and the payload that we have created and it returns the status code and the response text that we are getting from by hitting the um API. So yeah, it's converted uh convert our text from English to Spanish. We have called that function with the uh with our payload and we are getting the status code and text and I have printed, just printed it here so that we can see the state. We have got status code as 200. That means our API call was successful. And then we have got the um I've got a translated text here. I don't really know how to, you know, read Spanish but yeah, it's something ola to do something. OK? Um This is uh this is uh the uh percentage of view how project like this is the projection of views that stack overflow answers have got over the over over a month and how it has, you know how it's going to increase the, you can see the graph of Python. It's, it has been over increasing, increasing over the years and how um how, how you know um some languages graph for some languages have been depreciating. Yeah, most, most common reason for this is Python has, uh uh you know, we can write uh more code in less, lesser time and the code is more readable because every time we work on organization, uh the teams keep changing and uh one team has to work on the codes written by other, other person.

And uh uh uh um so, and not every time the quotes are well documented and has uh come. So, yeah, lets more power. So, here's what the top website has to say about Python. The source of these codes are from python.org. And you can uh you uh python.org has the documentation for Python and everything you, every time you need to, you have fa you face some issues in something you can visit the python.org uh website and you can um refer to their documentation. They have good tutorials as well, you can view them and you can generally learn a lot from the, there's um uh there's uh well, there's also links to a famous book of Pythons in the, in the document in the python.org website. And then, OK, so, yeah, so what youtube has to say about Python, most of these website, the website uses Python for developing some of the features because uh uh it's more maintainable and uh uh yeah, it's more fun. So, here's what industrial light and magic has to say. Python is also used for, you know, machine learning and deep learning task extensively. Most of the, most of the libraries are well developed and there's, and there's very big community of developers which uses uh uses these uh Python libraries. And, yeah, because in the most of the cases, uh we cannot, you know, create uh create the each code from scratch, we need a community so that they can uh help and uh uh uh help to debug.

I mean, um uh if you are facing some issues, they can, you know, help us and then we can learn and move along together. So here we will be uh performing a small um small uh uh uh coding, coding tasks. And uh using the Python will be predicting house prices using linear regression model. So if you guys have any question, you can uh um uh put them in the chat option. I'll be waiting for a few minutes here. OK. V so, so um so I have mentioned it earlier as well. If you want to follow along, you can um you can go to the collapse section collab file and you can see this in the top section. OK. So here are all the imports that I have used. I've used uh pandas and Esker Namai mat plot for plotting the plotting the graphs. So mm so I, I have taken a housing data, data set and I have read uh read it using pandas and stored it in a data frame. Then I have uh in the next slide I have uh printed the few top few uh rows of the data set. As you can see, we have different features like longitude latitude, uh housing, medium age total rooms, total bedrooms, et cetera in the data set. And then, and then uh we have uh median income ocean pro proximity and other features. You can see all the features here and we'll be predicting the house house price using the using all these features. So here we'll be using prediction.

Uh We'll be doing prediction using two ways first, Multivariate uh using Multivariate regression. We'll be using all these features to predict the house price. And then we'll be using uh uh middle income, just medium income and predicting the house price that is uh predicting the house price using one IND independent variables. So before we move forward, we have seen like that in the last time we have seen the total be bedroom columns has some null values in it. It uh as you can see all the, all the data set, all the features have uh 20640 values and total bedrooms have 20433 values and the rest of the values are not. So before uh training our linear regression model, we need to uh have uh preproce uh I mean um remove the nerve values and have some values there so that the results are not, not misleading. So we are just here rechecking if uh if uh any else, any else column has uh null values. So I have done it here.

The next slide I have uh in the next slide uh the I have taken the total bedrooms column and I have filled all the null values but the mean of the mean of that column. And uh uh and then we have ocean proximity uh ocean proximity value. It has categorical value. All the value, all the values you can see here all the value, all the features have uh in integer values and float values. But ocean proximity has object values, we need to know uh encode that categorical column. And yeah, so we have done it here using label encoder. And then I have just checked the shape of our data data frame, a smoker. So before uh before uh you know uh training the training the linear regression, we have to normalize the value I have used min Max scaler for this task. And um and this is how we uh we get the scaled value from the original value. It uses this uh uh transformation. I have uh the transformation here. And then it uses the transformation to transform the input data and get, get us the scale value. Then I have just checked the shape of our features and target variable. Then I have um then I have the uh train you, you train the Lear regression using a training set uh and uh uh tested it on the test set here. I have trained the linear regressors using crane data that is Xtra and Y trainin.

And then I have predicted the house prices value that is Y using the test data. Then I have calculated the mean squared error using, using those values. Here, we have got 0.214. No. OK. If you have any questions, uh you can put them in the chart section. OK? And after this, I'll be uh predicting the house values using uh, um, one independent variable that is median income. OK. So, yeah, I have, uh, taken the T FX which is, uh, which is median income uh in the D FX data frame. And then we have the target values that is house prices values in DFY. And then I have, uh, splitted them into test and train data set. So we're here. Uh I have, you know, again, um, fitted the linear aggressive with train data set and then I have predicted the house prices using X test values. And in the same way, I have calculated the means squared error. This is the plot of I predicted value. We have used median income to predict the house prices. And here is the fitted line cleaner address line, which, which is used to predict the prices of the house. OK. So this was the end of the session. If you guys have any questions, you can put them in the chat option and I'll be happy to answer them.

But, you know,