Ultimate Python Masterclass | John Harper | Skillshare
Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
48 Lessons (5h 53m)
    • 1. Introduction

      1:53
    • 2. Maximising learning

      2:12
    • 3. Installing python

      6:01
    • 4. Jupyter notebook

      8:38
    • 5. Practical projects

      5:34
    • 6. Print and input

      6:37
    • 7. Common data types

      8:05
    • 8. Commenting

      6:10
    • 9. Practical 1

      2:08
    • 10. Solutions 1

      11:20
    • 11. Comparison

      8:56
    • 12. If else

      10:25
    • 13. While loops

      12:41
    • 14. Lists

      10:32
    • 15. For loops

      8:57
    • 16. List comprehension

      1:35
    • 17. Cool things neural nets

      2:48
    • 18. Practical 2

      1:53
    • 19. Solutions 2

      17:56
    • 20. Basic functions

      13:44
    • 21. Implementing functions

      8:41
    • 22. Import modules

      9:32
    • 23. Practical 3

      1:30
    • 24. Solution 3

      14:09
    • 25. Open read write

      9:55
    • 26. Practical 4

      1:22
    • 27. Solutions 4

      9:21
    • 28. List slicing

      9:59
    • 29. Sets and tuples

      7:58
    • 30. Dictionaries

      7:31
    • 31. Practical 5

      0:55
    • 32. Solutions 5

      12:40
    • 33. Lambda

      6:01
    • 34. Map and filter

      8:55
    • 35. Generators

      2:29
    • 36. Decorators

      6:42
    • 37. Rcursion

      2:20
    • 38. Practical 6

      1:16
    • 39. Solutions 6

      9:53
    • 40. Classes

      7:37
    • 41. Inheritance

      6:51
    • 42. Practical 7

      0:21
    • 43. Solutions 7

      8:44
    • 44. Github

      3:20
    • 45. Resources for growth

      3:14
    • 46. Learning summary

      41:16
    • 47. How to continue improving

      1:28
    • 48. Any questions

      1:08
15 students are watching this class

About This Class

Master practical python concepts and fundamentals

My course does exactly what the title describes in a simple, practical and relatable way. I help you to grasp the fundamentals of python with live coding, practical examples, projects and quizzes, moving step by step through beginner and then intermediate concepts - getting you to the point where you are ready to being a career in python - to apply the foundations of python into real life projects, such as games, websites, data science or AI.

Why you need this course

Coming to grips with python isn't always easy. On your own it can be quite confusing, difficult and frustrating. I've been through the process myself, and with the help of my peers and mentors I've quickly become a proficient python developer. I want to share all I've learned with my fellow python beginners, developers, AI aspirers. My inspiration comes from believing that, if taught effectively in a carefully planned and considered way, the vast majority of people will be able to master python..that's why I've created this course.

What you will get out of this course

I will give you straightforward examples, instructions, advice, insights and resources for you to take simple steps to start coding your own programs, solving problems that inspire you and instilling the 'developer's mindset' of problem solving into you.

I personally provide support within the course, answering questions and giving feedback on what you're discovering/creating along the way. I don't just throw you in at the deep end - I provide you with the resources to learn and develop what you need at a pace to work for you and then help you stroll through to the finish line. Studies have shown that to learn effectively from online courses tutorials should last around ten minutes each. Therefore to maximise your learning experience all of the lectures in this course have been created around this amount of time. 

My course integrates all of the aspects required to get you on the road becoming a successful python developer. I teach and I preach, with live, practical exercises and walkthroughs at the end of each section!

Cost effective learning!

As a professional AI developer I have over five years in Senior positions in software development and technology entrepreneurship, with experience in tutoring and creating online courses, catering to thousands of students. I've been trained at Cambridge University and the prestigious Pi School of Artificial Intelligence in Rome.Face to face I charge $50 per hour for a student. To complete the curriculum that I offer it would cost them between $1,000 - $2,000.

To reach more people than I could face to face I decided to create this course.

Who this is not for

This course is not for anyone looking for a one-click fix. Although I provide you with a path walked enough times that it can be a smooth journey it still requires a lot of time and effort from you to make it happen. If you're not interested in putting in your energy to truly better yours skills in python then this may not be the right course for you.

What materials are included?

The majority of my lectures I have chosen to be in video format so that you can hear me and see me live coding when we're going through each and every area of the course.

Aswell as the course lectures, practicals, and quizzes the course will soon also offers my full support as an instructor to answer questions, provide feedback and support.

I will be constantly adding more content and resources to the course as time goes by. Keep checking back here if you're not sure right now and feel free to send me a message with any questions or requests you may have.

Transcripts

1. Introduction: welcome to the ultimate python masterclass. I'm very excited to be teaching you all the fundamentals of python and to get you programming and creating your own practical projects. My aim is by the end of this course, you will be confident and proficient in all of the fundamentals of python programming. Not only we have a strong handle on all of the concepts. I believe you have a practical understanding, an intuition on how to implement all these concepts into real world situations. The optimal learning time is between five and 15 minutes. That's why, for all of the lectures in this course, there'll be around the 10 minute mark. So whilst you're watching this course, what I recommend you do is to split your screen and half for the left half. You have the tutorial running on on the right half. You can have your own code running at the same time so you can practice what I'm preaching at the same time. If you have any questions during the course for each of the lectures you can simply commenting on the side, you just click here on. Then I will do my best to respond to you as soon as possible, as well as being a python programmer. I'm also a machine learning engineer, and I have a great passion for passing on this knowledge to other people. So as we go through this course, I'll be pointing out how these fundamental concepts can connect with machine learning and creating artificial intelligence if you have no interest in it. In this no problem, these are optional parts where you could just learn a little bit more to repair yourself in case you're interested in later becoming a machine learning engineer. After this course, I'll be offering another one in machine learning so that this will be a good way to prepare you for this one. So that's the introduction. Next up will be talking about how you can maximize your learning during this course. 2. Maximising learning: this lecture is all about getting you into the right mindset to maximize your learning experience. In this course, If you follow along with the suggestions, I'm confident they will be programming like a prey in no time. The first point is that this isn't a passive learning experience. It's important that wash your going through the lectures. You're coding with me at the same time. So you develop in intuition and a confidence for writing code yourself. The second point is to try and have a learning journal, whether that's an online document on note pads or just some chiefs of paper. Try to know down the new things that we're learning throughout the course and throughout the lectures, so that you can come back to them and you might find things that you might have forgotten previously. So this things on to my next point, and that's at the end of every day and at the start of every day, try Teoh without using any of your notes. Think about what you learned the previous day. This could help you to start making those connections in your head and to improve your learning. It's important to get created with python. So try once every day to create your own programs. Really own python for yourself. As I mentioned, this course is very practical, and we're gonna get stuck into the concepts quite quickly, so you're gonna have a lot of different concepts to start thinking of. How can these concepts be used to solve different problems? I recommends doing this one today by yourself. Creating a very small project every day could be really helpful. Finally, it's important to develop a skill in using online Resource is for problem solving. Whether you've been programming for a week or for a decade, every programmer finds important that when they get errors, when they're confused with their codes, they know where to go for online resource is and to go into the online forums. So we'll be going. We'll be talking about that in a later lecture. So that's everything on this lecture. Next will be going into more of the hands on coding, so I look forward to cutting with you in the near future. 3. Installing python: Okay, so let's get started. With installing python onto your computer, we're gonna be using something called Anaconda, which is a very useful distribution. Essentially, all you need to do is download Anaconda and install it on, and it will come with a lot of different packages, including python on Jupiter notebook, which will be using to run python through but through Anaconda. You can basically get access to a lot of different packages, which is really useful in many different ways. So I highly recommend you download Anaconda. You can also just go to the Python Web site and download it from there and just get Python by highly recommend. You go to anaconda dot com slash download and you can donate it for Windows. Back or lyrics will be going with the Python three version s A. The way the python to is different is that this is mostly just different syntax. Um, so basically, how you write the code, eso will be sticking to the three bison three syntax on. Most likely, you want to get for the 64 bit, so recommend the first try that on. If that's not working, then try the 32 bit. If your windows. If you're Mark, you don't have a choice. You could go for graphical installer or command line. The stolen ID recommends. If you're not that used to using the command line, go the graphical into installer the command line. It's need to learn a few other things, which I'll be going over in a later course with lyrics here. You would recommend you try the 64 bits times 86 installer. If that doesn't work, try the one below. So essentially all you need to do is download it and install. It is very simple to do if you, if you have any problems with trying to install it with the errors. First coupled Teoh this websites and look at the documentation just here. See, see what has to say but also Google, Google what the error says, and usually it will come up with describe what's going on. Uh, but also, of course, what you could do is basically leave a comment in the course, and I could try to help you as well to try and get this running so soon as you been stored on the conduct. It's incredibly easy to then load Jupiter notebooks and we could get started, so it should take between 5 10 minutes. It may take a bit longer to it, sort if your computer's a bit slower. But make sure you download the right one for your operating system. Most likely will either be win days or back. Right now. I wanna Windows laptop. I used these Lennox, So yeah, download its in store, really conduct. And then basically, what you could do that is you can easily load Jupiter Lit book. So I suggest you pause to the lecture here. Adds once, once you've got Anaconda installed, then come back here and I'll show you how to load Jupiter playbook. So the main two ways of letting dupes today. Brooke, if you just type in your search Jupiter notebook, then you see this right head Who's you get? So this is the icon produced a notebook. Essentially, I have ah, objectively but running right now, so I'll just shut that down. So if I search for dupes electric here, if we just click on this, it was essentially just start running it. So opens here. What's open? Just here is the anaconda command line, so Essentially, you will probably be waiting for a little while right now. What? Computers? A little bit slow, because I'm also running something in the background, but as you can see, opens up and there you go. So that's what waits weapon up another way that you should open up and ah, chips labor. There's you simply open the anaconda prompt like this. You wait for a second foot to get started. It's actually important. I show you this this way as well, because it shows you what directory you're working in. That's important to know when we start working with different files. As you can see right now, we're running from users slash police guys slash document Andi. So that means that it's gonna be able to load files and it will save any files to this folder. Documents that's really important to work we have to do is just type in Jupiter. That book at all load up the exact same screen, which is the home screen for duty notebook. And once it slated, I can change the home page, it basically shows, shows me a list of files and folders there in my documents. So as you see right now, this is stupid. Little working in local Host s Opens in your browser browser, but this isn't running on the Internet. It'll this is simply just working from from my computer. And then what we'll be doing in the next lecture is clicking on this new button, selected by 33 And this will be where we'll be working out of Jupiter notebook. So give it a try yourself, download Anaconda, install it and tried to open Jeep Today. Book You have any problems? Check out the Anaconda Anaconda documentation, but also feel free to leave a comment in this lecture on. I'll try and help you to get it running on. Def. We get enough errors or probably creates a Neff a Q page that would help help everyone else . So when you ready, go on to the next lecture on. We'll learn how to use Duped a notebook. 4. Jupyter notebook: so do to notebook is where most of our lectures is gonna be taking place. It's a fantastic tool to use for running small bits of code on. It's really good for communicating things. For example, you can write really good reports on your code or on your programs. You should use notebook. It's very good for prototyping. It's also very, very useful for teaching. So that's why I'm gonna be using dupes a note, but pretty much the whole time. There are a number of difference. Other tools you can use, for example, for standard coding. When I'm writing a lot of Kate's, I use something here called Sublime, which basically allows you to color. Coordinated is very nice, and you can write your Caden sublime. So if you want to get another tool, I'd recommend sublime, which is a useful tool. But for this course, we're gonna be using mainly due to notebooks. As you can see here, I've already put a few bits of text that you'll see this a lot in a lot of the lectures. They're pretty much just prompts, and let's just say subtitles for lecture of what we're gonna be going through so we're gonna start by showing you how to create a title loading files and saving force. So right here where you can see untitled eight saying last checkpoint seven minutes ago. That's basically giving your total name and the last time they were saved. Eso You can click on that. Give it any name that you want so I can quote Jupiter notebook tutorial. I'm gonna read a bit and then whatever you want to save it, you could just go to this, though. So floppy floppy disk icon, and you will save it. Andi, all of the files are saved as dot I p y N b files. Okay, And those are due to notebook files if you just save something. For example, in sublime text, a za python file is a dot p y file. So we've got saving and creating titles done. No. Now let's look at loading files. Essentially, you click on file and then opened. It's going to take you to your home page, as you can see here, the dupes a notebook tutorial dot i p y and be has been saved a few seconds ago, and it's currently running so you can open up any of these files here. You can also open python files on other filers, but we're gonna be focusing just on these due to notebook files. So running yourself. So this look, actually running some code now, Okay. Every simple example is due today book as with python, because we're basically running, as you can see, Top Right here. We're running Python three on Jupiter Date book. So it's not just python you can use do today, but gone. I mean, that's why why it's so popular. But we're going to just be running python three. Essentially, you can use it as a basic, uh, calculator. So three plus four. Now, to run a cell, you can dio a number of things that the easiest way to do it is press shift and enter. As you can see, we have the inputs. It says in three plus four at the output of this cell that we just run is seven. Okay, let's just put this in the string. So as you can see, whenever you run, I'm just gonna write a very small smallville of code, which you will be getting familiar with very soon. Okay, so this is running at now. An actual python command. It's printing. Hello. So that's the first command you will come across of Python in this course. Okay, so So, basically, python and general confuses a calculator on using Jeeps notebook. If you ever want to run any any of your code, you just press shift in tow. Appear right below. Okay, go on to shortcut buttons. You know, some people we tend to use a lot of these things at the top, for example, adding, things are moving things up and down their ways to deletes cells add new cells, etcetera on to run cells. So you could do with this clicking buttons. You can use the graphical interface if you want, but there are some really useful shortcuts. So here's just a few of them. If if this box is green and you can see this appear here, then you're with your inside the cell. So using any off the shortcut keys is a good way. So first we need to make sure the outside of the cell you've got this nice blue color and yeah, basically, let's see if you want to create a cell below, you press be that creates more more cells. If you want to create a new cell above for this one, you can just press A If you want to delete cells, you press D twice double tap D that elites as many as you like. Okay, so there's four or the forehead. The shortcut keys are shift enter to run a cell, but this a toe Add a cell above be toe addis l below a double D to delete a. So now sometimes you may run something. Let me just This is just a small bit of code that might take a few seconds to run. I want to point this out. Look here, Next aware, it says in a star's going to appear when I start running this on that, saying that this cell is currently running when one said is running. If you try to run any other cells, the next cells just gonna be put into a key so nothing is gonna be able to run until this is run. If this is taking too long, you want to start again. You click on Curdle and click Restart, and that's going to restart everything here and in a few seconds you're gonna see this star is gonna disappear and you're gonna have to run your coach again. This is just if you think that something's stuck in your code or you just you just started running yourself that has a lot of code. Let's and you see that is taking a long time. But then you suddenly see a bug in your coat or something. You think I need to change that. Run it again. It's cattle restarts or restart Arado if you want to run with the cells again. And now just a nice little extra. If you want to use this not just for running code here, you can change it to mark down. And this basic means it's not over code. It's just Hey, this is an explanation. So So this is You can run it, and it's just gonna be like this lesson clean. So this is if you want to use markdown. Otherwise, you could just keep using code. Um, thank you. It's enough. You run it and it just stays. Stays the same coders before. So that's the basics of Jupiter notebook. It's incredibly useful at this stage, I think, because one of the biggest things that you can run small snippet of code whenever you want another thing to point out. And this is going going into coding a little bit now. So if you're a complete beginner, don't worry too much. But let's say I do. There's something called variables where I create this word here. I'm assigning it something. So I'm saying that name equals seven. So now if I just run this cell here, the outputs could be seven. I've assigned this number to this variable I've coordinated now in deep to notebook. It doesn't matter if you if you run a cell above or below. It's all based on when you run it in time. So you run this one better in this one. I could also put name up here. It's still gonna output seven. So doesn't matter if it's a bubble below, and that's an important thing to remember. You could look at this at the sequence of which things around by looking at this number here. So this is run number two. Number three. Number four, this is number one, which is right just before, So those are the main points of deep today, Brooke would be great to hear what you guys think of it. So leave a comment in the section here in this lecture on when you ready, let's move on to the next lecture. 5. Practical projects: now the end of these section off the course, I'll be providing you with some practical questions for you to run through that will basically be solidifying your understanding of that section. So I'll be making sure I touch on all of the concepts that I discuss in order to help you to practice eso here. I have the example of the first practical, which will come at the end of the next section. And as you can see, I've put in mark down some questions and then below the question you can put in the in Burt's of how you think. So, for example, says he get the cell blow to attend. Hello, my name is so I just give you the example here. So this is what the correct that's will be spider latte. They run it so you could do like this. And after each of the practical, why would What I will be doing is running through all of the questions and explaining how you could get the correct answer. So let's just go over how you're going to be able to get these files. So essentially in this lecture, you'll find attachment that has a zip file in that zip file will be a number of I p Y N B files. That will be just like this. So, as I mentioned before, in order to run files Ah, there on your computer they need to be in the same directory, the Jupiter note, because run from so basically anything that's in here. So one way to find out where is if you open a duped a notebook? Ah, new. Would you basically type in P W D? Okay. And then run it using shift, enter. This means print working direct directory. It's going to show you exactly where things were running from, so uses Blue skies, documents. That's where minds running from. So what I would do is I would take unzip that file that's attached here, uh, into documents into this folder. And from then on, you can access it very easily from home, just like I can access all of these ones here with these i p Y b ones. So that's why I recommend you do on there when you get to these practical. Essentially, I highly recommend that you try and do all of them by yourself. I mean, usually what the case is is that most people will find different parts of the course difficult and different parts easy on the part of the important thing. To keep in mind with becoming a strong developer is getting the mindset of solving problems . So if you don't understand something straight away, I really recommend you persevere. Give it try by yourself until you really understand what you don't know, because at that point, then you can ask the right questions to get get more help on. I was strongly, strongly recommend. You don't watch their solutions video that comes afterwards after the practical until you've you've really feel like you've given it a good try when you get stuck. There are a lot of different ways that you could get help. I think the first, the first ages, just to persevere by yourself for five minutes or so. And then there's something useful, something useful. Google called Stack Overflow. So this is a really, really helpful place where essentially you can post questions about problems that you haven't with code. I recommend usually if you are. If you try to google something like stack overflow and then you know, um python, Uh, print or something like that? Yes. If you especially having error, you can literally just google the name of the error and includes stack overflow if you like , but you know it will most likely come up with the problem that you're looking for. So when you're running through through one of these things through one of the practical and you come up with an error or you're unsure, try Googling stack overflow on. Then they're probably having so either exactly copying, pacing the error or or describing in your own words on. But of course I'm more than happy. Teoh reply to any of your comments in the lectures. If you have any questions, why do highly recommend you do is get into this mind set of developer because that's what they would do. They would persevere for a few minutes, come to understand what they don't know on what the problem might be. Then look on stack overflow or any forms. You can just google your problems. If you type in python first and then the problem will python three. You can, even if if the if there aren't any answers or any questions existing on your problem. Then you could sign up to stack overflow, which is free, and then post your problem yourself. So yeah, that's that's the main point of it. Once you've done all that, then we can go through the solutions together. Besides what it's introduce you to the practical side of this, which is really, really important and also be encouraging you to play around with concepts. Eso use your imagination to create your own many programs based on the concepts one X lecture that we go through. So with that in mind, let's get into the practical side of things. Andi, start teaching you how to code. 6. Print and input: Okay, now that we've got everything set up, I'm very excited to get into the more practical part with the on Greece, start to help you to learn Python. So we're gonna start with two of the very basic things. It's kind of like the hello world of Python. So hello World is like the first thing you'll ever do t get started with a language. So go start with the print function. So you're typing prints. And essentially, what print does is your telling the program to prince whatever you put within some brackets or what we call parentheses. So, for example, you might have a program, and you want it to print to say to the user, Welcome to this program. Say, within the brackets, you would then put quotation marks within these quotation marks. You could say Welcome to this program. And then if I run this since she is gonna prince just below saying, Welcome to this program. Now whenever it's text or what we call a string of text, if it's not within these quotation marks were going to get error. So there is always come up when something in the code isn't working properly. on, we get what's called a syntax error. So whenever we're putting in text, we need to have thes print thes quotation marks. However, if you want to print a number, you don't need to put that in quotation marks. So right now we're just printing a number. If I worked but these in quotation marks, then it would actually be the number. But in text formats, that might be a bit confusing at first. But trust me, you will. You will get intuition for it. So I want you to know, try and do exactly this Type in Prince and within these parentheses or brackets and you write Hello World in quotation marks, try Rhine running that you should get below Hello World in text. So the next thing we're moving onto is input. So this is basically a step up from print again. You type inputs parentheses on the in quotation marks, so input. Actually, what the function does is it's getting the user to put in some sort of information. So whatever text or numbers I put in these parentheses, it doesn't really matter. So Aiken type in Hello, for example. Now when I run, this is they're going to come up with a little box, which is what? The user where? Where the user would have to put in some sort of information. So you compare What if you want him? Doesn't. Doesn't really matter. So addicted to blow the output is high, so people might use this. Let's say, for example, ah, we are creating a question. If so, it says hello. Please enter your name. And then you put a space at the end of your text just so that it's not like here it looks a bit weird. So you run this in your name from that, and you'll get your output as John, you could do the same for for age or whatever. So give that a try now with me, type in inputs, parentheses, and then whatever text you would like. Hello. How are you today? Find? So give that tribe and you you should get get something like this. And so the way that this is used, I'm going going to introduce to now a concept that we will be going over in the next section. So don't be put off by this, but I'm just going to show you one cool application off this essentially, with an input, you can store this as something called a variable so we can actually store whatever the user replies Safe, they would say Fine, we can actually save that is a very so I could put it. Is this this is gonna be the name of the variable I'm declaring is equal to inputs. How are you? So then, whatever the the user enters that will be stored as this variable cool response. So if we run this fine, but here's the cool pop. If I just put response see this? The response has now been stored in this very born eight. I could also you can print variables. So Prince Response site. I'm gonna do something cool with this. No. So response equals impacts. How you I'm going to use something called a if statement. So if response is equal Teoh Fine. Which it is books. My mistake Print. Okay, so were we already know that the response is, um, fine. So it prints back Caray, So input could be used for some really cool stuff. That's just an introduction to this. So now that we've been through how to print things off, how to take in input from the user and how to store it as a variable. Try noting down these three things off a bit of paper and also give each of them a try. So in your own way, writer print function and get it to bring whatever you want. Remember, if it's text to include the coat quotation marks, if it's a number you don't need to, and then try creating input. And if you want to look nice, remember to add a space just before the end of your quotations, uh, and then try to store on input in a variable and then print off that terrible. So once you could do that, you're really on your way on Beacon. Get started with the next lecture, which is all about different data formats, so I'll see you in the next one 7. Common data types: Okay, guys, we're now moving on to common data types. Eso in by thin. There are a range of different data types. We're gonna be going going over the most basic ones, which we touched on the 1st 2 sets here in our first lecture. So strings, they're essentially pieces of text. So, for example, uh, hello. This is a strength. Okay. Introducing floats. These are numbers. An integer is a whole number. So for example, 12 or 32 any of any of these kind of numbers there or indigenous anything that has a decimal point in them. So they're 2.45 or even 32.0 that is now afloat. And it's important to know that there's a difference between integers and floats. For example, as I mentioned that, we're gonna be touching on machine learning and artificial intelligence. This is really important. Teoh be able to grasp there's difference between integers and flutes. Uh, so we have text, we have two types of number. So it's important. Remember that finally we have billions, which I think is a very cool it. It's basically true and force. So that's that's essentially what billions are you either have true or you have false Andre . This is used in so many different ways. Um, let me just show you something. So let's say one. And this is a new thing is equal to So I'm if if one If I'm stating that one with two equal signs, it means that I'm stating that one is equal to I'm gonna put three. It's gonna come back with force, because that's not true. So I turned that the course toe one. It's gonna be treated. And if I were to do this, I would get, um, syntax error because it thinks that I'm tryingto create a variable that's called one Onda does not like that. So, yes, so this could be used in so many different ways. Uh, so, for example, in games you can say I don't get too complex here, but there's another thing called a while loop. And you could say while yeah, um, game is equal to true. And then you could run the Gabo. So essentially true. Enforce communes in lots different ways. It will be touching on it. I don't get into too many complexities. So for now, just keep in mind that you can use thes two equal signs to state if something is true or not and Python will come back to and say, Wait a second. Yeah, that that's not true. So if you want to check the type of something So let's say, for example, um, we want to know the type off. Hello? Obviously, we know it's a string, but we just want to check. So what we can do if we just type in type and then put this in brackets, it will return saying strip, which means string. If we were to change this to 32.0, as we have up there, we have flipped there. We remove the decimal point, we have it. So that's how you can check the type of something you literally just put type and then parentheses, and then you will it you put the thing inside the parentheses. So finally, we're going to go into converting. So how do we convert, for example, an interview into a string or vice versa. So this is quickly we have fetched, right? That's an insurgent. But we, uh, could put instead Ah, see string 1st 2 Okay, so returning the program now that we want 32 to be string. So no, If we store this as a variable, well, we can do even simpler and just put in here. What is the type of this you can see? It's now a straight So we could go the other way. Like I was just saying and weaken store it as a variable. So would a equals drink it and then what is the type of a its history? Okay, Onda, we can do this vice versa. So if we were to say a equals fst so because in quotation marks were saying that whatever's in here is a string, so it's no longer an interview If we look what type that is gonna be a string. But now if we put B equals denture hey, time be isn't and also so it is obviously interview for float. We just need to type float that is now flights. So the main things that have covered in this picture gone through some common data types strings, which is text into Joan float. So that's numbers. Integers are numbers that don't have any decimals afterwards, billions which is basically true and false statements and Then we looked at how to check the type off anything. So, for example, here we detect just a number. It stated that was an interview. Then we looked at how we can convert strings into images and interest is into strings by basically just putting. For example, Here we put we put text within this, so we just we just put float parentheses and then we just put whatever in here and attending to a flight. So some good things to practice here recommends just checking out the types of some things . So your store, for example hello as a variable. So just to make sure your understanding you could store hello is any variable so you could put text equals Hello. So text is now. Hello. The string is now stored in this text. So now, to check the type, we just put in type text no output it. So the first thing to do is just play around with that. Make sure you can check what types, stores and things as variables and then check their types, then playroom with this true and false, just literally try you for example three is equal to 100 you'll see it's false. Three is equal to three and it will return tree. And then what you can do after that? Just have a look at converting them as well. So taking, storing, very storing some textures of variable. And then just putting that variable, for example, like this. So if your if your story some string, that's a number that you can convert into a floater on interview. Obviously, if you were to try and do this, so you have stored some text, but it's not number as a text. And then you were to try and do this. You're gonna get error, because, of course, you can't turn hello into a number, so keep keep mind of that era as well. So yep, that's it for now, and I'll see you in the next sector. 8. Commenting: hi guys. So today we're going to be doing a very simple and short lecture. But some fixing something is very important. And that's commenting. So adding comments to your codes or love people call documenting your coat. Eso. This basically means like when when you're writing a lot of code and you're creating a program, it's adding lines in that don't necessarily have any function within the program. But simply describe what's going on in the code now. Why would you want to add comments? Tiu some your code? Well, there are two main reasons. The 1st 1 might be that you're working within a large team on your all working on the same on the same code, or they'll be having to look your code a certain times. Teoh. Find out, right? How does this part of your code work toe make something happen in the program, and it's important that they can look at your code and it's written in plain English what the different parts of the program does? Um, similarly for yourself because on large project with teams, then there may be millions of lines of code. I mean, if you can imagine Facebook for example, could you imagine an engineer having to go in there and just look at all the codes and work out right? OK, this function links that one. Things get very complicated very quickly, So it's important to have this this commenting. Similarly, If you're writing your own code, you're writing a large programme. You might forget what certain parts your program do. I've been guilty of this of the past and not commenting three. So I'm going to show you a quick example. So here, for example, I was building a convolution. Your network at the top here. This is just a very short comment that saying this is, ah, commission your network, downloading all the images on reporting accuracy and improving on it. But the rest of it, as you can see, I basically haven't had it at it Well, because you can't see Epic 17 showed you how to quit. But I haven't added me comments here, so I'll just show you quickly. What comment is a comment is essentially you put in a hashtag and then you can write whatever describing a function. So, for example, I might write creating a variable, um, for use in if function my shaded the function a few lectures ago So then I can I can basically say I'm creating a variable A equals Andi, let's say three plus So I've run this and I'm actually gonna tell it to print Hey, as well. So what? I run this now there's gonna show a which is this seven plus three. But it's not gonna print this off, so actually, it has absolutely no effect. It'll on on running the code. It's just so that I can see what this is doing creating variable for use in fortune on that I could like it created. So if a is equal, if you remember that to 10 print yea, such printing this then that's printing this. But it's not printing this little. So if you if you put a hashtag in front of something, basically it's not going to appear it'll So if we go back to this now, you can see I've put one here. If we scroll down, you can see here supports a really basic stuff. So here I'm saying, I'm defining a loss here, working at the accuracy, actually calculation, some dumping, some very basic comments. The reason why I put it here is because this line of code, if I were to remove this comments, it would it would be part of the cage. And I don't want the program to run this parts at the moment. So don't get too intimidated by all this code. If you take, my next course will be looking a lot into creating your networks and actually quite fun and quite easy. But for now, going back to commenting. So if you want to do a comment with just one line, you can simply put this hashtag which is very cool. So if for example, print yea to so 10 Yea, yea to. But now I'm gonna comment this part out. So now, as you can imagine, it's only gonna print this one and this one 10 And yet now, if you want to do multi line comments, essentially, this is what you have to do. You put in three apostrophes, So on either side, say 123 and dupes notebook is nice and smart, and it creates it for us. And then I'm gonna put few enters in that campaign. Hello. I, um, commenting, this is the best course have. Ah, okay, so do to notebook. Actually, it's a bit city when you run it. It puts this in slash end basically means that there's a line. So, as you can see after writing comments, commenting, there isn't an extra line, so dupes notebook isn't great for this. But if you run the run, the Python file and I'll be showing you how how to do that as an actual program, this wouldn't appear. So if you want to do more to nine comments and Duke to notebook, an easy way to Dirt is using control and four slash. So if I select a lot of this and I put control Ford slash there's this nice Everything we're adds a hashtag tour, so I mean that that's what I use. So that's the basics of commenting. So why recommended you play around with this Triton's write a few lines of code? Try commenting a few things out on DSI. How that goes. It's quite simple concept, but it's very important that you get into the habit of using this quite often, especially as we start to use more more code in our programs, so next will be going over. A few more practical things on there will be moving on to the next section 9. Practical 1: Okay, welcome to your first practical. So just remind you in case you're confused how to get to this file one the basics practical . In the first section, there's a lecture on the practical on. It has an attached zip file. Make sure that you download that and you unzip it. If you type in pwd into any Jupiter notebook you're running, um, you want to make sure that you're running it from from wherever you see this Eso I'm running my file from from this fire this folder here Python practical. So make sure you store all of all of the different files in this directory. Whatever is on your computer, just type in PWD. So essentially, these are gonna be the different questions that you have. Um, in general, I'm not gonna be posting anything that I haven't already gone over in the lectures s I won't be stretching too much, really have ago are entering all of these yourself. If you have any errors that come up or you're not sure what to do, the first step I recommend is toe. Try a few different things yourself, play around with it on, then after that, going to stack overflow Google with the error on then comment in the lecture. If you seven got anything and if you re still struggling, obviously you can go into the solutions. That's just after this. But everything here I've tried to make it takes you ever so slightly out of your comfort zone. Let's say to get you working, get you thinking, but nothing too much that I don't think you can handle. One thing to note on the final question here, number six right to comment is that with Jupiter notebook? If you run the sell, something will actually appear on. And if you if the text appears with the slash N, that means you've done it correctly. I'll make a note of that in the solutions lecture as well. But here you are. So good luck. Andi, leave any comments you like in this section in this lecture on myself, and hopefully some of the students will be able to help you. So good luck 10. Solutions 1: Okay. Welcome to the first solutions lecture from our first section. I hope you have given this a good try by yourself on if you come up against any errors, you've may be considered using stack overflow or googling the errors or even commenting in the previous lecture for help from myself and other students. So if you've done all that, then let's get started with the solutions to the practical. So this gets side, right? With number one below the cell, so toe to make a point. I mean, I could have said print. Hello? My name is but using the word prince would have meant that you'd already having you had. Okay, I need to use the print function. So I'm trying to kind of pretend like I might be a client or something. Somebody doesn't know the jargon behind Python, so it makes you use your brain in a developers way to translate this. So essentially all you're doing here is I'm asking you to get the cell output. Hello. My name is and then there's a blank. So you could put in whatever you want here. So you use the print function in parentheses. You have the quotation marks because it's a string, you have to have a quotation marks and then you can simply type. Hello. My name is John, this ghoulish mark. And then to run the cell, you press shift. Enter outcomes. Hello. My name is John. So a few hours that might have occurred is you might have forgotten to add to the parentheses or similarly, you might have forgot to include the speech box, which also would have thrown in error because with strings you have to include the quotation marks. So this is here is the correct answer. Obviously, you could have any name that you want. Okay, create a variable assigned to text Jim. So as you may remember, a variable could be anything you don't need to put in quotation marks. That's a very important point. So I'm going to put J UN school very cool. It's very good to include if you've got something that's long with just one word or short word to increase like an underscore, something you can't have space is that that's no variable. It was for an error, so you have to have something like an underscore. J variable equals the text Jim, so there'll be no output here. But if I run below, so just make sure I created that extra cell by using the shortcut B. If I just type J variable. And here's another handy tip This is now being created is a variable has been saved into memory. So one thing dupes a notebook does, which is really cool. I've written part of it. If I tap the tab button on my keyboard, it will auto complete it, which is quite cold. So I run this by pressing shift. Enter and it well put, Jim. So we have created a variable. The sign It's text Jim. Okay, The next one print This is my friend Jim. Without writing Jim explicitly in light of a lot of code ballet. So this one's a little bit more tricky on dumb. Yeah, I hope if you had problems with this, you tried by yourself, Maybe looked up a few tutorials online or going on stack overflow. A. Went back on the previous lectures. Essentially, we've just created a variable that has the text, Jim. So I could do is rather print function. This is my friend that outside the speech box I put a comma, which basically means I'm saying print this at then print so I could print a thing. I could print more text if I wanted. So even though these are in two different quotation marks for run this you are that the color isn't in there because it's not in speech marks. But we want to do this without actually writing and jib. So we're gonna put J variable and there we go and what they said. And you just have a commerce. I've got put a comma inside here as well the every day. So just keep in mind that when you print something, you could put many things You just need to separate them with a comma, so I could have put string there or number. This is my friend of before all these things will work just fine. So next up creates line of code that requires the user to provide information. So this is simply asking you to use the input function which you went over over before the previous lecture. I've got a pit. Basically, the text type of here isn't actually that important. I can type whatever I want and it would come up with this input bar below, but that wouldn't make sense of self was using a program. So let's get creative. Let's say hello Ah, um, automated played. Where do you want to get Colon? Because it looks nicer under space afterwards to make it look even nicer if I run that okay , you might remember in the one of the first lectures for Duke today. But if this happens, as you can see here, the Asterix is just sitting there waiting. So why can do? For some reason this is stored or click on Colonel and just restarts restarts. And in a second, what's gonna happen is up here. It's going to show me that the whole thing is restarted, that I can try running again. So it's not that there's an arrow going on here. It's probably something going on with by my computer itself. But this happens a lot for people on their computers. It's important to know what to do in this situation. We have a Asterix hearsay weightings of God's Colonel of clicked on restarts. You have seen just there flashed up blue for a second, so now it should be restarted like it. So it seems the dupes notebook was just being a bit buggy. The tricks wasn't changing. So what I did is I went to colonel and selected. Restarting their output was basically, as you can see, has removed or the output from previously. But the districts has now disappeared so we can continue. So if I run this now, as I was saying, we're using the imp a function Australia into that No, we haven't up put Australia. So now we want to get information from the user just like we did above. But store is a variable, so no, we have to do as we have lived before. We can create variable with any word we want. Make sure it's not in quotation marks and then we just assign it do equals inputs. Uh, how about this? We could call this user of the school age, so it's very clear what it is and that we could put what? This your age? Then shift, Enter to run. There we go. Uh, two hundreds enter the end. So now if I produce another cell blow by tapping, Be, uh, if I just road users age right puts because in other programs for Europol sublime, You have to put print ease or age it. Wait, Just output. Otherwise, he gives us 200. So we have gone information from user. We have stored it in the variable user age. Okay, so just a few more together No return this variable within a sentence written by the program. Okay, so now we're getting some cool stuff this time I'm going to create. Okay. Says returned this very well. So I'm going to use this variable use age. So that was going to say print. This is very similar to what we did above when we use that calmer to separate separate things in a print command. So hello. Your age is very, very interesting. Sensitive. Hello your ages. So I've done that string and now we've added a comma that I could just put in the very book afterwards. So this is exactly what we were doing up above before we put the variable hip. So putting in the string, then comma use their age. As I said, you could put anything here. You could put another string, you could put a number. You run this and you get Hello. Your ages 200. So now if I run this again up here, user age, the Imbert over. Change that to 20. Okay? And now if I run this, it's going toe outputs. Hello. Your age is 20 which is awesome. Okay, next writer commented that brother code, This is lovely and simple. You just put a hashtag that say, this is a comment. And then when I run this cell or line of codes, I press shift enter and nothing outputs because it is simply a comment If I were to put Prince 20 groups with print disease So the comment This this line does not get processed, the toilet gets ignored, and we just print 20. Okay, so now we're writing a comment that goes on for multiple lines without using the hashtag Okereke. So this is where we're using this. So you won't have six of these posts trees that you will separate by a few lines that this is a multi lied comment. All right. A now with Jupiter notebook. As you can see, it's a bit strange because it does actually output it, which is quite confusing, but not to worry. Basically, it's is not going to be processing this. I'm not really sure. Why do you two know but does this. But you can rest assured that this isn't going to affect your coat. If I were to run this in sublime, for example, or any any interpreter for Python? It's is not going Teoh do anything with this, Collins, You don't even get us it. Just for some reason, dupes notebook likes to put in by some weird. So you could ignore that. Basically, Um yeah, so that that's how you write a mortar like comet with three apostrophes. So, uh, why I recommend you do is if if you go any of these incorrect when you're going through it yourself, make a note with a pen and paper right down the concepts that you struggled with and that make sure you just go through a few times over the next few days. But well done on completing the first section, you did a great job. And let's Beavon to the second section 11. Comparison: Okay, so now in this sector, we're going to be going over some comparisons we've already visited before to reinforce the billions. As we described, we're gonna get a bit more detail in some other things. So you've already seen this one as well. Equal to this could all be incredibly useful in so many different applications. So, for example, in artificial intelligence, it's really helpful, especially for data processing in cleaning up data. There are a great deal of of uses for these sort things. Even for example, if you are taking emails from someone on your website and you can say for using an if statement, which we talked about a few times, saying, If there is, uh, if there is there, the at symbol in three email address variable that that is fine. Because, unlike past, um, essentially using these sort things, they're saying, If this is in the text, then the email is fine. If it's not, then you know that you could given air message to the users, saying it's an incorrect email there, so many different applications. So we're gonna go through all of these now on. We're going to start with Let's start with the equal to or not equality. So we've touched on this a few times. The two equal signs means equal to, But now if you put exclamation mark equal to it means not equality. So let me show you. Three is equal to three, so that should return truth. Great three is equal to five force. Now, if we are going to change this to an exclamation mark, three is no equal to five. Then, as you see, that will return truth. No, that's going to in and not in. So as I was just saying, we can use this as example for emails, so I'm gonna create and variable court email. And then there's a string of grains. Pits me at me dot com. But actually, I'm going to not include the outside, so it's just mean dot com. No using a function if the at sign not in. So I'm saying, if this I mean this is a great thing about python as well is it's very easy to understand and grasp. It's almost like reading out English if that sign is not in the variable email print. Incorrect female. So it should return incorrect email, but No, no. We're gonna add in this outside, and it should return nothing at all because it is. This is an email. So now we can do the exact the opposite of this. And just have if that science is an email print, correct email space. Excellent. So that's in not in. And as we go into more complex data structures, for example, lists, which are you very, very, very useful in artificial intelligence and machine learning, you'll be able to see that use that we can use this on lists and other large date structures. Gate. Now let's go down to more than less than more than or equity less iniquity. So this signed by itself just means is more than so. For example, I could put three is more than five. That should return close. If we put three, it's more than one. That's true. So as you can imagine, this means less than five is less than two. Force Five is a stand one zillion true weapons. If you put five, is there some five? It's going false, but if we put five is less than or equal to, that's what this means is gonna return True because it is equal to five five is less than or equal to five. Unless these nicely into our and or comparisons here. So this is quite useful. So we could put five is more than three, which is true, and seven more tonight safe. What do you think this is going to return? Five more than three. That's true. But seven is not more than nine. So what is gonna happen is gonna say, Well, yes, this is. But what I'm looking for is that five is more than three and seven more than nine. So, security force. However, if we put war here, we returned Treat. Now, if we return to this e mail example, email equals the hello. No need to put these in quotation marks. So this is an important point. This is this the same named vary boehlje. But essentially, if I If I do this again so email it cause me at me dot com. But now I'm running again. It doesn't matter if I run it above or below. I'm basically assigning this variable to something new as soon as I do that it completely forgets about this. And this is now email This is what the variable holds. So me at me dot com has been completely forgotten. So we now have ah, variable email Now in this if statement. So I'm just lonely introducing you to these things like the if statement. Don't worry. If you don't know I'm standing at the moment, the more introduce you to these things now the easier it will be when I introduce them to properly in a future section. So if the at sign is in email. Andi dot com this in email prince correct case And now we're getting a bit more complex. Our program is becoming that little bit smarter. Correct email. Excellent. So that's using the And we could also use the or that's removed. Basing that on the dot They is not gonna print correct email because neither this or this is an email. So we've gone over quite a lot of different comparisons here. So what recommend you do now in order to practice all of these is to focus on the and on the or and in and not in and go through these different equals. To annoy equals two and go go for the more than or less than so when you're practicing, you could simply do things like this. Best of this of ones like is equal to you. Could put hello is equity. Oh, true. Okay, Hello. Is equal toe Life Force. Okay, so just play around with things like that. Who? Okay, so, playroom with those once you want your feeling confident with that, then go into doing some comparisons using more than less than more than or equal to and then drive in and not in. So for now, it's mainly going to be using text. So hi, ho In. Uh, hi. True. So how if you go to that Andi, you could put in her on in Howdy. Okay, so just play around with these things on when you're ready. I'll see you in the next lecture. 12. If else: Okay, so now we're going on to if else statements I really like. If our statements, it's the first time when I was learning Python, where I really felt excited about the powers of python, what what I can really do and how simple and easy it is to integrate these things so essentially will go through if else and something called LF which basically means else. If so, as as you might have seen a few times in the lectures you may remember, I've shown you the F statement a few times now it's essentially just like in plain English . So if one is equal to two for equal to one, for example. So I want to show you the syntax of this now on the syntax, basic means the structure. How would people this when, When you want to use, if statements, you basically put this first. This is what you're checking for and then you want to put a colon after it, and then the next line you go down and you want Oh, indent. So this it doesn't really nicely. Sometimes some programs don't so essentially, what it is is if you press enter and you start just here, either you compress tab when your keyboards all you can do four spaces. 1234 And that's called Indentation. And that's what. So what you're saying is saying if and then you put this one equals one way of your checking for on. Then here you put what the program should do. If this thing here the A checking for is true self, one is equal to one you could put. Yea, one is the same as one Eureka. You never see what a footprint in front of that. So Okay, so it was read that because essentially I had there wasn't indented. Property was only three spaces, which should before, so you know it's too. But you want four spaces in the Yeah, what is the same as one? So that's great. That's a good way to start. But now what? If you want it to print, you're not sure if if it's if this is true or not. So you wanna have like a backup plan, So plan A. If this is true, then Britain this. But what if it's not you? Still, when you're programmed to do something and that's where the else statement comes in. So what we're gonna do is make a bit more fun to know we create a variable. I'm just gonna put it is a equals. Uh, let's say Jim. So go Jim. Here he is trying to under a log on Teoh a certain platform on, and he has to state his name before he could get into it. So you can say if ah, a what we could do would be quite nice. OK, so we're going to create an import. We're going to go back to start now just to make sure that you're practicing, all the skills have got here. So we're gonna create a variable called entry. We're gonna give this a better variable name cause a bit city put name entry equals inputs . What is your name but space there? So we're going to say if a so if name is equal toe entry. So we want the pat one on the present input. Their name is Jim. So the name should be the same. His entry print Welcome, Teoh. Jurassic Park about that. Okay, so that's cool. So, first of all, we need to follow up. OK, so I haven't run this since I changed the very real name. So you to run that again Up and down into in this, of course you're gonna put in here, Jim. Have to be care. Careful to make sure this is low Uppercase here as well. It has to be the exact same thing. Case of Internet, Jim. So now name is Jim. And entry is Jim as well. So that should say, Welcome to Jurassic Park. Do the duty. So, no, If I change this to, for example, um believe. Okay, So now Bobby is trying to hack into two gyms seemingly Jurassic Park account, which is weird. And so we have if the name is the same his entry. So it's not the same. No. We want something else happen. We don't just want to have. So if you run, so make sure you're running this. So I got Jim is the name Bowie is? The entry name is not equal to entry, so nothing's gonna happen. We don't want that. We want something to happen. So we're gonna put else so basically, if if If the name is equal 20 then do this. But if no if anything else, happens. So if name is equal to anything else, then just print in Judah. So if we run this now, what should happen is that Prince intruder let OK, Excellent. But what if we want to have something where a a number of different things can happen? Because right now it's quite by angry. If this is happening to do this, if otherwise do this So what if we want to say Well, if this is happening, do this. If this is happening, do this. If this other thing is happening, do that this otherwise just do this. This is where l f comes in essence, you're saying, or if she s a if name is equal to entry. Oh, or if name is equal to, let's say admin like it's an admirably count trying to log in then, uh, and hope for you our latest. I forgot to put a colon here or if they is equal to the loss erupt er because if the velociraptor is trying to access it, maybe we should lock all the doors. That helps you will notice again. I've got that the cold here. And so with basic covered. If the name is the same. So if it's gym trying to get in, then that's awesome. I will fill the seat of a second, uh, but or if the animals trying to sign in, then we can say Welcome to the admin. Or if it velociraptors trying again, then maybe we should try and locked down all the doors and evacuate everyone. Sorry for the wait example and then at the end, you can say, or if anything else is happening, we can put intruder alert or something. Let's just fill it up. So if the name is the same as the entry, remember, this is all in the example of trying to log on to some sort of, I guess online. Jurassic Park Prince. Welcome, because that's that's what we want. We want Jim to be lord, you know, But if it's the admin, we can just say that's fine. Welcome admitted. But if it's a velociraptor, tries Logan. Most don't velociraptor. Hackers print closing doors. Evacuation else. Print the intruders. Okay, cool. So we've covered the main things here. You've got the f l f or else, and we're just gonna use one example just to go through this again, make sure it so that you had so cinnabar. So we're talking about a cinema here where the let's say, there's a film where you you could only view if you're over 18. And so we have this cool. Let's say, for example, camera that could dio image your image recognition that it could detect the age of the person by looking at their face so we could put creates a variable called age. Let's say this is the the image recognition outputs that the person is age 15. We're actually got created age Liberte as well. Now, this is important thing into creating variable names. You can't create a variable name with a space in it. So whenever you want put space instead, you put underscore age underscore limit equals 18 right? Because if you're under 18 you can't see this film. So we're gonna be using a couple of different things that we've been going over, which was gonna be quite fun. So I say if age is, uh, more than or equal Teoh 18. Sorry, age limit fruit. Uh, enjoy the movie, but or else print too young, because if it's not, if they're no over 18 then they can't basically see the movie. So before the age of the age limit on, the cool thing about this is it's we kids actually provide this program so that it could be used for different age limits. So let's say you have to be 15 or over so that this person would be able to enjoy the media . So we've gone over. Today is if else and L f which means or if so, I recommend that you just play around with this for a while, come up with your own ideas like this, have been fun with creating variables, using some of these comparisons and try out a few of statements by yourself. And when you ready, I'll see you in the next lecture. 13. While loops: Okay, We're now moving into a wild leaps. So while statements of while loops are very cool, very useful things on. We're going to go into a few applications now, So the 1st 1 is we're gonna be doing a countdown, so of interest. So we'll be introducing you to a few different things. So first of all, you put while and then you put something in here, which is, for example, let's say that's great. Variable called Counter. We're gonna put it to 10. So we're going to say, while counter is more than, uh, say one. Well, I say we have more than their and then do something. So let's just say Prince, uh, running. Okay, So what's gonna happen now is that counter is always more than zero, so it's basically gonna just loops round itself. So it goes to this line while counter is more than zero. Do this so you can do this and then assumes has done This is going to go right back up to here and just go keep running through this loop forever. Uh, site while do is I'll start running it and they've got press control. See? To cancel it Okay, lets see. Two run this first. Okay, so we'll run again and you can see cancelling it. It's already I printed off running many, many, many times. So you don't want that? So what we're gonna do is we're gonna add something else just underneath this print. Teoh, reduce the counter each time. So one easy thing we could do just that Counter equals zero. Say what? This is guarantee. It's gonna First of all, count has been defined us 10. So this goes haywire. Counter is hearing is more than zero. OK, it's 10 print running, but then I'm redefining their variable zero. So come right back up to here. And it will a lot of problems. So for some reason, it stalling. Let me just check with that. So if you ever get this solved problem, by the way, you could just go. Teoh Trickle, curdle and select Restart. Just result Cuddles, Jake restarted. Or so essentially, what's gonna happen once I've once this has been run is it's just gonna print it off. Once, uh, could you say we get which is fine? Encounter There's being 10 and then were running this and it's just gonna go once. Yep. So what? It's done, it said, while counters more than theory. And here it is, more than zero. It's 10 print running, and then we're redefining the very, very variable counter a zero. They were going back up to the top, while counter is more than zero. What is no anymore? So the program is just stopping there. That's a bit boring. That's trying to sell me a bit more fun. Let's make it so it counter equals counter minus one. So what this is going to do? It's gonna say, right, countries 10. That and then it goes AWOL counters more than Jerry. It is Prince running or print running, and then it's gonna do. Counter equals counter minus one system counter equals 10 minus one. So counter is now gonna be nine. So I'm just gonna get it to print off counter as well. So we see what's happening. So run this as you can see the first time it does it, it prints running, and then it takes away one that it prints. It sets nine, 8765 etcetera until we get onto zero. Once counter is equal to zero, it's going to stop running because it's no longer more than there. Now to make this look even nicer. This line here country goes counter minus one. We could actually something cool where we put minus equals one. And this is the exact same thing. It's just a shorter way of doing it. So you're saying counter equals counter minus whatever is here but again, who did the exact same thing? Should they Okay, let's run this. Understand? So I haven't redefined counter as 10. So it's still thinks that counter is zero from the last time we run. The four leaps I have to redefine it is 10. Never again. Now it works this time. Okay, Thank you. So hopefully you you understand how this part works That will move on to next. So let's let's use us in a cool, interesting way. Let's look at this as a game. So we have a player, his name is Jim, and we're going to give him some health. This is variable. Were just avoiding a variable is always Jim. Health equals five. This dude has five lives. If you say no going to a wallet. Wow, Jim, Most gyms health this more than zero Oddly print. Jim is alive. But then let's say you each time this wild leap goes along. Ah, Prince Jim fell over you. So for was over. He loses one health. So you put Jim like he should have a capital J here, but usually actually best have lower cases just to keep things simple. So a change of these to the cases we do is make sure that whether it's up case in my case, it stays the same all the time. Jim. Health minus equals What to say? Four is over. He loses his health. And then we're gonna pet print to so right, give me something cool. Hip gyms. Health is Colon will end the text here Nike and spoke common here. And now it's gonna print both this group in the text and then straight after it's going to print the variable, which is quite cool. So let's run this. Make sure I have to find this very quickly. So starts off with five health. That's where this say Jim is alive. But then Jim felt Jim fell over. Jeb's health is that it prints the very before, and that keeps going until this know, what we could do is a Sooners. So we're removing. We were where we were indented. Here. We're going to remove that indentation. So it's here. Good. I'm gonna pick Prince. Okay, over. So this is only good to print. Wants this wall leap has finished. Okay? Because in python just reads top to bottom runs like this. So it says, Oh, here's a wallet. Okay, We're going to stay in this loop until it finishes. It finishes when it's no local. More than very. And this government came over to be around this way to redefine that variable at the top. Apologies. So here we go. Goes 43210 Game over. Okay. And then what other cool trick that they use sometimes in games as you could just put wild truth? Because how diapers is kind of the default, that true is true. So when you say Walter is basically saying, Run, we're going to do something like this. Uh, so what? This is running. Essentially, if I was just put Walter reprints running like before is getting the same thing. So you can't say that. So what we can do is you something called break. And if we put this essentially assumed is the loop gets to This is going to stop It just says this break just basically finished that. Stop it, You could put here. Stop! So I said, you gotta print once. They're basically the fact that I'm doing this thes infinite loops tends to be unhappy, but we could keep running for no. So essentially, we're Paywall Tree prince running. So what we could do here is we can say, you know, if something happens. So, for example, I say weaken define a variable use Ah, input equals, but keep running. So basically, every time we're gonna be asking the user, you want to keep running and then we're going to say if use ah, input is equal to no And they were gonna invent this here break. So essentially, we're creating wildly. We're going to keep printing, running, and each time we print running straight after, we're going to ask the user again to keep your job to keep running. If the user says no, that break. But then if they if they don't put in there, is just going to do it again and then once it's break we're gonna print this stuff. Okay, so we're gonna run this now. Keep running. Uh, and I can put anything in here. It doesn't really matter. I could pull ever in there, but it's not writing no. So it's not going to break. It's just going to ignore that and go right back up to stop. That's gonna print running and asked me again. I can keep doing this forever. I could just type in. Yes, it doesn't actually matter why, right? As long as I don't write. No. And here's another important point I could write No, with a capital end, it's still not going to rock. So let's say, for example, I'm just gonna type in the external use. It stops. It stopped. Now what I could do here if user input equals No, I could also put user input again. Same thing equals capital as well. So now basically, it's going to stop if either of these things a typed in no case or a place so keep running . Yes, whether I keep life in this. But now if I put in capital and then it's going to stop us, well, so that's us using this or that we went over in a previous sector. Okay, so in this lecture, we've gone over the wild leap. So I recommend you go over this counter thing. You try it yourself, set yourself for counter, and then run a while. Loop on and on, then, yeah, have a counter slowly decrease. Well, you could do it the other way. So you could do plus equals. Let's just get that we drive. So the counter equals here, and you can say, while counter is this very cool to 10. So our county equals Siri, you can see is going. 1234 47 9 10 11 Okay. And so the reason why it's actually up to 11 now. So while counter is less or equal step so far removed the equal to you just got to If you encounter again. Which Capstead. Okay. Thank you. So yeah. Give that. Try yourself, play around with it, and then try. Try doing the exact same thing, but pay into more of a game perspective. Because essentially, I want you to build on intuition on skills and in being creative. So you're actually defining a problem or a game or something? and you're achieving the outcome by game, creative yourself and then try using this wild truth and using a break. You don't have to use the if statement if you want, but it's quite courting to practice. So work on most suit. Three things on. Once you feel like you've got a foundation, some confidence in it. Move on to the next lecture on. I will see you there. 14. Lists: Okay, so now moving onto lists lists are very, very important. They are used a great deal in artificial intelligence. We use them to create matrices of information, essentially lists. You can think of them as just a lot of different bits of information held together. Um, So, for example, you could create a list assist, create few of these above this always contained in square brackets. So you could Kravis, that includes all of these things. They could be the same thing reproduced twice or as many times you like, so I could create the variable called on my list. And then if we this here is my list. As you can see, this is the list. No, no, only can we have inter, just But we can also have because we have inches. We could have strings. We could obviously have floats. We course have variables as well. So if I create variable here called, uh, A and I can just put in whatever the Christmas here, we can put that very blond hair, and we can also put in other lists so we can put in a list within a list. So, no, If we print this I'm just gonna water complete this. You can also complete. I think we went over this in there. Initial tutto pressing tab. It's sort of completes. So as you can see, this is my nice, jumbled missed se through this gate, for example. Let's say you're a bouncer of of a night club and you have a list of the eyepiece, so we will call this bounce of boats. We have, As always, Jim is always welcome to the party. Um, the only, uh, fee on Let's go for Judy. Okay, so these the V i p s. So if someone comes to the door and they say, Oh, my name is Jeb Okay, that we can say if gibb this in the i p prince so bit he is in the list. So he's allowed in so lists. As you can see, they can have numbers. You can have strings, you can have variables, and you can also have other lists. So, in machine learning artificial intelligence, we use lists within lists within list. Quite a lot. They're just really, really simple and useful ways to hold it data. So so selecting an index. So let's create a new list, and I'm just go call this new list Equals what? I'm just gonna fill with numbers just because it's easy This way. So this is my guest. Now. Each of these hasn't index, and it starts with zero. So this is number zero index in. So number one is index zero in the list. The number five is index one index to you. The next three index for in finally Index five. So always starts with an index of zero. So what I'm gonna do This is how we're put new list. This is the name of the list. Obviously, they're square brackets. I'm just gonna put the number zero now. This is basically referring to the zero index. So it's really the first element in new list and it returns the number. So if I were to put in a new list square brackets for what do you think would come out of? What do you think it output would be if I run this? Have a quick things yourself. Take a look. It's number faithful, because we have zero one to three four, so it returns the fourth index. So it's a very useful thing Top. Okay, it's no. We're going to get through a few of these different things so new, this don't index. So this this way I won't say in my newest Ivan over 89. I want to know what index number it is and it's going to tell me it's number three on Let's just test that here. So if I put in new list three years ago over 10 89 Yes, it ISS So this is how you find out the index of something in one of your lists. OK, now let's look at a pending A Pending is essentially just adding on a new element to your list. And when I say element, that means what was talking about before strings, integers, variables, everything. So I'm gonna put new list on this important just like I did here. I put the dot Okay, so this is basically adding already existing function, the upend function, some saying Do this function the upend function to new list, and then why want to upend? It's the number one million. So it's now a pendant. That's just check. So now at the end of our list, we have one milion. Okay, so this time. I don't just wanna add it to the end. I want to add it to a specific index. I want to put it in between the numbers five and seven. So I'm go after this is index 10 Sorry, Index one. So we have to create New Wonder Index to some girl pit new list dot Insert. And now, for the first value, I have to put the index number, which is going to be, too. And don't get written about you. I'm actually gonna put in a string, so let's see if this is worked, as you can see it in next to we now have. Hello. Um, but I I don't like having the text in there, so I'm going to remove it. So I used this final fortune here. Relief. I put new lest dot Remove. Hello, Andi. Now, let's take a look. See if that's worked. Yep. It's not over in there. Now, if I try and remove again because it's already been removed, I'm gonna have an era. It's going to say X not in list this X here of first to the head. Oh, that's mine. Okay, so you're converting something to list. So essentially, if I were to, uh, this would be like using this convention. So actually, as a matter of fact, I'm going to leave this for the next lecture because I don't get things too confusing. I'm just gonna touch on this if in, because this is a useful way of doing so. We already did this once before. By what? A touching it again with our bouncer bots. So I'm going to create a new list, my list because those who run the numbers and then what you can do here is you can say if the number five 78 is in my list. Sprint 578 is in my list should return and outputs of that that we get so in the sector, warfare gone through. We've gone over what list side, which essentially just a group of elements and each with their own index, and you can put in numbers. You can also put floats, which I missed here. We're just type in just to make sure it is explicit. So you got introduced, you've got floats, your boat strings, which are text even put in variables like we've done here. You can also add other lists, which is quite cool. So then what we did is we looked at an example where we had a V i p list, so it show it showed with the uses of it, you can have a list of different names on, and you could just say if that name is in the list, then return coming If you are about to About then, of course, we looked a T indexes. So if you state an index index over three, you'll get 0123 You get the fourth element in the list. Just remember, the index always starts with zero. So when we went into a few of the basic functions, you can do some cool things you can do within list. To find out index of an element in the list, you can add new elements into your list of the end, where you can insert new elements at a specific index. You can also remove elements from list if they're already in there if they're not in the list that you get there. So what I recommend you do is you just go through these different exercises, write down these different functions here in next upend, insert and remove. I also suggest you just create a few lists. Onda have fun just trying. Teoh, typing in different numbers of the index's getting elements out on dry. Play around with this indexing here with with adding Lester lists. And then you can try indexing. So that's that's where I come in. You do. For now. I want you feeling confidence. I'll see you in the next lecture. 15. For loops: Hello and welcome to the four loops. So four loops are very useful in a great range of different applications are specifically they used a great deal in machine learning. Andi Artificial intelligence. You might remember I showed you the code for convolution your networks before, um, which is basically basically a type of artificial intelligence machine learning on in pretty much you might not see here pretty much every time I create some kind of model for machine learning. It will include using a four leap at some point, often multiple for leaves. So if you're looking to get artificial intelligence, it's extremely important important to understand them. Actually, if you're looking again at any sort of project that involves Python four loops are incredibly useful for iterating through certain things. So we go through some of them to start with. Let's start with something very basic. You can actually use a for loop iterated through some text. So let's say we have a name is equal to Harry. Okay, Now we're going to use a for loop to print off each of these letters one of time, so we're gonna put four now. This is the first part to get your head around for something in name? No, essentially, this could be anything. It doesn't actually matter what you put. A lot of people tend to put when you're just doing, like an example. We just put the letter I there. So for I in name. But you could also put letters because it's it makes more sense when you read it for letter in name won't make it even clearer for each letter in name. Whatever is we'll go over that again just in case doesn't make sense. But just like with the F statements with we've put this part here. And then we had adding a colon that on the next line opinion indentation, we're gonna say it's a typo. We'll go change that toe. I just because it's easy to write for I in name and name. That's the variable here. Print. Hi. So what's gonna happen now is on each time we go see one letter so first printing hates than a than our than otherwise. So like I said, we can change this to anything we want. Just certainly guess we also at that end here as well. It's good that exact same thing for Billy in name Prince Billy. You can pull everyone, but it's basically saying for everything every single parts in this print it okay, But it's important because you're saying for every single in there the reason why experts on me in there is because the program needs to know what to do with it. If you just put for I in name, it's just gonna come up with Panera. So you want you want to do like this? So next we just talked, talked about lists. So going to this here I've created some example lists once called example list 11 isn't empty, lest called less t called new. Less so, Andi, As you can see, there's nothing in there, but it's still arrest. We use a for repair so we can say for I, in example underscore list Prince pipe. Never think yourself. What do you reckon is gonna come out here? So what's gonna happen? Is there going to get each of the names coming up one at a time? We're iterating through this list and printing out each of them. Okay, let's look at an interest Example. We're going to use a four leap But we're also going to use an if statement because basically, I want to create a list. I only want to have friends who have at least four let four characters in their names because I'm just kind of weird and picky like that. So I'm good deal. I'm gonna say it's right through this list, and then I'm gonna put here if the length So this is a new thing l e n that saying length. So if the length of I So for the first element, that's gonna be Jim, Right? So the length of isil length of Jim is gonna be three. It's three characters long. I'm just gonna reinforce that. I'm gonna put in the length of the example list. So this will return five because it's five elements long. Now, I'm gonna pit. If you remember, we talked about indexing lists, so we're going to get zero index from this list. Which Gov. Jim? Because this is zero index. Bob is one Lucy to etcetera. So this is going to look at Jim. Mr. Gorton. Jim, the length of Jim is three because it's three characters long. Okay, just go that clear. So now, if the length of I. So the 1st 1 is going to be Jim. But this is full of them. So if the length is less four So we got were saying, If the length is ah, it is more than or equal to form to make that simple, I'm just gonna put if it's more than three. If the length of the name is longer than three, then we're gonna add it to our new list. Because this is the nest where I want to say, right, these are gonna be my friends. It's just change that two friends list. If the length is more than three, then we're going to say friends list thought upend. So if you remember, that's a function we used in the lead in the lists lecture. So going to append. All right, so what we're doing is we're saying, look at each of the elements in example, this one at a time. Now, if the length of the element is more than three, we're going to add it to the friends list, like it, uh, and else so otherwise, print right. So if it doesn't get added to the list because it's it's not more than three characters long. We're just gonna print off. So if we run this Oh, So I had seats to find this So is printed off all of the names that aren't longer than three characters. Um, no. If we print off our friends list, it should be too long. It's got Lucy and Hannah, which thes these are gonna be our new friends because they're cool because they have more than three characters in their name. Okay, so we've done that now and now we're gonna go for in range. So this is another thing we can do with with it with sorry for lips. So for I in range 3 to 10. So let's make this a bit You just start with for I in range. Prince, I This is basically gonna when you do in range, just like with the list indexes. It starts with zero. Let's go print all the way up to nine. So never includes the 10. The number that you put here, but it's got 10 different numbers here, so this could be useful for arranged everything. So instead of printing, I hear I could print running, for example, and it prints it 10 times. You can do it, starting it from anywhere and finishing anywhere. Such started the number three finish of the number 49. So we put print. I hear it's gonna print the numbers from three down to 49. And again, we can change that too. Um, hello. Whoa. Many, many times. So these are the different 40 ways you can use four leaps. So we've got over basically in a very sorry in Texan string. You could go through all the letters one at a time. You could iterated through lists, and you could do cool things. Like adding, if statements A pending them two different things. There's an infinite number. Of course, things you could do with lists on then we just did in range as well to finish off. So recommend that you try out these three uses for four loops. Andi, once you ready? I will see you in the next lecture. 16. List comprehension: okay. I just wanted to introduce you quickly Teoh concept called list comprehension, which is basically a cool way that you can create your own lists. So it's very simple. You're basically combining lists with four lips. So I'm gonna go create variable called on my list and with square brackets. Because, remember, we square brackets for lists we can do, we can create very big list of numbers, for example, by doing I for I in range 100. Okay, so we're basically moving around the format of a four leap were saying create. I create elements for for every element in range 100. So we're going to get everything from zero up to 99 1 lovely, long missed, You can see. So maybe this time will make a bit cleaner. I would say that's Ted. So I've got nice list here. So with this comprehension, you could do cool things like this. I just want to introduce you to the concept of this point. So have a go yourself playing around with this. You can even like we showed them in the previous lecture, you can add starting value and unending valley. So you have like this. So give it a try, have some fun, and then I'll see you in the next lecture. 17. Cool things neural nets: Okay, so this is a marriage. Want to touch on very briefly with lists, as are saying they're very important, for example, in artificial intelligence and machine learning, because that's how we tend toe put data into any of our machine learning models and matrices. I mean, you might have heard of the word matrix before. They're basically just just a series of numbers within lists. So if you just create one list like this, look it, then you've got just list, right? But then what you can do as I mentioned before, you can have lists in lists. So now we have what, you cool at array. But what if Okay, no, stay with me. Illness. If we put these two lists into a single list, so and then we do this, let's say twice. No, this might take a little while to get your head around, okay? And I'm just touched on this briefly, just in case you have a curiosity and machine learning, because this this is very important right now. This is a three dimensional matrix, essentially what you've got, you've got two lists with in a list. Yeah, but now you've actually got these two again within list. So these this is just one element within a list, OK, and then you've got thes two elements within the next the list, and then you've got third list. So it's a three dimensional matrix. Like I say, if you're just looking to them python, you know that interested, then don't worry about this at all. I just would be a cool thing toe add in and mention. So, for example, with images when you when you take an image and put it into a model, it would turn it into this format for each of the pixel values. Pixel values haven't RGB values red, green and blue values on De. So it's expressed by the height, the width and the RGB value. And that's how you get a three dimensional matrix for an image that you'd run through, for example, an image classify in artificial intelligence. So just touching on that very briefly so that it goes into head. So if you do away further courses, you're already slightly prepped for the data preparation, and it's a cool application of lists. I think so, Anyway, I hope that makes sense, and I look forward to see you in the next lecture 18. Practical 2: Okay, welcome to the second practical congratulations on making it through this section. It's there's been a lot of information to deal with. Eso will make sure that this part isn't too intense view, but it's still were able to solidify all the different concepts. So in question one here, you just wanted to return true for all of these below. So, for example, you're gonna want to write something here to fill in the blank. And here you have something at the start for the blank here, and you want to run all of these cells in order for them to say true at the end, the move go begins going into, if else statements while loops, creating some lists, printing an element from a list. So selecting just one thing running loops for within a list, etcetera. So one thing to note on this one that you need to yourself, which is my mistake. When you select this one here, the actual list change that from mark down into coat, which could do by just tapping the letter. Why? Because you're going to need to run that list in order to do these. One of these questions here so best of luck. If you have any troubles, remember, try and persevere. You're really gonna be developing skills of a real developer if you're able to persevere and problem solved by yourself, don't put too much pressure on yourself. You give yourself 5 10 minutes toe. Usually resource is then use online. Resource is, And if you really feel like you're stuck, of course, the station's afterwards. It's important just to give yourself 5 10 minutes of problem solving, trying to build intuition, some confidence, the skills you required for you to become a strong part of developer. So best of luck, and when you're ready, you can move on to the solutions. 19. Solutions 2: Okay, so I hope the practical went wealthy. Now we're just gonna run through the solutions together. So the first question here, it's all about using what would learned about these comparisons on slash or equal to no equal Teoh in Not in these old things. So the point is, Teoh return truthful of the falling. So, for example, here 10 is less or equal to two hundreds. Okay, So in order to have, true to have, this is saying one is equal to, Of course, the anything that one is. Equity is one. So you run. That's true. If I put anything else to Oh, okay. Letter skeleton force. So you wanna have one is equal to one. Something is more than nine. So any number basically that's more than nine. So that's 10 for example. Just keep in mind you can do this. Says bit more cramped. Uh, I much prefer to do spaces here, So tennis hope more than nine. Well, not exactly. So now first we have to run this cell to create the variable ls for its list. And then we this you basically want to feel in something here. So six something list so basically one of six. You can see that six is an element in the list you will put six in ls if I put six is not in at less would get force. So you wanted to put six in s. So finally here you've got something is not equal to six. Andi for is equal to something. So you want to return truth? So first for the obvious 14 is equal to four. And then you could put anything that's not six. So I think you could put in some tech step on. That would return true because he is no equal to the six. The only way that this would be false has ever put six. Anything else I could put? That list here is equal to 60 Interesting. OK, so if I put it at less, actually it has six in it, so Oh, that? Of course it returns true because it's no equal to six. So if I put six is no equal six year that you're doing force by mistake, I still need a coffee. So basically, if you personal use, But anything else there six that writes I could put ls and that will return. True because l s is not equal to six on for a quizzical before. So two true statements there. OK, moving on to if else no, off use of the age. Okay, so let's just start with that first. I'm guessing we're going to put that through an if statement. So in order to do that, I'm gonna have to set set the emperor in up as it variable so we can do what we did in the first practical Chris available. Could use their age inputs. What in speech marks? What is your age? Okay. And then with this, uh, we're over puts another another. So once you've run this, if they're under 16 tell them that they aren't raised Drive yet. So let's start with that. If use age is less than 16 coat on a case. That's how we set up our if statement, if whatever. So here we have the user age is less than 16. Just press enter and know automatically and dense. Then what? We wanted to tell them that they aren't raised. Drive. So prints you your notes. Ready to drive. Okay. If they're exactly 63 congratulate them and there's another F So the most efficient way to do this, I could put, because this is just one thing happening. So if this happens, tell that race drive yet if this happens, congratulate them. But for everything else. So if they're not over 16 if they if they're over 16. So if they're not under 16 like you're saying here and if they're not 63 then do this. So what we could do is this last bet would probably be useful as else we could put the 63 thing as an LF LF, if you remember, stands for like else f or you could say or if so, you're saying if these rages lesson 16 about a block or if so, we gotta put user age. The two equals sides. Say, LF user H is equal to 63 code could greatly congratulate There will be awesome. Okay, Daiki, corn grants relations dotted up. You also okay, Abed, Basically, the last thing is basically saying so. If there if there no under 16 all the 63 then tell them there is a drive. So we could just put as in else, because that covers everything else. apart from these two statements, so else print, you are ready to drive. So that's quite a lot I can imagine. For your first off. If else this is this is quite a challenge. So don't get overwhelmed with this. I strongly recommend if you found this difficult, use your imagination, play with it and just create a few, if else statements by yourself, won't you confident just using if else that bring in this? LF for certain situations, I strongly recommend you do at least five times in the next two days just to get your head around it. But if you are comfortable with it So you struggled a bit, but you got there. Congratulations. Really well done. So you run the cell and that's put in age. Let's go for four years old. What happened four years old. Okay, let's see what's going on here. Okay, so this is important because I actually put a hidden here as well, which I failed to read. Hit user input is always a string, so we'll need converting into an interview. So whatever we do this input it always by default. Whatever the user pitted, it comes out as a string, not an interview. So what I'm gonna do in order to convert this intern insta it's a really cool thing. I just put it and then put this in brackets, and that's going to convert this to an interview. A re important note to make it okay. If I create another variable called High and I create some strings, you say hello or wherever. So I've now got this variable. What to do? I can't just convert this Internet project. I try this. It's going to give me an error because you can't turn this word into a number. It just doesn't work. But if you have a string, that's a number like this. If you can't on the Internet, you okay? So what we do is just put it which stands for integer. Then put this in brackets. This is now returning an integer of the string four. So we now have little before the cake cause of cool the street. OK, that's just try this, then instead, see if that self the problem. So as you could see, everyone gets errors. They have to try and prove himself sometimes because you can't remember everything. Okay, so it's very happy with that. Basically, it was happy that was trying. Teoh automatically turn injured in steel. What? I'm stating the variable. So Okay, that's putting for again here. And instead, what I've done is I've basically each time of using use age here. I'm just converting Internet. You're here. So it's happy with that s So it's basically saying, if thean ginger of this string the string is four is less than 16 pretty no race drive. That's what's done. Now let's import it as 63. Okay, we'll put that. Run it. Congratulations. You are awesome. Thank you very much. Now let's go for 40. Your rage, Dr Perfect. That's jump in that car. Okay, now, moving on to wa leaves creative character as a variable less overhead there that has 30 health haven't lose one health steadily due to poison when their health reaches 10. Printer warning. Okay, so I've made sure to give you guys clear directions on what you're intimating instead of just leaving you to work out what you need to use because we're at this early stage. I thought it best to leave you with these sorts of these kind of problems. So good. Create character, variable. I am litchis gonna call that character. I'm gonna give it 30 health. Simple as that simple. Is that case I'm going with that. So I have variable. That is where 30 I'm gonna pitch while character, which is over able, is more than Ted. Uh, yes. That that will work. Like a wall character is more than Ted. Let's just print off character to show that what their health is. And each time we do this, he's gonna tease one health. So we're gonna character. This is a weapon. Character equals character by this one. So, as I mentioned before, code with python, it goes from top to bottom. So it's gonna go this first. So yes, the captures more than 10. It's 30 this point Prince character, the open 30 on. Then the variable is gonna be reassigned to 30 minus one, which is 29 at that point is gonna get to the top here. It's gonna be 29. Yes, is more than 10. Let's go. Keep going like that. You're 28. 27 instead against to Ted. I wanted to attend. This wallet is going to break so just to make a big show on this, but that you can make this a bit more succinct. You could just say character minus equals one at this exact same. A Do what we just said before. This is saying character equals character by this one, basically. So if we were to do this now, if I wrote this, it's gonna pretty everything down to 11 once against the 10 it's just gonna break. But what it says here says when the health reaches 10 print awarding. So at the end of the world leap, make sure it's no indented ready prints warning. Your health is 10. Say, if you're on this now, his is a problem. I'll give you a second to think about why this may not have worked this time. Okay, I'm guilty of this all the time since you What's happened? Teoh is I read this right, and at the end of it, this character variable was already at 10. So of course, this starts while it again. While character, which is already quit 10 is more than 10. Do this, but it's not just going know that it went straight to print warning. Your health is 10 So what I needed to do was actually reset the variable at 30 on. Now, if I run out, you can see it's working fine. Gets all the way down to 11 and then it gives me a warning at 10. Okay, maybe on two lists create a list that contains elements that are strings images. And he's one very born. Another list. Okay, so I'll get it. Unless I just like to fighting my variables for a list as l s u could define it. However you want use of square brackets, I'm just gonna put in some strings. Uh, can spread the character variables. Well, so we have four elements. Adds a nice little tip for you. If you want to see how long the list is, Let's say you have a gigantic list. Just put lead, which stands for length the l s. If you run that, it tells you how many elements are in your list. So something to definitely make it off because it's quite useful. Ah, so we've created the list. Now check the type of this list like it. So it's very simple as well over the election before you put type with princes and you put it ls like footed type character. What do you think that will come out? It's Joe, of course, but that s It's got less so printed element from first. Okay, hopefully this hit was helpful. You put the list name which minus ls and the square bracket. You could put the index say, Remember the first element of Leicester's Index zero? That one, then two, then three. So I'm gonna select to print out that a Soviet index one and every time I'd say if I put a serious girl returned to the five. If I put Index, Ted is gonna give it error because there is not an indexed head we connect you. So always the Adele with a four loop run the cell below for rituals. OK, so this is why I mentioned before the who get in describing the practical you to turn that into markdown. So I said she I just went up here Isolated code Sorry from markdown. But also, what you could do is if you just click here, make sure it's not in here outside of the box, just a type why it turns into code. So run that so we're creating. Ls as this is now, this list multiply east list of this element in this. Each element in this is by 10 imprinted. Okay, so use going is a fully appear to it rate through the list. So you could say four. And then whatever you per here doesn't matter, but I or put dumb suffered number for each number in the list. Oh, Lord. And there are new light indented. We're gonna pit, uh, Prince Princess Dub times 10. So what we're saying is, for every irritable in this list, print off that it That's element times, Ted. So we should get all of these in Allied, but 10 times bigger. There we go. OK, What I was talking about was the one thing. One thing you could do is you can put you credit available u equals double times Ted, and that I could just print itself toasted here. Could you? Maybe that's completely up to you. It makes makes no difference. The other way was actually slightly smaller. Shorter looks a bit nicer. So maybe just leave it with that because that would be if we wanted to do lots of different things with that. But right now we just want to print it. So this is the easiest. Okay, this is where things get interesting with a list comprehension, and this is kind of moving on to almost already an intermediate concept. What a lot of Kate Create a list of numbers for between 2020 and 30. So if you buy list comprehension is where you have square brackets and use a fully been a different way. So you'd say No, I because I enjoy it. I for I n rage pretty too. Now I think this will output. The less Stone Age create is a variable. So the reason why I put 31 is because it always includes the first number, but only ever includes. Never includes the goes up to you but doesn't include the last over. So this is how you do this convention you put in square brackets. So let's just put that was dubbed just to show you it doesn't better what you put as the days these things Azzam visit the same none for dub It Ridge. If I was I for dub example is given era because it says I was notified Hey and that's how you do this comprehension. So that makes sense. If you struggled with anything, feel free to comment in this lecture, you share what? What you're finding good. What you find difficult because it's great to be part of this online community as part of this course, and we can share what's where the struggles are, where our strength and together we could get a lot better. So leave a comment less, know what you thought was good. What was difficult, any things you re struggled struggled with, Ah, highly, highly recommend at this point to just go over the concept a few more times. Go through that part of the lecture. Do something your own research online on until you feel feel confident enough to move on when you're ready, Let's move on to the next section. 20. Basic functions: and lay there, So we're going to be starting on basic functions. We've already been through a lot of different concepts, so I won't say well done for getting to this point. Give yourself tap on the back on Let's get started with functions. So functions are very, very useful. Things toe use. There have a lot of different locations and so big a through a few of them today, and it might take a little bit of time, just ah, grasp the concept. But once you've been over a few times, it makes complete sense. So essentially a function is Ah, Siri's off different things you can do in one go. So, for example, I'm just gonna create a made up function called food. Yes, I'm going. Call the name of function and inside I'm going to put, um, let's see Prince have a print. How ah Yew. And let's just say that's it for now. So why three? I run this cell and nothing's actually going to output because I've simply created a functions like a template. So if I were to what we say, cool the function, then this will happen. So now in any other line I can just put food and by printed the parentheses, I run it and then that happens. So you can put in as many things as you want in here. And you can also increasing complexity by adding inputs. Say we were set up death for you to and in these brackets. This time we're just going to put a variable that's called X. It doesn't really matter what you call it. Same as in four leaps we need to do is make sure you use the same variable. So here we're using X. So when we call it later on like this, we're going to put a value in here. So let's suppose that we are in. We're going to be in putting a name. Okay, So X is going to be John. And we could say print Hello there. You remember I could put a comma and then x good put space after Hello, Sasko Prince. Hello, John. So I create that function on now I cool it and outputs can be heard. John Now here's the cool thing. I like it immediately. Call the function again this time with different name. It's gonna be had a job and you can do that is for any any different things you want. You could if you wanted to use interview just ahead a three, which doesn't make much sense, but I think you get the idea. So basically, yeah, you can put anything within these functions, which is really cool. Another thing that you can do is if I set up another function called Deaf Food. Three is I can print something like cooling function. Did it? Did it did. And then with inter function, I can cool a previous function. It's like I could call the first function here. So again, when I run this cell, nothing's going to happen. But now if I just cool through three, this is going to first will print calling function and then is going to cool the function food. So just give it a try. So as you can see first of what's printed according function. And then it's called Food and it's printed out all of this. We could also do food to here and then put in whatever we want Mr Function and he can see that he happens when we actually run cell. But when we will be cool. Just threw three here said, You know, this isn't going to be called here. This is This is a good thing called, but for three years going to be caught. Then it's going Teoh print calling function. And then it's going to call food, too, with Mr Function says, Just go print. Hello, Mr Function. So let's give it a try. And there you go now often in functions. Thea Output. You're going to want to store it. You're not just gonna want to print something. So what we use instead of print is we use return so we could use an example off. Let's say you have an online account for something, so I began to have We're gonna have a function eso you say death. And then in general, you want your functions. Teoh makes sense. So let's say in this example, going over accounts where we take uses money on let's say we remove £20 or $20 from their accounts and then afterwards we want toe basically from the output with outside of the function we're going to then look at it and say right, if it's if their accounts is now less than 50. It will send them an email or something like that. Warn them that there they've gone under. So we could we could call the function something like, That's a money removal. And then in here, in here, we can just put the balance. Okay, so all against is we're gonna take the balance, which is thes is current amount of money. We're going to take away 20. Okay, so we're gonna store that as a new new variable called New Balance. And then what we want to do is we want to return new balance. Because if we don't do this, then essentially new balance can't be used outside of this function. So you want to return it outside of the function so it can be used by other functions, for example. So this is our first function that we can create another function koot deaf. Um, death check, because we're checking for whether the person whether the balance is is still over 50 or not. So we're gonna put into this you balance. Okay, Andi. Then we're going. Teoh if the if statement. So if new balance there's mawr than 50 continue, so continues to useful thing. Just to basically say you don't need to do anything. And then if that's right, uh, else the only other thing could be is that it's left investing 50 else. Then we just have a print. For now. Prince, you account is this. I have to look it so if creativity functions now Oh, that's right. Not continued. Pass my mistake. So, yeah, when you're using, If statements used pass, you continue inm or like in for loops on in wild leaps and such. So now we're gonna call them both. Say money removal is our first the function. And let's say this first person has 120. So it does provide the outputs in Jupiter Notebook Hasn't printed it? No. Outside of the function. I can then just put this Okay, Okay. I just need to check something on De So essentially what we actually have to do just do if debugging there. So, first of all, we call the check function and within So if this parameter instead, just calling a parameter new balance wants have run the money removal function, we actually just put in the money removal function as a parameter When we put in the current balance because essentially, this returns it. But it has to be used right away by another function. It doesn't get stored as a new variable. It just needs to be used straight away by another function. So what we're gonna do here, we're going to cool a function within the parameter, which is pretty cool, I think on just to make sure nothing blank turns up here. We can just put a print. We remove this past. But it's a good thing to make note off using this past thing. In case you didn't want anything to print, your account is more than 50. So as you can see, we've run hut with 100 and 20. We could actually just put here the new balance as well so we can see exactly how much there is every gate. It's 100 week, even, but you balance is so that looks a bit nicer. Now you're Countess more than 50 or new balance is 100. So now let's try cooling it with 60. As you can see, our account is now less than 50 and we could also just use this as well. If you're in the snow. What I can't. So, as you can see, I've put in an extra quick mark here. That's why it through an error to blue. There we go. You can do that for any numbers. Now just play around with it. So it's already starting with less. You balance zero. Let's see what happens if we only have five were in there on it. Now we're overdrawn. Okay, so we've got over quite a lot today on DA. But as I say, these are really useful and in artificial intelligence and machine learning. We use functions really often because it saves so much time because very often you want to do the same thing multiple times eso we set up a function so that instead of each time having to, you know, do all this for every time we want to check the balance now from no one, we can just do this. And it's just so much cleaner on DSO, much less code we have to write. We can just keep doing it in just one line instead of each time having to do six lines of code. So it just makes everything a lot more efficient. So the main things that we've gone over today are creating a basic function. So we always use this death at the start and then we provide the name of our function. And then we have parentheses in which we can put parameters and then we indented just like we do with four loops. If statements most things on, we put in what we want the function to do. And then we can just call this function by calling its name and adding the parentheses. So then afterwards we looked. It's how you can create functions that require inputs. So here we have created ah function with one parameter, and we've used that in create printing a string on. Then after that, we looked at returning variables on and as we saw, a variable will be returned to the end. But it's not stored to be used in future piece of code. He needs to be used right away by a function, which is why we did this. So, essentially, in our first function here, we returned to variable on this variable was immediately put in to this this next function . So what I recommend that you do is have a play around with this. Take a lot of time just to create a number of functions, just toy functions that just you can have a bit of fun with and really get a good feel for it because they're so important. And try what we were doing before. Like calling a function from a function or from within a function. But why would mainly focus on is just creating function like this death food? Try creating a function that takes a variable. I'd say those are the two main things you should focus on for now. Andi, having this return is like the icing on the cake. So if you can do that as well, then perfect. So once you've done that and you're feeling confidence with foundations, move on to the next lecture and I'll see you there. 21. Implementing functions: you say we've gone over the basics of functions on now? I basically wanted to provide a few very simple examples that could be used to help you to build an intuition and the confidence about how functioned work. Make sure making sure we go over every part of it. Basically, whilst we do that, I'm going to go over to useful functions that we use in text in writing strings quite often , so dot format we use I use in pretty much every artificial intelligence program I write on DOT Upper is also just something useful for you to understand on bits you useful in cleaning up data in databases. For example, when we're preparing our data to run it through a machine learning algorithm, for example, so they're both very useful. So let's start with greetings, but we're going to create a basic function. Let's say that a hotel has bought one of our bespoke robots that greets people at the door of their hotel. When someone checks in, we take a picture of their face on. Then whenever they walk in photo again, the greetings bought basically can say hello to them by name, which is quite cool. So let's just write. This will take about two or three lines of code. Teoh greet someone by name. So first, we're going to write in death. So defining our function. If I already mentioned that death stands for define and then we're going to come up with a name for our function which could be greet. And then our parameter will be the name of the person. And then we could Bryce like this prince. Hello Coma then a comma outside of the quotes and the parameter name. And then come again. Full stop. You are Well come. Have you guys like my robot action? I've been working on it all day. Uh, site we could write it is this and then we call the function greet. I think we're in the name of CGM is coming along for the ride, So Hello, Jim. You are welcome. That's our robot speaking. Good job. OK, but it z not as nice as I'd like And this looks a little bit messy. Eso I'd like to make this a bit more succinct. So what we can do? We can actually remove this here like so And instead of just having took you remove you Remove the string at the at the parameter in the middle. We can actually spoke placeholder here, which is the curly brackets eso on my keyboards where the scared of square brackets are You press shift and press the square bracket on. This will come up Um, you are welcome. And then we can put at the end after the string. So that's after the quotation mark. Doctor formats. And then here we can say what we want to go into this place older, into the curly brackets and also you want name to go in there. So if I run, this is going to the exact same thing, See, except there's no longer a space in between this on before Stop, which is nice. So you can do this for multiple placeholders, which is also very handy. So that say, now Jim is bringing a couple of friends with him. I just name three. And for those four people coming in, So now we have to do is this. We put in four place orders and then in the former here we put to they three they for, so it works in order to the 1st 1 here. Well connected the first on here. 2nd 2nd 3rd 3rd 4/4 Just like that. So now in greet in the when we call the function, we actually two cool four parameters. So Jim is bringing his friend Jane. Jane never goes anywhere without Bob. And of course, Bob insists on bringing it salamander and it bobs a bit different to go on holiday with, but we fought for them. So now it says hello, Jim Jane, Bob Salamander, You are welcome. Say, this is a pretty complex robot because he can No, I need to take the face of humans, but off salamanders. So I think Google might be interested in buying this, actually. So if it was interesting going into business with me, let me know. Um, so this is our function. Just three lines on. If you contrive imagine doing this without using a function, it would take a lot more code. So we're going to look at something very similar now with security bots. So, security Bob, let's take a look at the dark. Professed to give some context. So I'm going to just say Prince Hello. So what you think is gonna come out of this. Hello, Right with a capital letter. Old age. But if we do hello and inside these princes we did dot upper with parentheses afterwards. So this this is a function we're calling. There's a pretty defined function we haven't set up anywhere. It's just part of life in this will turn it weren't up case we can also do. Make sure you had those print theses afterwards. It turns orange alert case. So this is a very useful thing. It's used a lot in cleaning up data. Let's say, for example, in you you have ah, huge database that has has a load of names on Let's say they're they're written in manually and you want to know how many times Harry appears okay, But his thing. Some people might add Harry like this, so these would actually be two completely separate things to a program. So what you need to do is go through the whole column and you could just do dots lower right, and then that would turn all the Harry's. So let's just put your name. They say they say That's the column. Don't lower. Then along the up case, Harry's would become this one, and it'll become the same. So using dot lower is actually very helpful for cleaning up data when you're preparing to run a machine learning algorithm. So it's important just just to use it a few times. For now, we're going to use the upper, which turns everything into up case because security bought likes to shout. So basically, in this function, we are sending robots now to homeowners on. And if it senses someone's in the house, it's going to say intruder, Let's, is that you and then ask the name off the of the homeowner So we want to have a function. So I've got to find the function, uh, scared of that heavy. Who you gonna find the function on? We're going to call it a lot. And then the perimeter is the homeowner, and then we're going to print. Um, we're going to also use dot former here again, just a Naylor in. So intrude uh, that is that you and then we have put a placeholder, then a few question marks. Then we do dot former We're gonna put the homeowner here. Okay, so right now we're not using up a little that's just run this just to check it a lot. Homeowner's name is, uh, rude. Intruded. Let is that you get rid. Okay, so it works very well now at the end here. So after home, after the dot former homeowner, we want to turn this whole thing into up case. So always to do this type dot upper another set of parentheses empty. Run it. And then everything becomes uppercase, just like magic. So I hope this this lecture has provided you a bit more intuition, a bit more confidence in creating basic functions. So my recommendation to you now is to write down a few things that you learned from this, especially the dot formats, which is really a very helpful thing. Toe. Keep in mind for the future, Andi. Then I try and just write two or three of your own functions, integrating dot format and upper or lower if you can. And then when you're ready, I will see you in the next lecture. 22. Import modules: Okay, so we're now going on to importing modules and libraries. I'm going to try and keep this relatively short. The concepts are quite basic, but their applications are huge. They're so so important and useful if you want to become a python programmer or a machine learning engineer. Eso If you're doing machine learning artificial intelligence without a doubt pretty much every single time you want to do anything, you're gonna have to import a few modules and libraries. Eso there are some very basic ones that we're going to use in this course will keep it quite simple. But for example, if you're doing machine learning, uh, if you didn't import anything and you're using a lower level language, then essentially it would take you a lot of lines of code on a lot longer. And some people like to do this in the code can run slightly faster on it provides you with absolutely flexibility. But basically what modules and libraries are they just, ah, lot of functions they've already been made for you that make your life a lot easier in in coding, So there are a lot of common functions that need to be used and so that's what you're importing, these sort of things. So, for example, with machine learning, lots of people use something called intensively. And this was created by Google to make machine learning engineers job a lot easier. Lots of pre defined functions that you can just use right off the bat. Teoh, create your neural networks. So for now, I should also mention as well you can actually create your own modules. So, for example, if your job in programming involves doing the same functions very, very often, then you can save your own python file simply you create a bunch of functions here, you get to file and U. S. Where is it? Download us, for example, and you can download it a za dock p y file python file, and then you can import it into other other piece of code that you have, which is really cool. But for now, we're going to be using some that are already provided in python, where you down later. And so the main when we're going to be using is random simply because it's a really fun and easy one to start using and playing around with some good I'm gonna be showing you how to import the random module and then how you can use all of the functions or a few of the functions. At least that's are contained within random on. Then I'll recommend to you that you do have every set yourself on Google Python. Importantly, what modules are there? Python Best modules? Because there are hundreds out there on it really comes down to taste and what you want to do with it. Essentially, for me, I used random on a few other basic ones in machine learning. There are a lot of very useful ones such tensorflow, numb pie and Penders. But you and the next course I do on your networks. We'll go for that a lot more. So for now we have to need to Import module is type in import and then the name of the module. It's that simple. If I type in Random Co. For example, that doesn't exist, so it's just gonna say no module. But if I try an import random, it's gonna be very happy with that. So random has a lot of functions, and the 1st 1 will be looking at is random dot choice. So when you write this, you're basically saying, use this function from random needy random dot choice. I'm gonna use example here. So what I will be doing is let's say we have a raffle. Right? So, uh, so we have a list of the people who entered the rifle. Jim likes to try his luck, of course, as always, Jane and somehow hope Salamander gone in, going in early, and he's got himself a nice raffle ticket. So now we want to randomly choose someone from this list. Salamander Slimming. Sorry, salamander. Eso You wanna randomly choose one from this list? So if you try and think for yourself, how could you do this with just Ryan code? Well, it's actually quite a complex task, so thank goodness there's already a pre pre defined function. The even use and we have to do is random. Well, that's great. Variable called Winner equals random dot choice. And then essentially, you just put in. So it's gonna randomly choose one element from this list raffle. And then that's print. Oops to run this. It's print weiner settlement. So now if I run this again, these two lines Jane one that time, Jim one this time, and it doesn't have anything like you once you have one you can't win against, right? Officer said Jim, just one straight after again. Jim's a lucky guy, so that's importing one other cool thing you could do if if you think you're gonna be using , for example, random really, really often you could do import random as de So then from then on, the same having to read, write random choice every time. Now you can just write it as our d dot choice. So it's just a nice way to make things simpler. Eso, for example, with tensorflow, which I was talking about before, which is used. This is, ah, library used a lot in machine learning. We always right importantly, is TF as TF because then, from now on, we could just write TF because we otherwise would be writing tensorflow so many times it would just get going. Another thing. Weaken Dio. Sometimes you don't want to import the whole module simply because some libraries and modules are just really big, so we don't have to import the whole thing to take some memory, so we could just say from random import choice and also this. Now we don't have to write. Just take this here. Just like simple. I'm not good bother paying a very bombs cup of print Random choice. But this time we don't have to put random choice anymore because of already just imported choice. So in just a print choice and it comes out, which just makes things a little bit easier. So what I recommend you do now is do this exact same thing yourself. You do it in a different context. Import the render module, create a list and then get a random choice from that list. Will also show you one other random function just to have something else to play with. Random dot rand. Um, have I got it? It's pretty BRD No. So we can just put this Andi don't run into just to make sure that I'm not confusing anyone here. Actually, let's just import random, just as it's so, making sure if anyone's confused I wrote Import random is RD here to make shorter but to make sure it's completely clear. So Rand int basically means a random interject case. I'm gonna say print a random insta and then you can do it from a number two. Another number. So if I just did, 100 is going to do any random interview from 0 to 99. Did did. Okay, so you do need to put in a lower number and another number, so it's gonna choose an a number from 1 to 99 here. So every time this is the lower range here, the first number putting So is saying print a random into job. So rand int from one 2000. Okay, we could do from 1 to 5, so she'll be 1 to 4. That doesn't include the top number. Then you get this gigantic number. Okay, so now you have to to play around with you have random choice, which is choosing a random element from a list, and you have random dot rand int, which is a random interject. Eso were also what have gone over. So I've gone over how to import the modules. We've found a way to make it a bit simpler so you can do import random as RD, for example, or you could just choose to import one function from random import choice whenever you're a cooler function if you if you haven't done this and you just imported random, for example, you've got do this dot Random is the module dot the function and then what you want to do the function on. Okay, So Islamic sense Give a try yourself. And like I say, go online debate research and see all of the cool models there are and see if there any their interest you. Because once you understand the concepts of how to do this, really, the world is your oyster and there are so many cool things you can do. So good luck with practice this on with your own research. If you find any cool modules or libraries that you like, please do post in the comments eso everyone's can see what what you're doing. And, as always, I will see you in the next lecture. 23. Practical 3: now going on to the practical is for functions and modules. These are the questions that we will be going through that I strongly suggest you give yourself some time to try them all by yourself, starting with creating some basic functions, taking parameters, um, then going some deeper into some or functions that actually have a useful purpose. And then practicing what I taught you about importing modules and using the render module. Encouraging you here to do a bit of research yourself finding a module that you find interesting because it's important for you to dip your toes into exploring what useful modules there are. Because what makes pythons so powerful is that they're incredible number of modules that could be used for multiple purposes. So especially, for example, in machine learning. So if you're interested in machine learning after you've complete this course, maybe type in useful machine learning modules, for example, Tensorflow is a very highly used one or number pi n u M p y. So that's most of it for for this section, give ago by yourself. Do your best. If you come up with errors and you get frustrated, I recommend you keep trying just from the 5 10 minutes after that by yourself. Work out what? You don't understand what you don't know. So it becomes clear in your minds on then seek further help on. Then when you're ready, we could go through this together. 24. Solution 3: a case, and now hopefully you have had a chance to go through the questions by ourself. You may have a few questions in the back of your mind. A few things you're unsure off. That's fine. Let's go through all of this together, says staff with a simple stuff, creating a basic function. So use D E f, which stands for define. So we define our function and give it the name food. And we're not putting in any parameters here, so we can leave the parentheses empty. But make sure you have princes. You can't just put deaf you without the brackets, I think Owen, you nine indentation. It should automatically give you indentation. Just remind you. Indentation is force base. It's 1234 Or you could just press tab once it does the same thing. So let's just have a basic function. That Prince, this is a function. Look it Now we call the function. Let's run this first, so we've created the function. Now we can just call it biting food, and we have to put in brackets. If we don't we get there or just so it shows you what the function is to actually call it. After that, you could do that multiple times so you can call it as many times as you please. Okay, so that's creating a basic function that let's move on to creating function that takes in a number as a parameter. We want the function to divide it by 10 and then we can run the function with different parameters. So that's creates another function called food, too. Well, let's let's give it something a bit better. I'm good. Teoh called death so deaf transfer to find deaf deaf 10 because we're divided by 10 and then in the parentheses afterwards, we're gonna put in one parameter. Would you just put that in this ex because it's just a place holder, right? It's no. Actually, a number were saying, Whatever is gonna be put into this function when the function is called do blah, blah, blah. So in this, in this sense, in this context, blah, blah, blah is divided by 10. So all we need to do is print that's divided by 10. Okay, so that is our function. It's ready to be simple now, in order to, and we're getting something called here. So I've already to find the function here. Say Jeeps notebook. Does something cool with water? Correct. Press tab. And as you can see, there a few different things here. Functions that already exist. But def tenders here, some selected, and then pretend this five. So, basically, it's gonna run the function and excess get this place holder is going to prove place by five. Were print 55 by 10 which is not 100.5. And then we could do that with different parameters. So this is different, Another different one and noticed that you get 0.0 after each of these. That's because we need it. When you do a division, the output is always afloat. Say, we could I wonder. I assume we can do this. We compared to type C. What type of this is done type. Okay, that's not very happy I get. That's why they essentially it's a floats that comes out so well being in a number of different things here. The dealer. Okay, cool. Say we have done that question Next up, set up and empty this. Okay, um, maybe I'm sure there's one person who got tripped up here. It's literally a simple of this. You're just creating an empty list. So l s equals on this is to square brackets. So we've created up to an empty less right now, if we look at the type is gonna tell us that it is in fact, a list. If we look at the length you may remember, I gave this nice little hint a few Practical is a gay. This is going to come back with zero because there there are this stands for length. So it's asking, what's the length of the list? Syria? Because there are no element. So we create function that takes use input and then adds the input into the list. And the list is this us? So hints dot a pent so dot depend as I eventually the previous lecture. It basically tells the programme to ads, whatever to list the list you specified. So I'm gonna call this death list up distant for bed that creates a very permitted the perimeter will be cooled. Uh, let's go list, add or it's quick because we're adding something to list. Um, there were goods put. Ah, user or school takes user input. This is cool user equals um well, we can let you just append it. So whatever they put in here, we just dependent to ls So we do. Ls Doctor Pence were saying add to the list. Ls good. Oh, I understand. Yes, of course. We used to get their user input first. Of course. So user equals inputs. What will you add to the list, Colonel Space. Then we're going to add the user input. So essentially Ah, we don't actually need a perimeter here at all. So that's where that's why I was tripping myself up here. Okay? No, we will cool this function and hope for what's gonna happen is we're going to be asked to put in some input here. Then whatever we add is going to be added to this list. Let's see if it works because there are no promises we could just brought it. But this read the number three. But as we've discussed before is gonna be a string when you do input. But let's see. Ls So three has now been added. Let's do it again. Hello? Makes. Yeah. Then said no. What do you think you could be on this list? So penny doesn't remove anything. It's already in the list, literally adding to it from again, Dog just going to keep on adding things to this function, which is quite cool. I like I like the list. OK, so now we're moving on. See importing models say import the render module. Hopefully, this is relative easy. If you have watched the connection recently, you did you just put in port random? That's what the name of the module okay, symbols that we've now imported all the Rendon fortunes. Let's look a different way of importing random. Let's say we want to use the red in function so often that it's gonna be a hassle for us to type in random every single time. So go do something a bit simpler. We're gonna import it, but called it R N d. So we do that by saying import random as Eddie. Okay, so now we can basically just import whenever we want to use a function from random. We just use our D instead of writing random every time. It was a bit of time. 11 for example. A lot of issues Was she learning tensorflow so tears off, hassled right every time. So we always right imports tensorflow as TF and t ever so. But she's just too right out when you have to do it many, many times. So it's now been imported as good port. Just that, just the choice. So now we just want to import one function from the red Brenda module. And if you've ever from lecture, we did by saying from random from the module imports choice, we should, and that's it. Now we have just the choice. Work should imports another module that you researched yourself. Uh, I am good import. I get so often when you're doing image classification. You want to use something called Matt Plot lip. That's a very useful visualization tool, so I use often something called Matt plots lib dot pie plots. It is just very helpful for visualizations the range of things. This is quite long. So instead, why it is I imported as plt. Make things a lot easier. So yep. Takes a little girl because it's a bit larger. So that's one model I might use. Uh, you could import. No, but you could import hundreds, So I went I would give this for too long. Okay, Now, we're going to using these modules. So we're using the Rendon module. Just kind of a toy module to get get the hang of using modules. Red was quite useful. Want to know? Anyway, so using the render module that you have no important create a list. So first of all, it's career list s equals toward 4766 88 wards. There would ah, lots of theirs. Okay, Now we want Teoh. So using the red of module, we basically want to choose something from here. So it's simple as this print read, um o r d. So because we imported as are indeed we also just imported choice here from the render model. So we should. So if we had only just important round, it would have to do this random dot choice. This is the module uber dot out of the function here, but because we already specified, we want to import from render the choice function. We should be able to do this choice, the brackets, the list. And there you go. So we don't get this. Could give us something different. So use time you might put off the same one, but it's always going to be completely randomly chosen, as you can see. So, uh, that is doing that. So as I say we could it could have been random. Doctor said that should still be OK. It is. Okay. So if you just If you have just employed around, um, you want to do it like this, If you'd said from random import choice, then you would have done it like this. Okay, so with the help of a four loop, generate 10 random numbers between 100. Okay, so this might have been a bit more tricky because we're using a four loop forcing using using in range, which you haven't used that much. So we say for I in range or whatever. This it doesn't matter. What you put here, right could be K or numbers, whether in range, Ted. So we're saying for 10 times basically print. So now we want to use the run. We want to select just a random incident on the function from random is called Rand Int, which is short for random interject, say, because we haven't explicitly imported the function Brandon's. What we have to do is random dots. So from the module, Random Rand int. And then we want to say the range that the number could be between 100. So we're saying basically here for changes to I just to make it very simple for I in range 10. So we're saying, Do this 10 times basically print the relevance job between 100 So we should get 10 numbers back are between 100 like that. We got 34 twice one of chances comment in the lecture, if you know the answer. So, yep, each time it does that, So that is the bulk of it. I assumed the love people tripped up in this last one. So what I would recommend you do is just have a go with this in range a few times just to get the hang of it. Understand what it does on also with the red. A minister if you had if you had issues with not the enraged parts, but you started having issues with generating random numbers, I I I strongly recommend you build more of a confidence in searching online for these problems simply because for this whole thing, I know there's a lot of resources out that If you are to Google, for example, Python how to print a random number, you'll get something like this. So So I highly recommend you get you get mawr more confident with with looking online for for help. Of course, if you have any questions, you can always come in in the in the lecture. But as I say, I mean developers. Even if they've been doing for 10 years, they will be going online. Teoh look, a question asking questions on Even a lot of us have experienced that we've had a question that we had five years ago. We searched the question and up Pops online are question that we placed it five years ago that we found the answer to and forgot. So it's really important, actually, Teoh become part this online community, where you feel comfortable asking questions, looking for answers to your questions, and eventually you'll be one of the people who is contributing and helping other people. So that's Ah, that's this section done on de. So if there's anything you've been having trouble with and you weren't sure in this part, one of the big parts off doing these practical is toe workout way a strong away. You could do a bit more improvement. So wherever you didn't feel too confidence, I recommend you just go over a few times by yourself. Build your confidence in your intuition and when you ready, are see you in the next section. 25. Open read write: so, up until now, we've mainly been running things out of Duke to notebook. Now we're going to expand that to creating files on our actual computer. So how to create them and how to read them and how to make changes. So it's all quite simple. As you can see, here I've outlined will be writing or files first. And then I'll be showing you how you can read files, warning of the dangers of over writing files and then how you can add to file instead of over writing it. So to begin with, to make it clear wherever the path you're running your program from so from dupes led. But here, you want to make sure you know where you're running your path from, so you can, for example, get your command line. This is you live it running. But at the top here, you can see this is, well, money from users, blues guys. So wherever I am going to write a file, if I'm using your notebook, it will write it in this directory. Okay, so they're start off by just simply writing a file. This is the basic sent actually. Right? So you create a variable. So right now we're just using faux. We're actually gonna call that food. We use this, we use the word food sometimes in example work so food equals open. So we're saying open a file that doesn't exist yet and the first thing we put in is the name of the file. So we're saying we want the file to be called this on. Then we put a W comma and then w on the w stands for right. So when you open a file, you have to say what for? You want what you're talking about right now? They actually isn't a file called Food Doc. Txt. So we're saying right a file called Fu Txt. As you can see down here, we're using the write the letter R, which stands for read, because at this point, when we run this, it will have already been created writing and then you can see here we have a which stands for appends appends basically means adds to, So this is the very simple way that you can write your own file. You create a variable what you can call it whatever you want on Ben, you put open then give it the name. Make sure you add the file extension so dot txt for now, because creating a text file is just a very simple way of doing it. And then which were tending to right here. We put out once we've created this variable, essentially, that's all we have. What we have right now is just a variable on now was telling that we're saying for food were saying dot right, which is basically saying write something in this file now so we could, right? Oops, this is a or Cem file. So not to blow my own horn. But it's a pretty good file, Andi. Then we could write another line saying Yes, it and that's it. And one thing to be aware off is that one. Whenever you open a file, so have done the opening at the start. You want to close it at the end. So you just with the variable, you say food variable dot clothes on, then you don't need to put anything in the parentheses. So basically, if I run this, I hope you're following along as well so that you could do the same thing. Basically, there's now a text file that has been written. So if you were Teoh, make sure you know where your path it's on. And then you can basically go to that path and you will see that a text file has been created called food. You can open up and you'll see that this is there in the text file itself. So another court thing we can do is we can read files. So if we have existing text files, TXT files in the directory, then simply weaken, weaken, read from them, do something relatively similar. So we perch phone or so yeah, well, let let's keep the variables different just to make sure. So foe complete different variable named food equals were opening a file were opening the food dot txt file, and they were saying to read it. And so that's what we're going to be doing with this variable reading, and then we just do faux dog breed. So if all goes well, when I run this, as you can see, we have this is not some file. Yes, eyes all on one line. The way that we could could read this outs That's not on one line, is we could use a for loop. So what we could say is for line in If you remember, whatever this word is here, it could be whatever you want to put. So you could put I or line or words whether you want it doesn't matter for so forwards info . And then here in self pick photo read, we can simply just put print What's okay? Say forwards Info, Print words, photo close. Okay, I see where the issue was essentially, When I was writing the file, I forgot to put a line in between these two rights. So if you had done this and you checked the text file, you may have noticed that's it was all written in one mind. So whatever you're writing text essentially to create a new line within the quote marks, you basically put back slash end and the this will be printed as backsides end. It will simply be like pressing Enter on your keyboard like this. It just adds another line. So once you've done this. So if we go back to what we were doing before we just find out, read it would be printed like this. However, if we do this which I was just showing you. Then you get them line by line. So we're just using a fully appear. Saying For what? Forwards info, print words. And they were making sure we're closing the end. And we get it nicely in, you know, in a row like this, so we can do this again, Add more lines. Hello. As you can see, just keep printing by that, which is awesome. Okay, Now, here's something very, very important. So let's say we wanted to add to this food dot text Well, so we want to basically write the far right to the file again. And this time we want to say something like we are adding to the above. Also, uh, hi. Hello. So I just have this. So what we think we're doing here is we're saying, right, open that file again and write some more. However, in reality, what it does is actually overwrites the file. So if you run this really read file again, as you can see, the text has been replaced. So imagine you're writing a big old file. This would get quite annoying, right? S o what I recommend you do instead of using the right here is if you want to add, you simply use append so you create your invariable whatever you like. Let's call this one file. So we're keeping the variables different. And so this time, with the open food dot txt So it's still the same file, But this time, miss of writing were a pending. So right now, our file says the above we are adding to the above. Awesome. Hi. Hello. No goods put slash End. So we have another return. Um, we have now successfully added to the above. Okay. And then follow close at the end. So if we read this again now, it should returned with four lines. So we've got this, and we have upended the file. So those are the three main things to keep in mind for now. I mean, obviously, there are so many different ways of creating files in different file types. This is just giving you the basic foundation to understanding how you can write a file, how you can read. It s so basically how you can save on open text files obviously in artificial intelligence , for example, would deal with a lot of different data that wouldn't be in a text file. We might use Jason Jason's. We might use images or we might be using audio files, lots of different things. So this provides you with a very strong foundation. So what I recommend you do is start creating your own files just trying to two or three times today. Created text file, write some stuff in it. Make sure you use this slash end toe, have the spaces, then try reading those files. Make sure you ever write your file a couple times, so you get it into your head that you know when you do the this w the right function again over rights, and then you can try pending as well. I heard this all makes sense. If you have any questions in the comments sections, have a go at it and I will see you in the next lecture. 26. Practical 4: So congratulations on making making it this far through the course you're doing fantastically well. A Tous points were handling files. This is kind of a nice resting point, if you will, where the section wasn't too intense, but it still got some really useful parts to it. When I remember what I have moved on handling files, why re enjoyed about it was until then, you're kind of working within a bubble. Where is this time? You're actually would create save and load change files that are on your desktop. So it really feels like you're starting to get grasp. This can actually have an effect. You can do things that's outside of this bubble. So would you go through the questions really quickly? So start by creating a text file called Amazing File and you wanna have the extension, Doctor X T, of course, and create a few lines on how awesome python is. Don't get too close your file at the end. Then read back the file to yourself, Then try and overwrite the whole file with a few lines on how interesting machine laddie is . If you don't know what it is that Google it because it is very interesting on. Then you can add text without over writing on file. So that's basically just using the basic concepts I provided to you in the previous lectures. So give it a try and when you ready, let's go on to the solutions. 27. Solutions 4: Okay, so let's get stuck into handling files. We'll start with the first point, which is creating and writing a text file cord. Amazing underscore file. With a few lines on how awesome Python is, say the first thing we need to do is create a variable quit file. It's gonna be opening. We're gonna be creating a new file here called Amazing Underscore File. We need to put the file extension name, which is dot txt and because it's new, is we're creating the fire we couldn't be reading. It could be because there's nothing to read, so it's gotta be right. So creating this variable with this variable file we're no going to write something by phone is awesome. No, I believe we've gone over this very briefly. But if you do back slash n, this is going. Teoh cause there to be a lot of extra lines is like pressing. Enter when you do a back section so it's not going appear as backs lesson in the file. You just going to peer is a new line. Python is simple to use, had a very powerful. That said, there are awesome teachers like John. They're gay or a great teacher blowing his own horn anyway, So we're writing three lines basically here and come back to this number in Jeeps and a bigger returns. This this is just the number of characters that's been written. And then now that we've written this firework unjustly filed up close and then the brackets . So wherever this due to notebook is running from this is where in the same folder this is where amazing filed a text. He will be written so fine, just go to file and open. You'll now see that we have amazing underscore file dot Txt defy. For this is a text defoe with no text in it, which is very interesting. Let's see, what's happened are okay, I haven't actually run the photo close yet, so that's Tracy and run. 123 Okay, You know, we should have figured across three lines with the text. Excellent E. Okay, so that's actually a really important point we've got going on here. Even at the top, I put don't forget to put fired up close. Say that's what happens when you don't close the file. It doesn't get completed. So close the file. Now we've created this file because it been closed. We have to open it all over again. So waken call this variable everyone just to make sure it's clear we're not that far Underscore. Reid equals I fed amazing file texi. So this is a father now already exists. And after that, I'm gonna put all which stands for read. So opening amazing file dot Txt and we're opening it in read mode before we are opening it in. Right boat. Now, where I play it in read mode. So I'm gonna run this. So we have a variable. There are two ways we could read from the file. We either to Steve file Far reads Dr Reid, That will give us this back. So give it back to us exactly as it is above with the back started. So it's not actually showing us what it would look like in the text file. What we could do, do you fully so we could say four lied. ID file read. Remember this Our keep saying over and over just until it gets Have it'd this this word could be anything. You could have his eye which has priced, ended. But you wanted to be readable. So safer lights like a light of text. It filed up one score, read Prince line, and that should protect it bit. Would I see. Okay, let's check. Let's go back to doing file reads Don't read. So, as you can see, it's now empty, which is quite strange. So I'm just gonna run this again at the top. Right? The file on. Then we're going to open the file. Okay, Now, let's try again. Four line in far read print line. Should There we go. OK, I'm not sure what happened before I ever think about it and see what comes up. Ah, but as you can see, we're printing off each line in turn, and it's printing off a lot nicer than if we just do file don't read. But this they get to stay. That which the strange anyway, So once it opened it, read it. We could do file read, stop clues. Okay, so, no, we want to overwrite the file with a few lines of text. So let's do that. So, essentially, if we want to override it, we have toe open it again. It read mode. So we're good to put file right is the variable. Remember? It could be anything. We want the opening this amazing. Oops. Music follow Txt open. Get in Write mode now we could do far right. Don't. Right. Uh, the sheet leading rules its crew can so number off interesting problems such as its classification. So now we've over written with the exact same number of characters, which is very interesting. Ah, So basically, we've opened up this fight again in right moods. And unfortunately, if we open in write mode, this doesn't just get added to the bottom, Actually, completely replaces all of the text from before. So should be able Steve far right. But read, actually, so that's close It have a few more lines here. Follow it was, but file equals opened. Open this in. Read Made full for I file print I There you go. As you can see, the Texas completely changed on. It hasn't just been added onto the end. Okay, so now we have this file called amazing Foldout text e with over return it. But now we want to actually add text onto the end. Now, let's make sure that we close this head. Okay, so let's open the father again. File equals open. Hopefully doing this number of times is going to get into your head on several. Read this time we're going to append. Remember, we use that word. We were adding things to the end of the list. It's exact same thing here. We're adding text to the end of a file. So now against D filed right slash ends, we start on a new line. This is new text. I have read that No, we should clues file if we have up again, though photo referred. There's before Tst. Open it. Read mode. Oops! My mistake with you far equals open. Okay? And that we do fire for all right and file I As you can see, we have the original three lines machinery, rules of law. And then this is new text. So those are the four things you have reading. Really? Sorry. Writing files, text e reading them over, writing them. Hand a pending them. So that will make sense. If not, go back over the lectures, go through the questions again and feel free to use stack overflow to help you understand. Do big googling on when you're ready. I'll see you in the next section 28. List slicing: right now moving on to some really cool functionality and python called list slicing. So essentially, when you have a large list, let's just say of numbers. What you can do is you can actually just select small parts off this list. So let me just put example list to give you the variable example list we get so essentially what you can do. I think we we have looked at this before, for sure is you can select one element from list. So this is third index one. So the index starts at zero. So number one here zero number four is one index number six is to index number 73 index. So I run this, it will return the number seven, but what you could do is actually just select a select few. So this is going to give return when you see it. 78 and six. So I'm basically saying go from the third in next three for five, and so we never include the final number is basically going saying go from this number to just the one before this number. If I were to put no coal, no numbers in between the two Coghlan's. It's gonna return everything so I could put just a number of the start, I could say from the third index, which would be the number six return everything beyond that. So when you have a number of basic means, go away and I can do it the other way, I can say just go up to third Index. So I returned everything that goes up to the third index, but not including, so you can get slices out of your lists just to make this a bit more interesting. Let's insert names. I just did. Okay, is a But so you have these five people. So now I could say, right, I want to return all of the names vinous. Obviously, I could just put example list and it will attend everything. If we're using this slicing, all I need to do is put a colon there so that it's giving no start point and no end point. So include everything. Now, how about if I just wanted to get Lizzie, Jen and Marc, how do you think we could do this using lists slicing Well, what I would do because I'd get to Lizzie so that 012 since the second element. Second index. Sorry in this nest. And then I leave after the colon blank, so it returns everything after Lizzie. Now, how about if we wanted Jim, Bob and Lizzie? Then what do you think we should do? Well, I would do is 0123 I put three here because it returned everything before, but no, including the Fed index. OK, and now let's try and take Bob, Lizzie and Jen have I think for yourself now how you do that. Feel free to stop the lecture and give it Try a cell first. So what I would do is I would go 01 and we're doing Bob, Lizzie and gents, I wanted to stop at Jen. So 12301234 Because it will go up to, but not including the fourth index. And they gave you have jobless engine so some people won't get the straight way. You might get it straight away. But for me, for example, it just took a bit of practice just to get the intuition and to understand it. So I recommend you create enlists, stop the lecture knowledge, create one list on Dube. This yourself. So before writing anything like this, you just say it yourself, right? I want just to have returned. Lizzie and Jennifer. Example. Andi. Then you try and do that. Use this using list. Slicing. Okay, let's go into the next one. That script. Ah, variable court example to for the list and which these numbers again Because it's easier to write out. Okay, so what we're gonna be doing now is adding a step. So let's say, for example, we want this whole thing. No, we've got over what you can do with one Copeland. So if we run this with just one coat on, we will get the whole list back. Who? Overcoming their It doesn't really matter. But so now we can have ah, little slice from that, Let's say from the third index up to but not including the night the next. But now what? We can actually add another coat on and another number. So the first number means the start point. The second number means the endpoints, but not including this number. And the third number we can add will be the step number. So if we have it as one. It's gonna come back exactly as we see it here because it's basic going one by one by one by one. But what you can actually do as you can change the step number two, for example, to count every other one. So now it's missing out. If you look at that number six, then it misses out. Number two. He gives you 45 misses out number five, give you 56. So, for example, if we just left this first cut on blank were saying Return everything from the start to the end, but with a step of to So what do you think? It's gonna return. Have a quick thing now. So as you can see, it gives you the 1st 1 and it misses out step, and it keeps going, missing out one at a time. You can change this number toe any number you like, But at some point, obviously, if I were to give it a 10 then there are actually that many elements in a list or other 369 There are exactly 10 so let's try 11. So it's only gonna return the 1st 1 because it gives you the starting one on. Then there are no more to be to be red afterwards. So that's steps. So now we have these two different continents. If I just do this, which whatever. You see why I would ever want to do that, it would just give you everything. Now, now we're looking at something very interesting and how we can do this in reverse. So let's use the same list this time. What we could put we want to do is we want to reverse this list using this license. Now, if you have a great intuition, Phyllis slicing already, you might be able to think from the information I've given you. How could you return this list, but in reverse? I'll give you a clue. It's to do with using the steps, the step number. So the third number we have. So if you want, pause the lecture for a second and playroom that see if you could reverse this list. Okay, so what I would do? First of all, we want to return the full list so we can just have starting in point. There's nothing. And then on the steps, instead of saying we want Teoh go forward. We can actually say we want to go backwards when we provide minus one. As you can see, that reverses the list completely. Then you could reverse it and miss out every other step if you would. But essentially, if you provide a minus number for that third number, it's going to reverse. The list is gonna count from from the end to the start, So that is reversing. So these are the main points. I just want to show you. One more cool thing is that you can use this in Texas. Well, so had I. My name is John, so let's put that in context. Put this as variable greeting. No, this is, I think this is really quickly. You can eat a slight list slicing on the strings site. If I put greeting like this, you get the whole thing. But let's say I only want the words Hello, Say the index's 01234 so really put five because I want everything up to, but not including the fifth Index. As you consider attends. Just tell a now let's just put in summer one of us to Andi. Nine. No returns low by space. So I think this is really cool. Onda. We could, for example, have it returned. Everything. But only there. Every second character plumb ie on location Critical coda. Or we could reverse the string The hajj cminor, you old The gauges credited new language so you could do the exact same things we were doing with lists except with strings on each one of these characters, including spaces are indexes. So this is less slicing. I recommend you just that you have a play around with it. Create realists. Yes. Give yourself a target each time, right? I'm just gonna get Bob and Jen, for example, on try and do it play around with having a started fish point that added this step. Try and reverse it and then have a play around with using this for text. If you could do of this confidently, then you went on your way toe to be a master of lists. So good luck with playing. Remember this and I will see you in the next lecture. 29. Sets and tuples: we're going to move on now. Teoh to other types of date sets. These are less commonly used by myself, but they still have their uses. And I've definitely found them useful in certain situations. So they're called sets and two bulls. We will first start with sets, so essentially sets they they provide only unique elements. Eso how dollhouse Say this. I'm going to create a list off numbers. As you can see, sometimes I am repeating numbers like that eight, for example, all the number six. Look it. No, I'm gonna convert this into a set. And what you will see may surprise you. It returns only the unique elements. So regardless of if they occur, once, like the number one or if there are many, many times they're only going to provide one for every unique element. So, for example, this is quite useful for machine learning and artificial intelligence. When you're preparing your data, sometimes you want to be able to see what are the unique values in my data set on that can help you So sets. Do you have there place? I use them ready, but sometimes in data processing. So give that a go yourself, create a list off elements that are you could be repeated so we could do the exact same plea again. Bring on jib. Did you do? It's Let's have a big party for the Chibs and then one Janet to keep him company. So we take this into set and we just get back. Janet and Jim. OK, Gigi said, moving onto two balls. Two. Bulls are very much like lists in most ways, but we use round brackets. So just to be sure you're using different types of brackets. I just want make this really clear. So we have lists which are square brackets. Okay, then we have sets which, uh, noble brackets. But we could also have two pools. I'm sorry sets. It's incorrect. Use curly brackets. Two bulls. We used your brackets, poopsie and dictionaries, which I believe we've touched on. Very likely it will be going over very soon. A future lecture addiction. Emory's. We use QWERTY records like it. So we use these different types of brackets. Now, what two pools are known for most is that there immutable, which basically means that nothing could be changed within within a two bowl. So to pull is still just doors. A load off elements. It can be numbers, it can be strings. It could be variables like we create this very blood here. A so And this is quite cool. You can always check the type of your data. So, for example, type B here should return to pull. Let's just check out what type is It's a list, OK? Because we if we we didn't actually change the change. What a is here? We just we just turned it into a set. But if we create a variable, we set this to a variable. Then if we type in type C here, as you can see, we get set. So, like I say in two pools, things can be replaced. And what makes this re useful is if you have loads and loads of data actually saves on memory. If if you can say that basically are immutable when they can't be changed, so with lists they can be replaced. I want to make sure this is absolutely clear because this is a re important point enlists. It's just create a simple list in lists. You can change the elements. I think I touched on this briefly before, but this is a really important point to notice. If I were to select a setted elements, let's say all we ever see So the index number would be 012 As you can see, it returns. See, however, if I were to do this, I can set a new value for second index. I could replace it with F. No, If we look at this again, let's look at the whole example list. Did you live, as you can see, see has been changed toe f We can change this as many times as we would. We changed it to a number, whatever we would, or we could even change it toward of our variables. As you can see here, we've just changed. See the second index to a which was our lovely was set We had here for those guys. Yes, it was. It was it was a socialist. So we put a list within the list here. So just to make it completely clear, you can assign new values to any one of the elements in a list. But if we take ah Chubu, which is be the what is happening here. I thought we changed it in example List. Oh, yeah, of course, because we added in ah, in a at the bottom. That's just remove that because it doesn't like to clean to Ed. If it's because elephants are awesome, there's, you know. Anyway, so on B, we now have these five elements. So if we try and do the exact same thing, let's say Listen for a second. Let's go. Let's go for the 010123 4/4 element, which is elephant? Let's try and change that now to Tiger. As you can see, it's not happy it throws back an error, saying to pull Object does not support item assignment basis. Basically, what that saying is you can't change an element within the tube. So the main points to take away from this lecture in sets they only keep one value for each unique value. Okay, then we moved onto two pools, which are immutable. Basically, you can't change anything in a to pull, but with lists, as we showed here, you can actually change values or elements within a list. So why I recommend you do is just take 5 10 minutes to play with this. So creator list that has lots of repeated values change into into a set yourself to see how that how only one of each unique, very appears on then with two pools. Try to reassign some the elements and you should get error and then try and reassigned some values in a list just for good practice on once you don't. With that, we can move on to the next lecture. 30. Dictionaries: onto one of the final onto one of the final data structures, called dictionaries. Now these are very, very useful, especially in holding information based on keys on values. They have so many different applications where you do, we do use it in artificial intelligence sometimes, especially when feeding data into our models. Essentially dictionaries, they have a oops apologies. This should be a comet. So essentially diction is What they do is they have a key and a value. So we use curly brackets here for to define a dictionary. We provide a key anybody, the key is basically any it can be a number or it can be a strength, and the value could similarly be a string or body. And we use this code to say right A is corresponding to this, that we have three separate. The next elements with a comma B is equal to this. So this is how we create it. And then when we want to get information from the dictionary, we basically, if we aside this with a very bad name, Dick example create variable that essentially, to get any information from this dictionary, we basically put Dick example the name of the dictionary, and then we we put in any key that we want to get the information back on. So we put this in, it should come up with the value. So exit says you could see the first element is always the key. And then after the colon is the value. No, in orderto add to dictionary, it's very simple. All we have to do, you could dish example and then we add a new key. So you put whatever Q B Woods, Septus IPs four simplicity. Sake of good put the key as see Abed equals woods here, 101 Okay, so have created that. Now, if we call if we look at it, uh, dick examples, the whole You will see. We now have three of them in here, and we can take a look at sea. You see that? A returns. Oops. No X 10101 Okay. Know what would happen if we put dishes are pool? So we have a B and C, right? What happened If I decides to put the example square brackets hey, equals sub new value. Let's just put it as one. What do you think would happen if I run. This ad that I wrote to her example again takes a second to think about it. What happens essentially is a now becomes one, so you could change the values off the keys at any point. So that's the basics off a dictionary, so you could essentially create a dictionary by just adding curly Brett brackets. You have a key, which could be a string or no, but and then you separate the key with value by putting a colon. And then for the next one, you must put a copper afterwards. So that's how you create a dictionary. Then you could look at any part of the dictionary by just put the data dictionary that in square brackets. Put again any one of the keys and you could replace or ads by Putting the key in this format equals do whatever you want, so there's like a quick, quick application. This. Let's say we we are Bank Onda. We basically want to be able to look at how much money is in any any one of our clients accounts. Anyone time. Imagine that we have utterly were small bank. We have 10,000 customers that say, I've created a small example here could current accounts. But now let's say Hank comes into the bank and he says, Right, I want to know how much money is in my camp right now. We say No problem. We're gonna gallop this dictionary. Put your name ID as the key. The value will come back. How much you have, which is 15,000 teases. Excellent. I'm rich. We're going to spend that. And then, let's say, uh, James D. James Dean comes into the store. He says, Right, how much do I have? This is all we have to do. Okay, that's a habit. Comes in heavy was that he comes in and says, How much do I have in my current account? We say, Well, Mr said you have 12 of the movement's 12 euro He says. Okay, well, I would like to put in some money, and so he says, Right, I'm going to put in an extra 10,000. Let's say so now. What we could do is we could update that we could, uh, footed. I see hope you remember this plus equals, which basically means this equals where we put in here But you say add this to this. So let's say he won't spend 2,249,384. So no, he says right. Well, how much do I have? No. Okay, then we say, Well, this is that you just put in a nice amount of money, so you don't have 249396 He says, Fantastic. I'm rich. So I'd recommend you do this exact same thing. You create your own little bank, and then you just think through ideas like this. So this was kind of improvised. This thing right side is toe if him to deposit some more money, never actually done a plus equals on a dictionary before, which is quite fun. So just play around with these things, essentially set up Ah, dictionary that has names and values Or do something different if you want and pretend that people come in and asked. You know how much is in there? Maybe they want to withdraw so you could do by this equals or you could do plus equals whatever you want to just play around with it. So I suggest you play around with creating a dictionary maybe have a context like a bank on Ben. Set up some examples like someone comes in to set up a new account. How would you do that? Well, let's get together, actually, because that's quite quite nice thing today. So say someone comes in. The name is Jenny. Jenny B. Okay, so we have to do is get your dictionary. Put it a new key like this in square brackets of it at the value. Let's say she just want to start with 50. No, As you could see, Jenny is now a very happy new clients, and she's been added to our data. So player over these sort of things, I suggest to really getting the hang of dictionaries because they could be used in many different ways. So have a go at it. And then I will see you in the next lecture. 31. Practical 5: so another have gone to the end of this section will be going through data structures on going through a few of the different questions on them. So printing off a less taking slices from a list, printing in reverse, extracting set of numbers on, then moving the same concepts into strings, which we went over in the lectures. Ah, there's a bonus. If you're feeling confident, I highly recommend you just do your best to give it a try. UM, is be able to get lists from with enlists and getting really deep into In the Matrix, which is basically an array of a list with a list with lists, you'll be able to extract us. One number from them is quite cool, quite fun, A bit of a challenge kind, like a brain teaser. So I highly recommend you give it a go, and then we can go over it together and all the solutions 32. Solutions 5: So I hope that went Wolfie on. There weren't too many hiccups along the way. Let's go through it together, just in case you weren't sure about some of the parts. So first of all, we run this cell to produce a list. Cordless NMS. OK, it's the first thing is to print off the list. Stay off Nice and easy print list numbs they gay with notebook. You can also just stateless numbers that come up Belay. That wouldn't happen if if you're running in other places So we've got our listeners know print or numbers from 13 to 200. So we're going to go into list slicing right away. So a start point is the number 13 and let's look in the index next zero. We always start with index zero with lists. Don't forget 0123 start from number three going all the way to. So we have the start point colon endpoints. So I want to get to 200 so we're going to get 01 23 for 56789 So we're gonna put 10 because the second number it goes up to, but not including that number So here we gave 13 to 200. Now pretty listed in reverse is relatively easy. If you remember what we were talking about in the lecture for less slices, you're pretty the whole thing. So from zero from start to end. So you need to put a number is there in the 3rd 1 This is the step number. But we have to do is put by this one and they go. You have the list in reverse. Okay, so now we want to extract numbers. 32104 Missing out every other number numbers. Now, we need to have three numbers in this square brackets. So the first time this could be the start point said number three. So we're gonna start right for the beginning, so we can actually start with an empty number. There won't go up to 104 which is indexed number 01234567 says index seven. We're gonna put number eight here, and then we'll get a print off every other the but so we won't have a step of to. So we want to say this new variable and then print it so I'm gonna create any variable called new list. He was that case. You don't have that. And then we're gonna print off you list, and there we go. 394710 ET Okay, So now we're gonna be moving on to text so you can do slicing the exact same way as on lists you could do on tech text. So we want to print just Christmas tree, so this might be a bit long, so let's go. Zero index for hate each. 1234567 89 10 11 12 13 14 Certainly. Right. That here. So the 14 is our start. Is our starting index for Christmas trees? So would you sentence? There's great brackets. 14 up until trees. So 14 sc 15 16 17 18 1922 1 20 for 3 to 4 to 5 to 6 to seven. Trailer. Say, Well, eso you want to do it up to switch denied? No, including 20 died. There we go. We have the lovely Christmas trees. Put the four centers been reversed, so we just did that with lists. So really sentence square brackets. We want the whole thing, but minus one step to put it into reverse. See it some cheer her e g e. All there. There we go. You just let how to speak. Jet I They will buy this to the course. Okay, so going on the bias ones now, hopefully give this a try. And don't worry. If you didn't get it'll, it's greatly gave it a try and start to build. Interesting around that. These things don't come overnight understanding them, but maybe did really well, either way, it let's go through it together, say, below is a matrix. In a previous luxury touch of list with lists, there's a very important concept machine leading. That's very correct. Job below is a matrix. This within list with lists just below. This is a list with analyst. As you could see, we've got two lists bundled together with interest. Of course, that list underscore list to extract either, lest you could use. So you've gone through it yourself, right? Readout. So first, where this at the list would zero. So that is good to give us 01 That's go. Give us this list on zero index is forced. That should give us that up before. Great. So, uh yeah. So, like, like I was saying here, Contrite now with obey tricks. Maybe you've had to play with that one as well. Just give it a try yourself to you few others. So run this below. We have a lovely matrix print out the 1st 2 lists. Cuba by their both within the same list. So what happens if I just do this matrix theory? Because, as you can see, that is gonna print out the 1st 2 because they are with it. Would big list. There are three that. Sorry. By mistake. There are just two of thes two of these. There were these within each of these. We have one of each. So we have to distant here. And these two lists are within a list of these other two. That sounds like absolute gobbledygook. I apologize. The only way to really great get an intuition here is to play around with it, just like we do now. So to print out the 1st 2 lists, this is the zeroth index, because this is just a list, right? This is it. This one was self square brackets. And between those two, you can see, there's to break brackets here. There's one comma, which means this is the zero index at the start and you have the first index after. So that's I managed to work out, print out just the first list. The case. This really gets a little complicated right now. We have beachings. Eerie. Is these 1st 2 here? Now we want to print off the first this within that. So we do another's area just after and every day. Okay, put out the double diet. Teed 1000. Okay, Say Okay. So what about two different numbers? Ah, that might have been slake of music apologies. So that it's just go for the number 19. That number 1000. Sorry if you were for both Fantastic. But for knowledge, wanna go for double se? They start by thinking. OK, so this was gonna be with Ed. Definitely. Matrix square brackets one. Right. Because this is what this whole thing. Okay, so now we want to go for within this list, which is a second index in here, But you start with index of zero, so I'm gonna put another one. So this is gonna retire this finalist now. We want to get the 1000. So 0123456 since the sixth element in hip start from the on index of zero. This what should return the number 1000 Fantastic that we get. We don't see if you're not completely sure about this. I just recommended playing around with it for a while, which is build interested by playing, Remember, Let if you think you're not gonna be getting into machine learning, this may not be as important to you or data science. In general. If you are thinking about doing that in the future, I recommend building and choose it now because it'll pay off later down the road. Okay, so now go into a list of names, turn the list below into a set. Okay, so we're moving into sets, and you boost says, read this vest that were seven of the cell I was gonna set. Just like when we want to change a a string of the number three. That's a string into a ninja we put into jail or its first. We just put set and improve. Sees we put list. Dame's there were gay. You could don't see that how it's big repeated again. Neither is Jackie, because sets the purpose of sets here is, uh provides early, unique elements, so we can see if we use lead, which actually before, which stands for length. Guess that this is variable A. To make it easy. The survey is going to be fought because already four unique names in the how is a tube or different to list It is immutable that needs that does inhibits in the two people could be potent. Okay, so three important point because it just based it means that takes up less memory and nothing could be changed with the inner tube or is in list. We can change the values quite easily. Okay, finally moving on to dictionaries. So in order to create dictionary, we need to use the QWERTY brackets and then we have to create a key. So I gave you hit here the act of this for months. So the key could be that say, let's go for the keys being letters of the values, big numbers. Let's keep it reasonable. So this is the key. The letter A. The double is the value, the associative value. Who will be Oops. Apologies coloured. See, this is very boring off today. The e Okay, so we have five and of its keep key value pass, you know dictionary. Okay. We want to do key value pair. So no, we have to do is less cool or something first that is called It's the fun Dictionary. OK, because it's so safe. Fun? There were gay? No, in orderto added new key value pair What we have to do Is this for dicked A Uh sorry. That's CSTO. Why equals I'm not capital letters up to that. But I was added. Why? As a key with the value of 22 this dictionary, let's take a look just to confirm did the lab magically. It has appeared here yet And just to make sure as a points with dictionaries, they're not kept in any specific order in memory. They could be kept in any order. They're presented like this, which is nice, but it doesn't really matter what order they kept it because it's all about the key value pairing. Know about water there and case it pretty Just one key. Very prayerful addiction. Okay, that's easy enough. Using the logic, we just use here to create the wood with just footprint for addict. Let's go for the letter D pulled that one off and it gives us the before, which is correct. So if you scare square brackets to call the dictionary elements, change the values of all your case. Okay, again, this is relatively simple. We just put five Dict De said it. You call it something else. 250 dead? No. Just to confirm, Mr Gillick, as you could see, D it's No. 259. Okay, So I hope that was already to the okay for you if you had any issues or if you found some things easy. Feedback is always welcome. So leave a comment in the in the tutorial in this tutorial on Yeah, just let me know what you think When you ready. I'll see in the next section. 33. Lambda: we're not going to look at some functional program programming, starting with Lambda eso Lambada is very much like using functions. So just to remind you fortunes are things like this fruit. So you just make sure remember what functions are things like this. So you set something up, and then you can call it whatever you want. Functions are very useful, especially when there's something that needs to be done numerous times throughout your code . Throughout your program. Lambda is very similar, except it's kind of like a one off. You know, you just you just use it for once, and then you don't use it again. So does the exact same thing as creating a function, except you use less lines of code. If you think the function is going to be repeated, your codes. It's very unlikely that you'd use Lambda. So we're just gonna go through a few examples of that now so you can set Lambda to variable , for example. G equals. Let's just put example lamb. Just just make it clearer as the variable, then lambada. So we put love in the first, and then we put X X is just like a place place order like we use in the for loop, for example. And then we say Take this X and multiply it by 1000. Ok, then what we could do is cool this example Lebda and replace the X with whatever we want. Eight. Okay, so what's happened here? I just rised. Is we put to action? Asterix is here, so this means X to the power of 1000. So whoops! Let's change. That's more Supply it and then this should be 8000. Ah, Kate, let's put in there instead. Hi! Now this will be fun. Hi. Ha ha ha! I is high times 1000. So that's just clear that up of it because that doesn't look very nice. Uh, oops, that's to the string. So what? If you just want to run a lambda in just one line? One line of code you can sense you just print out but the lambda x x times 1000 by this. So this is in one bracket once of princes and then you can put straight after another set of parentheses. What you want extra B high on? Let's change this to tend to make a bit nicer essentially, just by doing this, you'll get it repeated. Get it returned. Sorry, just like this. So you can do it in one line, which just makes it super simple. You put lambda, you're placeholder a colon, and you say what you want to do this place holder, and then straight after a separate sent set of parentheses. You say what you want to feed into this love defection so you can do all in one line, which is very cool. So let's look at another example here. Let's do this with two lines of code first where you're calling it. So what we're doing is we're creating a variable here called Hey, H, we're gonna put this as string loved, uh, equals. So paying the lambda and then are place holder and then colon and to our X, we're going to be doing dot upper, which I showed you in a previous lecture, basically capitalizes all of the all of the letters. So underneath, though we are going to call the function the Lambda Function and they were going to put in here up. Okay, And as you will see okay, besides t two, call this first right and As you can see, it goes into up case If I would try and put a number in here by the would not be happy okay , Into your object has not be upper because you can't put up a case on a number. Okay, Now let's try and do this exact same thing. But in one night of code, so we put gonna print out Let's but pretty dead. Just just let's start with this. We're ready. Loved a X and then we're going to do but the so they're soft. Be lambda. We're saying, right, we wanted their function. This is our place. Order. What do you want to do with our place? Order? We want to make it all uppercase member for digging the upper. You have to put a set of empty parentheses and then straight afterwards we're going to put in what we're going to fill a placeholder with testing. So then we won't say right, that's print this whole thing out. So you put, make sure we close those brackets. The end. As you can see a one night of Kate, we have now been able to do dot upper Say why I recommend you do is try both of these. I'd say the most important thing to get head around is doing in one line of Cade because really, what Lambda is all about is saving time and making it very easy toe to do this. So I recommend you try and do this exact same thing. So do a loved a function with a placeholder on trying to one thing where changes text, for example, the upper and lower on fill in your place holder on the same line and then try and do the same thing, but with numbers and maybe multiplying it or something similar to that, and that's essentially what number is. It's just a very simple way to to do a function that doesn't take more than one line of code or just takes two lines of code. So give it a try, and when you're ready, as always, I will see you in the next lecture 34. Map and filter: this lecture on map and filter are great illustration on just why I love Python so much. It just it makes things so easy on DSO so easy to do things, so essentially mapping it allows you to do the same function multiple times on on its trible. So, for example, you could do the same function on every single thing in a list, which otherwise would take a very long time to get through. Oh, you could use a 14 for example. But this way, using map, just it makes it so simple, and you can do everything in just one line of code. So that's what this is all the reasons why I like Python so much. So, like I said, map is a great way to apply any function Teoh to a large. For example, a list of inputs filter is something similar but allows you to go through a list and filter out things that you don't want in there. So you keep only the ones that you want using, for example, a loved a function. So let's start with mapping. In order to map through a list, you need two things. You need your input which will be the list, and you'll need a function to apply things to it. So let's say Ah, deaf. Uh uh, the deaf try literally. We don't use dry, deaf mapping. We put in put in excess. That'll be each element for with a list on. Let's just do make sure indented properly X times for to be reasonable and make sure that the lower case x okay, we want to return. Oh, why pressed up oppressed capsule That way Return extend for marketing And now let's set up our inputs imputed a nice range of random numbers. Okay, so we have a list of numbers. We have a function which returns the inputs, but times is it by four. Let's make it a bit more clear. There's times that by 100 so the way that we remember things out. First of all, let's start with the simplest part we just put. But the first thing we put it is the function. So he put it the day with the function, and then we put in the imports, which we've conveniently called inputs. Now it's important that we convert this whole thing into a list, so we create a new list that contains all of these elements of the original, but it applied into mapping. So we wrote this. Oh, as you could see we to remove those parentheses so literally just put in the name of the function and the inputs. And as you can see, what's happened here is that for the inputs Ha, let's try scary to run this. There we go. Now you can see all of the inputs have been times by 100 we have a new list. And obviously we would probably in real life new list or something would want to give you put it into a variable. So essentially mapping is a really cool thing. So you create a function, you create your inputs and then used literally, just use this map thing, type of map, the ad in the function and the inputs, and you make sure that you convert that to a list straight away, and it does it automatically very quickly. So moving on to filters, we'll do the exact same thing. Let's put it, Ted. 4 27 200 70 the 2.2 yes. So what I'm doing on purpose, it is for the inputs. Excuse for the inputs I'm putting in some that are multiples of 10 and others that are not because I'm going to want Teoh filter through this list and return only those that are divisible by 10. Okay, so we have this on it, saying it's invalidated. Tex Kennedy would like this and tell me what is invalid here. Let's take a look. Okay, here's the problem. We turned it into a cover. A decibel. Okay, so now, essentially, this is what we want to do. We want to use the filter here and a pile. Abdeh, What does God look? We got our place audible Call X as usual. And then we'll we will let you just put X, uh, divisible by 10. So I think we've gone over this before. Essentially, this is called ma Jealous. So we're saying there, if you divide X by 10 the remainder will be equal to zero. Okay, uh, that we're going to put in our inputs, which is number missed. Okay, Now let's see that. So hopefully this list will just be those that are divisible by 10. As you could see, it has been a great success So we've got over mapping and we've gone over. Filter we recommend is that you try this yourself. So has a ways. That's always my recommendation. I mean, I really can't put more any more emphasis on it. The best way to learn how to do these things is to try it yourself and keep continuously playing with them, making errors, see where the air is. Pierre, keep going until you really feel confident you could do this for memory. So you set up a function. Remember, this function could be called anything whatsoever. And you have parameter input and you say what to do with that? You have your list, and then basically, you're saying map and then in parentheses, your function. What you gonna do to the inputs, Evan, you put your inputs in a swell and you create a list out of that with filters. What you're doing is you're providing a function that's filtering out. So basically, you're saying from this numbers list, only keep those that are divisible by 10. Okay, so anything that does not that is not true. Here, as like we went over before billions true force. If this is false, that it won't be added to the to the list. If it's true, it will be so. For example, if we put visible by five, there should be a few bull uh, do this. Oh, sorry. That should be zero. This should be five. We've got a few more now that are so divisible by five, obviously the ones that divisible white end still there. So go through these. These two concepts aren't exactly easy. We're moving into the intermediate stuff now, so I really don't feel worried. If you're not getting this first time, don't feel overwhelmed. I highly recommend you just take one step at a time and just play around with these dubious times, maybe over a number of days. Just get familiar with it. These are the source of concepts where suitors Maybe at first you don't get it. But once you've done it 10 20 times, once it makes sense. It always makes sense. Fee. So if any point for these concepts, especially going on for the future concepts in this course on down to the future future courses that I'm gonna be providing if they're things that overwhelm you and you're not completely sure just keep doing a couple of times, play with it, get some errors, see if you can solve it. Obviously, if you having problems, leave comments in any of the lectures, no reply, but keep going on. And eventually these things will make sense on what they make sense. They'll stick with the and they'll be incredibly powerful tools. So that's my pep talk on. At this point, I would just want to say, Well done for getting so far in this course, you've learned a great deal of varied concepts, and they are all very useful tools to have so play around with these on when you're ready, we'll do a bit more functional programming in the next lecture. 35. Generators: moving on to generate two functions. These are really good way to it. Rate through a function. Andi provide lots of values on the fly and not taking up memory, so these could be very useful in a range of ways. Eso essentially a generator function works the same as any other function you do deaf. You define your function, open parentheses, colon, and then the important thing here is the yield statement right at the end. So when it says yield, it basically just means it's kind of the same is returned, right, Except it doesn't save to memory. That's an important point toe think about. So I've just set up a very basic function here with a four leave basically saying, For I in range, 10 year old ice is basically a print off all the values from 0 to 9. If I run this, nothing's gonna happen, obviously, because I haven't cooled the function or anything like that. Now, in order to generate all of these, what we can do is create four leap here. So instead of just calling generate functions, that's obviously one thing that we can do. But this but we'll get back is this. So what we want to do is to use it for, say, four, um, values in generates function, print about these. Remember, we can change these to everyone. We could change this, I or, you know, whatever we wanted, that doesn't matter. So but what wasn't born here is that we're iterating over a function before in the past with iterated over things like lists. But now we're iterating through a function and that's made possible by this yield. So if we run this now, we get values of 0 to 9. So that's just us touching on the basics of generating functions. Give it a try yourself, try and generate some things by yourself using for the for I in range on Detroit through this Jerry to function. Andi, we'll go through some more of this when I sent you to exercises. So give it a try for yourself and see our gaze. And I see in the next lecture 36. Decorators: right. We're now coming up to near the end of the course now, so I just want to repeat what I said a few doctor to gate and just really well done on getting to this point. We've been through such a range of concepts on I just want to make sure that we we managed expectations here because if you have been going through this so far without playing around with the concept yourself a some point, if you really want to get a good, good grasp of python, there's no replacement for just getting your hands dirty and writing out some code and practicing things. So all of these concepts on providing with all these lectures, if you haven't already, I recommend going through some of them picking up right. What's what do these concepts do? How can I play with them? Can I try and break them? You know what errors come up. All these things are super important to you. Do you growing as ah Python developer? So I recommend with all these concepts, especially the ones later on that we're doing now, Do you play around with them? A lot So insane that with decorators were going to be moving on to now. So this is another thing that we can play around with with creating functions. It's basically what decorators do is they allow you to when you're creating a function, say, within that function, you're going to be calling another function. But you're not stating what function you're calling at that point, so that at a later time you can then cool different functions from within this function. That might sound a bit complicated, but it's really not. So let's go through it. I've set up an example here, have to find a function called deck or on the variable the perimeter. Sorry, I've decided to put this funk simply because that's very readable. And now you know that the perimeter your calling is going to be a function within this defining another function called rap. It's important to have rappers something called Rappers in Here, which basically brings it all together so that I can call a function within here so you don't have to quote a rap, but again, it makes them more readable. You can create another function called whatever, but in general I recommend you call it rap or rapper so within What we're doing here is we're printing, high wants then we're printing high again in the middle, recording a function. But we haven't. We haven't stated what function that is at the end of it, we're saying, right, return all of this. So here I've decided to create another very basic function that we can use to cool inside of this. So I've defined the function. The function name is print text there. No parameters need to go into it. I'm just saying, Prince High World. So let's move this out of the way. Let's put this in over here. So if I call print text by itself and hopefully you know how to that by now, I type in the name of the function and then because there no parameters to state, I just use empty parentheses. I run it and it's going to say hello, world. Now what happens if I try and just run deck or I'm gonna have an era? Because, um, I have to state a parameter now within this contest, put in, you know, high or something like that. It's is basically no not gonna return what we want. Uh, so what I do is I created variable. Um, well, I don't I don't necessarily need to do that. But what I'm doing here is I'm saying deck or say, Well, if I want to see the results I d. So I'm creating variable called Decorated, and I am calling the function Decca, which is here at the top and then inside of that, I am putting what the function wants to be. I don't need to put the brackets of the parentheses at the end after print text because they already exist here within the rapper. So if I state that variable and then I run that variable, we have high, then high world, then high. I could also create another one. I'm gonna call it print numbers, and I'm gonna say Prince one gazillion. Okay, it's no you. Can anyone take a look and let me know what's gone room here? I'll give you a few seconds. Essentially, what I have missed out are the parentheses after defining my function. So now I can create another very Buchel decorated numb, for example, equals Stoeckle. This I'm gonna put in their prince numbers. And then if I call this decorated numb. You can see your prince high then that So it basically means I've got a function running on within it. I can run a different function of range of different functions, whatever I like. There's another way of doing this. So once I have created this function, why conduce who is simply put the at symbol here and then put the name of the function on Put that right above another function that I've created, as you can see automatically there has wrapped this print text with the deck or so Now, if I were to just cool print text Well, not wrap. Sorry, I've decorated the print text function with Deco. So now you can see that just by calling the print text function. And no, only just prints the hello, but it's printing this whole thing because we've put the at symbol above with the Deco. So this is decorators. I recommend you take some time to implement this both ways. So, first of all creative function, make sure you wrap it up in a nice function within the function. And then you have this placeholder function in the middle or wherever you want, creates a second function, Set up your variable like this and then cool it. So that's the first way of doing it. No, I recommend trying out inserting different functions into it and then try doing it this way with the at sign. So give those to try each of them. Maybe one or two times haven't think about right? How could this actually be used within a program? How could you use it? And when you ready, let's move on to the next section. 37. Rcursion: moving on to Rikers in S. This is another method used of within functions. It's important for you to get an understanding of the basics of how incursion works. I wouldn't say it's is important as mastering for lists or for generating basic functions, things like that. But I would say it's important just to get an understanding of what this is. It's no used all that commonly why I found from my experience, but it's important to know of it because it can be used quite often. It depends in how you work. What's your stuff you do with Python? But let's go through it. So essentially, you. First of all, I've written this out, defining a function called factorial with the parameter X. I'm saying, if X is equal to one return X otherwise return X times this function with the parameter X minus one. So I'm calling this function, and it should come up with 24 which it does good. So it's kind of hard to get your head around. What's going on here? It's basically looping through itself until X is equal to one. I've written this up just to just to help you to tow us together to look through it. So first form calling the function factorial for and some saying four. Because until this number here is four being is one being called, it's not going to stop, right? So we're doing factory before they were saying Right, this is four times factory or three. This is this part here X times factorial X minus one. So we've got that, and then we're looping through again. We're saying so now it's four times three times factorial, too, which is the same as four times three times two times factorial one which is the same as saying four times three times, two times one, which turned out to be 24. So have a go at this yourself. Try according a function within a function. Play around with it and see what applications you can dio. I'll include a few exercises in the practical part of this sanction. But just after this, make sure you give it a try yourself and then I will see you in the next lecture 38. Practical 6: okay, so well done for making it through functional programming section. I would say this practical part is probably one of the more difficult. One to the course will be gained through Lambda Map and Filter generators. Decorators Ryker Shin. If you felt like you grasp the concepts right away, then fantastic. My intuition. That is, for most people eyes that with these concepts, especially, they need to play with it many, many, many times before they feel confident they have gained an intuition into how to use these. So if you struggle in the interest of these questions, don't worry too much. What I would suggest is that you go back over. A few of the lectures had play around with concepts of it a bit. Also feel free to take a look at Stack overflow and Google. The concept as well has always helped forward to get other insights and other angles. And these concepts, I just try your best. If you have any issues, you can always comment in the lectures. Either myself or the other students who grasped the concepts better will be able to help you, uh, ads. When you're ready, you could go onto the solutions of these on. I'll walk you through how to make these work. So good luck, and I'll see you in the next lecture. 39. Solutions 6: so to begin with, I just want to say really well done for giving this a go and going through the questions hopefully have gone through all of the questions. And now you're ready to find out the gaps in your knowledge they're missing how they could be filled. Eso Let's start with Lambda. Lambda is one of the easier ones out of these as we talked about before, they're like creating functions. But you could do that just like as a one off in one line. So you start off but writing Lebda we want to print this, say, but as well, why don't so we want to print. We put two brackets here because first of all, we want to call make the statement which is loved, uh, using a placeholder court X. We want to multiply X by three and then subtract seven. Okay, so that's all Abda We put that put that in one set of parentheses. So we're creating our function was saying using, said Lambda. So basically saying Do this function with a place on the X Times X by three and some tractor, and we have to put X minus three x times three in brackets before the seven. Because we want this to occur first before subtraction. It's always just safe to do that. 77 the computer think it should be X times through by a seven, which would be X times minus four on then in a separate brackets. Pregnancies we wanted for Ed work should be. And that's 100. And they re close with another set of brackets. And then here we have 293 So where we could actually just remove that. I believe I just don't like this as well. So, uh oh, this thing is right. Yep. Okay. Course so greatly on them to function. And then we are saying what? To fill it afterwards. OK, so moving on to map and filter, use the function of this below. Use the map function. Okay, so we have a function and we have a literal, which is a list we basically wanted. Wants to carry out this function. The death exponential on every element in the list. Ls So this is where map comes in really handy. Well, we have to do I really love Max. It's so simple. If you put back that just literally just the babe off the function. One use and it's terrible. Now you may have just on this Internet had got this would be like, Wait, what is this? This is crazy. The thing is, that's just having you this It's a function that's been created. You want to convert this whole thing into a new list, right? Because you're creating four new numbers, so you want to put it into complete new list. So if you put in this now and if the house of breath sees wrote it within it, Did you get this? Get 10 to the power of Wanted about four Power eight, partner looking. Whereas if we had to just have this as time Stead is the power of that, we would have got these. Of course. Okay, so feeling filtering out all the elements This is where we used Lambda Lambda comes in use . So festival We want to everything analyst orderly and actually so first we just put filter . The same thing is before we want to put function and then the list. So the function now is going to be a loved up so we can put Lebda ex Selby any element in the nest we want to keep when x divided by to zero. That's basically saying the module iss I think I've talked talked about once before. But this is the modular side. So you divide x by two. The largest is the remainders. So if you did for example three divide by two, you would have one remainder right? Do you want with the remainder is eerie. I eat whether number divides by two perfectly with the number is divisible by t So that's us filtering out things that are developed, visible, weighty. And then afterwards we just put the list that we want to use, which is ls this should print out this and then we want to put everything into a nice lovely this every day we just have four date. If we were to change this murderous to three, for example, we're just gonna get the number died, right? If we were to put changes completely and say anything, there's X where X is less than nine. They would just get those ones. Okay, so that's filter. And I still say these are what I was really before. Just a check. We can use these as the example. So for generators setting up a function that returns four numbers say we want to use for something in range loop and then use another four leap to call the function. So this is what I've done here To find a function with a parameter X, I safer. I enrage x yield. I remember for generators, you want to be using that word yield yield, not return or print. So mystified that function. So basically saying for I enraged that say we put 10 for example, they would say for 10 times we want to repeat, well, the yield I which b 01 Teoh up to night. Okay, No, this is where it gets cool. We're saying for for K in. So for whether in food, that's the the function and we're pretty the parameters three. Okay, so the sheds print off the numbers. Zero. If you want to pretend like I said 50 wanted your first inmate died. It's that that's the use of a generator moving on to a decorator. Okay, so I've created this previously. Eso basically in decorators, you create two separate functions, one of which takes four or as many functions as you want, but essentially you're calling a different function inside another function. So here we're creating a function defining it called food with a parameter, which could be named 80. But according it funk, because it's readable, then you you understand right away that you pick a function into this into this function. Eso we're doing print test just to show that this is this function is always gonna print test and then we're going to cool whatever function we put into it. So we've created function here called Food two, which just prints high when it's called Let's create 1/3 functions. Well, just for fun disease. Okay, print third, third full showed a But folks, you only like a perfect. So now what we're doing is we're going to cool the function food using food to source happiness go First print test. There is going to call the function which is for you to so shepherd test and then high. No expert apologies. Maybe it's d print food. The Cape Apologies. I just hadn't run these cells yet, So is using the food food to up above. So we run these makes were running all of them then food food, too. As you can see, it prints test and then high so we could changes to 33 now that we're calling as a parameter within the function food and it should print test, then third function on May. There were good and that is decorators so moving, finding onto occasion using a function, have the function outs, outputs, apologies, Alper number and then court itself as a function repeatedly outfitting from 10 down to three. So I've done here is I've set up another function called food and with a problem X I'm saying to print off X, then if X is more than three, so basically is going to call its function again in the same thing minus one. So next time it's going to cool. Let's say we put in food 10 that what's gonna happen is go print 10 here and then it's gonna cool. The number nine here says corporate died and eight etcetera, and as soon as we get toe ex being not being more than three, so I x is three, then is going to stop working. So what we're gonna see is every number from 10 to 3 the every day. If we were to do it for that, say, 17. I don't need big numbers, but you will go from 17 down to three. Okay. So congratulations on making it through the section like I always do. I would recommend you play around with these things. All of these are very, very powerful tools on, if you condone. What I'd say is, if you really want to get foundation here, I'd say at least be able to confidently create Lambda functions. And, of course, normal functions would be helpful to be able t use mapas. Well, if you want to just start with a foundation. If you could do filtering generators, decorators incursion, then that's absolutely fantastic. These all intermediate concepts now. So you really stepping up your game? So congratulations. You keep up with the the momentum. And when you're ready, I will see you in the next lecture. 40. Classes: Okay, So moving into object orientated programming, we're gonna be going going over the concept of classes. First of all, just to talk about object orientated programming, little bit thistles, one of Piland, strong points. It's incredibly useful for so many different areas, and I'm going to be going through a few of them now. So two of the big pluses of using object oriented programming and using classes is that you can group functions together on call them. Using the class on you can also use classes. And this is what's very often it's used for is creating blueprints for things. So, for example, the one that will be going through is creating a blueprint so that for a game like the Sims , where you can then go along and enter basic details, just stating the class and it will create it will create. The blueprint will create your SIM from that blueprint. So that start from the basics. Eso The first thing you want to do is to it just had to check the my microphone was definitely working, so Ah, yes. So first thing is the estate that we're creating a class, So with functions we always put death first with crosses. Voice put class first. Andi, as a rule of thumb. I mean, you don't have to, but it's used all the time. Is when you set up a class you have. You name it. You want to give it a capital letter. So I'm gonna call example. So I'm going to capital that here and then, as always, I'm gonna put the colon, and then on the next line, it's indented. So first thing, aggression is that you can put in loads different functions, and then then call them from this class as you like. So I was gonna create some really basic ones. So deaf, high print. Howdy. Then I create another function called death. Hello. And then print off. What's what's it? Okay, so then this class have created two different functions, and now you can call them anytime you want. The example. Dots. Hello. So you can cool the different ones as you please, and it's just a good way of grouping your functions together. Sometimes. Now we're going to brief prints. So, for example, this is re important concept that you can create blueprints from a class, so let's go straight enter. I'm gonna call this class Sims. I mentioned that as an example and within. So this is this is where it gets not complicated, but it will take some time just to get used to it. If you want to create a blueprint of something, the first thing you have to do is state what different things air acquired in that blueprint. So, for example, let's say you were creating like a currency, like a number of coins you'd want to be able to stay what the color should be, what its value should be on when it's I should be. Because we're doing Sims. Let's say that we want to state what their name is, what their sex is, Andi their their their favorite hobby. Whenever you're ready there, Chef, do something called create. You have to have to find a function with two underscores and in it, Okay, for now, we won't worry about what stands for this is just just how it's done. So the first thing you always put itself, and after that, then you put in the different parameters that you think are important. So we put name sex Khobe. Oops. So this function Now we have to stay it like this. Self dot name equals name. And so I'm self taught sex because sex itself talked. Hobby equals hobby. So my seem a bit strange, but this is what you're supposed to do when whenever you set up a class and you want to have some kind of blueprint, you make sure that you said you do a function called in its with 200 schools another side, and then you have self. Then you have all the parameters that you want, and then you have to state self Doctor, these parameters equals the name of the perimeter. Okay, So once you've done this, then basically you can just say we can create different Tim. So I'm gonna have ah Sim called Andy we have today is type in the class name and then within it, you simply states his name Andy. Some creating a completely new, similar male and then hobby can be acting. Okay, so now we have from this blueprint, we've been able to create very easily the Andes name, sex and hope. So now we can say, uh, script Wilmore's. Well, actually, that's creates good old Jim. Let's see what you like city. So we cool the name of the class to find his name. He is male on his favorite hobby is juggling. He loves to juggle. So let's just say that we've created 100 different Sims. How could we easily find out what one of their names are? Or let's say we we want to know Jim's hobby would have to do is put Jim the variable. And actually, because this is a variable name, let's keep it to lower case. She was simple. Jim dot sex chance from them. Male Jim Hobby. Oops, that's transport correctly juggling. Okay, let's try to you, Andy. So obvious. Acting so essentially is this is just a really good way of creating a number of different objects, so each one of these could be described as an object. So what some other applications you could do? Let's think of. For example, if you're creating a game on, do you know you want to have a lot of enemies in there and you after each time you have to define what their strength is. Their movements be their size or the source stuff. Then you will need to be ableto have a class, so it's really easy to set this up. It just saves you a lot of time. So that's the basics. Off classes we recommend you do is try that example. I was just talking about great great A class for blue printing enemies in the game. And you can state whatever promises you want here net their names, their strength, their size, their movements be worth so stuff eso you give it a go and then you can try and find out different parts of information about them by simply doing this on DSI. If you can create a few functions from within a class on, call them outside the class. I just remind you what that's like. You just state the Kloss 0.1 of the functions? No, with princes. Okay, so give those ago on, then I will see you in the next lecture. 41. Inheritance: so one important concept in classes is inheritance on. This involves having a super class. So let's imagine for a second that you want to have a blueprint but you for different things. You want different things happen. So let's say, for example, with in the game, you might have allies or you might and you might have enemies on DSO. For allies and enemies, they all have the same parameters or attributes such as I don't like heights or, like strength, wisdom, movement, speed all. They saw things that tend to define a lot characters in the game. But let's say for for the good guys they can. There are certain functions or certain things that they can do. And there are certain things that enemies can do or you might want separate into, like wizards. Barbarians were wizards there. The function should set are things where they can cast bells. I don't get get into too much complications, so I'm just going to show you what I mean by this. Let's split them up their characters instead of good and evil. Let's put up into wizards and warriors. So first of all, we're going to create a super class, okay? And this is no different how we set up anything else before. So we're going to call this class. Excuse me? It ain't kept toe see on the cross class character, okay? And then we're going to do the old death. Said the function in it to underscores on either side, put the self and then we put the other parameters. The other attributes who want toe have forgotten. Unless you say for this, they have strength. Um, magic and movement. Speed. Okay, so we keep it simple. We just have three of these. Um, So once we have the stated, we're going to just do this whole thing that we're doing before, I don't know. So we're going to put Self dot strength whose strength themselves dot magic, because magic just tidy this up a little bit. Sorry. So, yeah, it's a bit boring doing this bit, but it's always has to be done. And a movement speed equals movement. Speed. Okay, so we set this up. So we have this blueprint from which we can always create characters. Now, let's have two different types of characters that we can have their say. We have a class of Wizard. And now, in order for for this class to inherit everything we've put here in the character class, we simply puts character here in the parentheses. And within here we can say we have a spell that say so. We define a function called Spell. Um, and we're within these functions is always guided just to include itself in these parentheses, and then we can print. So I mean, overseeing the game would be a lot more interesting that, But in order for me just to explain the concepts of what we're using here, we don't need to do anything more than that. And then we have another one cool class warrior again. We put character in here to make sure this class is now inheriting from what we call a super class. There's nothing different about this that makes it a super class. Except the reason why we call a super class is because this class is inheriting from this class. So the character class is by definition now a super class. Just because of that, So within hit, that's great death strike and then itself none prince. But that was a strike. Just make it very clear. Thank you. Thank you. So now what we can do is essentially, we can create, um, this create Gandalf with two f's so that I can't be sued for copyright. Um, just getting on. Then we states the class that we want. Okay. And then essentially, what we do after this is we put in, um, the strength, magic and movement. So let's give the wizard to strength. 10. Magic earned six movement speed, and then we can have a barbarian who's a warrior. And so we just do this. Then we can give him whatever I say. He's 10 to on eight. That's a Okay. So now we have created two different characters from our blueprints or from from here from our classes. So let's just do a quick check. Let's just check on Gandalf's, um, strength you can see has the strength of tea barbarian have the strength of 10. Okay, so now we want to try and get that say the barbarian to, um to do a spell. Let's say so. We have to do is puts. Let's see, barbarian dot strike and it should come out with parentheses. Bash. That was a strike. OK, so that kind of makes sense, right? Because when we created our character, we used the class warrior. But we're automatically able to use this death in its to create our character from the super class character simply because character was put in here as a parameter for the class warrior. Okay, so it was easy enough for us then toe do this. Barbarian. Don't strike. The important thing here is to realize that we're able to create these attributes. The strength, the magic movement, speed by this class, inheriting from the soup class. So I I recommend for you to do the exact same thing. Have a play around it. Play around with it on when you're ready. I'll see you in the next lecture. 42. Practical 7: okay to wrap up this section. Here is a few questions. A few practical parts on object oriented programming, pretty much focusing just on classes and on inheritance. So there are a few questions here. Go through at your own pace. Do your best. When you ready, we could go over it. The solutions in the next lecture. 43. Solutions 7: So what? Um, for going through the questions by herself. Now, let's go through the solutions together. I have, ah, pre prepared a few answers that just run three by myself because there are many areas that could come up along the way. And I want to make sure that I keep this succinct fee. So let's look what I've done here for setting up a class to act as a blueprint. So first of all, I've defined the class coin. So instead of being deaf like you do for a function of put class, and I've called it coined with a capital C. So keep in mind when you're defining your class, you tend to give it a capital letter at the start. And then here I'm doing the death in its with self to start with, and then the three parameters size, weight and color. And then I what you could say, activating each of these self taught size, equal size, etcetera. So now I've created this class. I can create a number of different coins. I decided to create a 50 pence piece that's from a different planet, because let's say the size is in centimeters. The weight is in kilograms on. The color is obsessed Ring, please. So, of course, if it depends, piece here and a 30 pence piece here. So using the class coin and then it goes through one off the other always ignore self. Then it goes through so size weights and color. So I decided to give it 10 10 agree and says, Great, that's okay. Now retrieve the size of a coin you've created so instead in color. So that's the size of 15 piece. We didn't you put 50 dot size. I don't three, which is correct. The check this with 30 pence piece Ted. Perfect. Okay, so now we're creating a super class so moving on to inheritance now. So when you're setting up, there's nothing different a tool, So there's nothing have to do to make it a super class. At this point, I've despite cycle that class Carver, because I realized that later on down here, we're creating another class called Khar. Say I'm credit card verb. Let's call it something better that's quit car vehicle. Just make it more readable. The deaf in its ads. Yep. So we're calling the size here first. We were basically activating the size and the noise. Those two parameters I've decided to do for the car or they Yet this actually. So now we are creating another class inheriting this from the car vehicle because we don't have to want after again just for every truck set up size nor etcetera. It's just as well. So we're going to be inheriting from car vehicle, which now makes car the car vehicle class. No, it makes it a super class by doing this. Okay, I'm setting up a function called Chug, and in here I have to call self or show you in a second. What happens if I went core self? It gets ignored essentially, but it's important Have in there, I'm saying when this function is called print chug because that's the exact noise that attract, attract makes, I believe, chug just like that anyway, So now we have created another class, so we will recreate another glass called Khar inherited you get for the super class car vehicle, adds this function. Prince ver. So let's go to this car vehicle. So I'm saying oppa function could ver and that including self and obtained the function when it's called to print. So now let's go ahead and create a few cars and make the noises. Okay, So in this first instance, I'm creating of Oxo. Yes, indeed. I am trying to get sponsorship from walks up. Just getting, say, I'm calling the class car here, and I have to then say basically what the size and the noise is because it's inheriting from the super class. I still have to define what its size, its noises. So let's say this is three meters log on the noise that makes is free. So what I was thinking about earlier is actually changing this noise to something else because it makes it kind of confusing. Were changed it to color, actually, um, because we're already using functions data down to make the noise. So see, that looks blue. Okay, So, Justus, before what we could do Name cars that find Okay, of course, we haven't really these yet, and right now we have run them of creative oaks. Also, as always, we can find out its size easily color if you're American. Apologies for the spelling of color. This is just how we do it. Indignant. Um so another have done that we could also, for the function they vote making noise. Now let's create a truck together. So we're going to say this force a brand called Truckee, which if it hasn't already been made, it should be so. First of all, we're calling so saying the variable is Truckee and just make sure confused. Lower case. We're calling the class truck Truckee. They would say What science says Big hurt silver. As always, we can get size and its color. There we go. And now we could get to makes a nice noise. Truckee making noise for us. What's it's function? Name? It's jug that live interesting. Okay, So what's happened here? Let's take a look. We have created this using the class? No. So the problem is here that I haven't used parentheses to actually cool it, So I basically just entry. This is, say, yet this is what according abound, Method. Um, so sometimes when there's a function within a class, you call it a method of avoided using it just to avoid complicating things. But it's a good thing today, so functions within classes often referred to your methods said if I call the function day it should go chug. Give a good kind of sounds a bit more like Pope, either the truck. But oh, well say that's That's what happens Now. Let's look at a few things. How could go wrong? What if I would try and cool the via the vory function that comes with the car class? It would be happy that because Truck has no object is not to be the Our truck is no associating with cost client anywhere tour. They're both connected to the car vehicle class, but not to one another. So I can't call a function from another from another class. Now let's see what happens if in the class I remove that self from the for the function. So we got it. We butts truck talking up. Chuck. Uh, still good dressing. Did I wrote it. Did you? OK, so that seems to run just fine as well. So you may be Sometimes you don't even need to yourself. I've always yourself just for good practice, I guess. But it seems to work up so you find so you can put self in order what it seems. So that's a that's a nice little for me. This is class is why I recommend you do is trying to the exact same thing again now that we've gone through it together. But try and do with something complete different. So instead of coins, you could create a factory for toys. And you could put in again the size, way to the color or the age recommendation or something like that. So do your best to go through it. Try and set up a super class if you can. And when you're ready, move on to the next section and congratulations for making it this far. You've learned a lot since you've started this course, so give yourself a pat on the back. 44. Github: If you are interested in building a portfolio of your coding and the code that you create either because you're looking Teoh, eventually get job in python or you're interested in just sharing your code with other people. I highly recommend you set yourself up with a get help account so these things can be completely free and very useful. So if you're interested, I recommends going through this lecture. You start by going to get hub dot com g i t hates you be dot com and set up accounts. Won't you set up your account and verified your email? If you go to this arrow next, the plus sign you click on New Repository is basically like creating a folder. So I'm going to call this I don't know, um, foundations. So I wanna show off. I have foundational skills in Python. Don't say developing that intuition for for basics off python. And then I might create one later for intermediate stuff, etcetera. I'm gonna make it public so that anyone can can use it and then all initialize with you. Read me. It's just useful. Top this. I created repose story, and now whenever I want to add some you came to this all have to do. I can either create a new file. I can upload existing files were just clicking this. I can If I have I p Y a b five, for example. I could literally just up late it here, Um, that can create a new file. But I can literally It's already set for me to write in some coats. So I'm gonna call this print and inputs so I could religious, but in here print. Hello inputs. What's your name? For example? Right. This is a very basic code. So I've created my code. The bottom I committed which basis means save it to that a repository or save it to that folder. If that's easier to understand, then you could just keep doing this, and I could go back to this one and click on edit That essentially has Make sure if you are doing stuff like this, that whenever you right out code or you insert Kate, you're putting a little commented on the top or within just commenting on what you're doing . So when someone's looking through it, it's relatively easy for them to understand what you're creating So, like I say, it's a very basic introduction. Teoh, get up. I recommend you set one up for yourself and just start up loading some of your your codes. Want you want. You get to playing with code and creating some of your own stuff. So, yeah, I recommend you set up and hopefully you'll start to upload a few things, and as soon as it's ready, please please do comment in this lecture. Send me a link to your get hub on. Then I'll check it out and I'll let you know what I think could give you some feedback. 45. Resources for growth: well done for making it through the bulk of this course. You've gone through a great range of different concepts, and you've grasped a lot of the subtleties of python. Now I just want to go through a number of resource is that can help you to get to the next level of Python. One thing I want to really emphasize is how important it is to get experience. Encoding. Courses like this are incredibly good to give you the foundational skills, understanding an intuition toe help you to go out there and become a python master. And if you say so, pleased to get a career in Python kating. But it's so important to get your own experience of it on the way that you can do that is through so many different ways. Checking out different blog's going on Reddit checking out there subreddit for bison, for example. Danity APs And of course, there are a number of different practical practice exercises. They're out there, which I will be adding to my course in due course. That could help you toe develop more of a mind set of developer. So here, a few resource is I'll be adding to them all the time. So by only be adding the ones, I think a really worth put your time in t. So, first of all, land path Python the hard way dot org's fantastic has a lot of different Resource is, especially if you're looking to expand beyond Python as well. Ah, highly records. You check out the websites Andi, also check out the book itself. So I got the book and it was very helpful to me. Well, so did I. Would recommend practice. Python dot org's has loads of different exercises on the number of Cheney's represents. Are difficult is so you can start quite easy, and the four chilies are a lot more difficult on. They all come with solutions on go through what you've learned in this course. You should be able to get through most of these things, So give this a try. I highly recommend you do a few of at least the easy exercises in this site. Also there, Solo learned, and they offer a range of different free APS you can use to learn a number of difference coding languages, including python. So you go to the website solona dot com. slash course slash python. We go straight to the APP stores and download them for free. They're very useful. Teoh. It's providing. They provide mainly tutorials and some practices exercises. But it might be a good supplement. Your leading then get help, which is which is very useful. So you have this guy called If you spell, it is Ed. Hey, H I w e hate you. He basically provides a lot of difference Practical exercises for you to go through developing intuition. So there's just some resource is like I say, I'll be adding a few extra as time goes on, but only the ones that I think are worth your time. So give these a try on if you take them out, comments in this lecture and let me know what you think of them. And if you have any other recommendations yourself 46. Learning summary: Okay, guys, we know coming to the last section. Of course on they get too emotional me yet we've still got a nice section two gay. So in this lecture here, this is going to be probably the longest one of them all because I'm basically gonna be going through all of the different concepts. Love, the main contact. We've been going over throughout this course. So whenever you feel like you want to come back to this course and do a quick refresher, I found a lot of people. People have been requesting this. So this is so somewhere that you can come if fast forward to the right place on the right subject for you or if you just want to refresh everything. You could just come to this lecture on. I'll be going through each and every one of these concepts with the practical parts. I'm just reminding you of how it works. No, of course, over time will be adding mawr content, more concepts to this course. So there may be a few things that missed out in this lecture. If there is, please do feel free to let me know. And I can always trying at them at one later, so I'd be a sitting comfortably with a nice cup of tea on Let's get Started. So the first things that we started working on a very basic things, such as printing input and commenting so printing. Let me do this in a separate line. Actually, Teoh. So printing simply put the print command and then parentheses or open brackets. And then we can either print off a string by putting in the quotation marks. And, of course, we've been going through using dupes notebooks. We run a cell biting shift. Enter as such, it printed out below. And also you can print out numbers. And of course, we went through creating variables, which I'll do above here. I can't really call this very oops. Sorry. I'm going call this variable A equals. Hello. And then we can simply print out. Variable out will come. Hello. Whoops. I need to run this first. Of course. Okay, So once we'd learned how to do Prince, we then went on to getting input from the user placing the input function. We have parentheses again in the text we put in here is simply what the user would see, So please and age code on space you need to just but just looks nicer when you run it at your age. Okay? My my age is 29 and that puts out here, and you can still this also in a variable. So if I had to print it out now, there we go. And also, we went over commenting So you can add your own comments into any code. This would affect the code. As you can see, it doesn't affect this code. Atal. We also went over Hokies multi line code. If you've got a lot to say. So you just put anything in here? Hoops? Lots of comments. Now in Jude's Notebook, this does print out with backslash. Doesn't like it, says you can see it's literally just printed out the variable. Okay, so now moving on to the data types, we were then showing that there are a number of different data types. You have the main ones. We look at our strings, of course, waken Look at what the different types are by licious putting type and then in parentheses . We can put this in, comes up with strip which stands for string Instead of having a string, we can have numbers. It will come out as int, which is interject with a decimal place. It's going to be afloat. So those are the main ones that we've been looking at. We also have the BoDeans true and false. Good, certainly just a nicely to next thing, which are comparisons. So with comparisons, that was things like equals two is equal to not equal to more than more than or equal to in out. Let's go through a few of these now and obviously comparisons mainly what you're gonna get your output is true false. So, for example, one is equal to one he comes out with. True one is equal to nine. Force one is not equal to 200. True. Okay, let's go for this one is more than nine close. One is less than nine. Treat one is less than one one. Is that senator equal to one? Okay, I think you get the idea. Ah, let's go for a list J hopes to do Jim judge. Okay, Now we can say, uh, Jack in a first base saying, Jack, this this string is in the list, which it's not however, Jim is okay. So there's just a few comparisons for you moving on to if else. This is where we really gain to the more of the heart of creating now. So let's say, Uh ah, let's say, Jim, the case equals other. Let's get for Jim. Age equals 20 and then we can say it. If Jim I'm just happy tab toe auto complete. There is equal teas using comparisons. 20 Print you, uh, 20 on then we just did l statements afterwards. But let's just make this people fun. We're gonna put this as user age equals input. What is your age? Okay. And then we can put this as if use age is less than 20. You are less than 20. And if use a age is equal to 25 Prince has, uh and then for any other age prince, you are over 20 but not 25 which is an incredibly useful program, as we all night just getting so if I were to put the age as 18. The view to run this we get an error less than ah ha. So of course, because with imports, they always outputs where these enters the outputs as a string. So we need to put this as a, uh interview. So I'm going to put user age equals user age, some replacing the user age variable with an Inter Joe. Okay, so let's see if this works 20. And they say so. This is nice, though. Trick I've used here, which you haven't seen you in the course have basically replaced. So this is why I have first the user input and then I'm basically saying now the variable is equal to the interviewer version off this. Okay, so let's enter 25. This has ah, Seems like our program likes people who are 25 if I am 1000 saying you're over 20 but not 25. So if I mean the thing I really like about if and else is that it's so readable, you know, basically reading out loud. If this variable is s and 20 then print this L If so, remember LF means or if so, we use else to basically say if anything else, other than what we put the if statement or the other statement. If that's not doesn't happen, then do this. So we use LF to be a bit more precise and saying, If this do this or if this do this otherwise, if if neither of those things happening, then we use the else of the end. So then do this. So that's very readable, the if any, if us so. While leaps while it's very useful, especially often in games. So, for example, let's say we'll give you two different examples. First, we're gonna do a counter because 10 let's make this a bit more graceful. Health equals 10. So that's a win. A game with use has 10 health. Um, while health it is more than five. Um, print health. We're gonna use the dot format if you remember that. So we're gonna put a string and also including this variable in there. So print your health is the music curly brackets. Then after the quotation to put dot formats and in those curly brackets we want to put health, Uh, and then we're going to do health. This is another trick. We went over in the course minus equals one. So basically saying take one away from health. Health equals health minus one, especially what we're saying. Just like I was showing you above where I'm taking this variable and replacing it with itself. But as an integer here, you're taking the variable and replacing it with one less than what it is in the moment. So it starts is 10. I'm going to say health equals 10 minus one. So benign. Each time this league goes, health is gonna go down by one. And then this wallet is going to stop working as soon as health is no longer at five. So I'm going to put just to check this out of print your health, his five checking health equals And there were many rackets. Don't for that health, just to make sure that we're correct. So that's run this and, uh, what's happened? String object has no format. Oh, type. That's always nice when it's a type for march for but very it. You have this 10 98765 Checking health equals five. Perfect. So another good way to his while is you can let you say it while true, because by defaults you it's always true that, my son strange. So if I were to put prints high, it would continuously print high forever until I cancelled it or my computer got tired of doing that, Bob. Going to just put, um, could still healthy equals 10 here. So I really something fun yet? I'm gonna include using an if statement here, So I'm going to say use the decision equals inputs. Ah, ad hope or take it away. Okay, this is gonna be fun if use ah, decision. Because I'm skipper here from the user that plus or minus. If you decision equals the string plus health first equals Sorry. Plus equals one, uh, that if use ah, decision because is equal Teoh minus health minus equals one. Um uh uh yet Okay. So if you don't if they don't enter either those I'm going to say break. So if the user adds, um, like this, let's have Q for quit. So l f we're not gonna have an else statement here, basically. Actually, we will, um LF use ah decision is equal to Q then break. That means basically if the user enters Q then break away from this wall leap. Um, but if not, it's just going to keep on leaping until I decide to quit. And then else one good do is print command not recognized? Because basically, in this program, we only want them to enter plus minus or key. Someone's gonna say, Come on. Recognized. Try again. And then off during this, of course, it would just go back into the top SE wants. The sleep has broken and the user has decided to enter Que I'm just going to print final health. Curly brackets don't formats. Uh, health. We were poor health as to here for ever. So take a health or take it away, actually. And or so, um Well, I can't at the top here are mostly gonna put use of health that the starving people were prints. Your health is former because this way, each time we get to see exactly what how health is doing So if we run these now, so healthy goes to your health is to add health of death. Wait cases Add some First your health This street, right, a bit more health is full And take away. Take away, take away and then find me. I'm going to quit. Find out one day gate. There's a nice use of a wall while leap in the game. We just have wild tree. It's basically keep is gonna keep keep going until Teoh we put in Q. So just to reinforce is just want to show you that this could go into the negative. But I spent a lot of medicine. Come on. Now recognized. I'm gonna keep taking my health, you know, against the negative because there's no logic to say you can't have my yourself. It's only when I put in the queue that breaks the while leap with that break statement, OK, moving on to lists. So we learned how to create lists. Very important date structure, especially in machine learning. So lists are basically just a collection of ordered collection of elements that can be numbers they can be what strings they can be. Variables use the health variable, for example. So you know this Still these variables? Of course. We have lists within lists, so we can have, um 23 We could just put a lesson. Another list. As you can see, we now have two lists within one list. Um, we can create list using this convention so we can put l s equals and we're using four loops here which would be going on over afterwards I i for I in range 12 tendency and that will create us a nice list. Um, if we just won't print out No. And you can see now what we've printed out. We have a nice list has been created through this cop Regine. Eso no weaken do list slices. So if we use this this, for example, if we wanted Teoh this Teoh you called us by putting the list name or the variable name on the new pit in square brackets, which element you want, which index you want. The index always goes from zero, then 1234 etcetera. So if I wanted the number five I would have to put is the index for they would get five further if I wanted to get a slice with a few more. That's a 3 to 5. I have to start from 012 next to and I'd want to got Teoh 345 because it goes. The first on the Putin is where it starts Deeper code on the second of you put it basically means go up to this number, but don't include it. So Syria 12345 So we'll get out. Fifth element Fifth element is six, but only print out up to five, as you can see. And then finally we could have Teoh six and say We have a step so it's gonna step. It's gonna miss every other every other element out. Let's go again. Steps of to We could even if we want Teoh. One cool trick is if we want wanted to reverse list We leave the start and end Blanks were saying Do the whole thing and they were saying Do a step of minus one. So basically all belt give us that list but in reverse OK, moving on to full lips. So for a simple example, if we have this list thirsty, we could do for number in list print number. So weaken change number two, anything weaken Just have as letter I The reason why I couldnt number is because it's more readable to put it as this, but you can really call it whatever you want. So if you run, this is gonna print off in turn, each one of the things in the number, we could do more interesting things, such as each of the numbers plus equals, hundreds were adding 100 to each of them on. Then. We're using this core a pen function which I talked about before a pen basic means add to the end off so we could adds to the list each of these new look new numbers basically okay , so moving onto functions. So, in creating functions, use death, which means define. And then you give your function name. So, for example, it could just be food, so basic function could be like this print. Hello? Oops, prince. What's it? Things that it So you create function, but nothing actually happens. You have to cool functions. And so it functions a very useful if you want to do the same thing multiple times using your code, they used very, very often. So it's very important to get the concept off. This, um, can also add parameters into these parentheses, so se x and why is placeholders and then prints X here, but not as a string glitches print the letter X, then print why and then in here when we call that the president parameters, uh, testing 123 So that's being replacing. Gonna replace X with testing and why, with 123 kids from this again With this, they get prints out. So importing modules is very important because there are thousands of different modules that could be used in python. For example, we could use random, which we talked about, which just basically has a number of pre defined functions to be used with a random with random. You could be cool things like prints random and then any function you want a cool from the random module. UFT random dot and name of the function. For example, random interject between one and hundreds. Let's go print off a random in nature between 100. We also went over how you can import them and give them different names. Import random, as are indeed, for example, so now it just makes it easier to type random. We also learned how to do from random out important, just like one function, for example, import round. So now we have to do the R and d dot We just do this, you know, did the exact same thing, which is nice on. As I said, there are thousands of different modules that can be used with a number of different frameworks. So, for example, in machine learning, we often use something create by ghoul cord tensorflow, which will be going over in the next course on machine learning. Right? So going on toe opening, reading and writing files. So we went over how Teoh how toe create and then read text files. So you start off to find your variable, and then we put open in the name of the text file. So remember wherever, wherever we rights here. So wherever we're running our duty, Nobert from that is the directory or the folder in which this TXT file will be saved on to . In order to read it, you need to be in the same directory. So, uh, practice stopped txt that's going to the name of our file and then we wanting to open the file in write mode in order to create it. And then once we've created that, we could do file don't, right. This is a new file than backslash end, which creates a new line. This is exciting by such end for New line has ah summaries. I really like that word today has Ah, there we get So this number here the outputs is just the number of characters. And then once we're done, we defiled up close and then empty brackets. Now, if you want to read this file, we create a new variable. We can call it file, read Rita equals open and then the title again. T this time we want to use read one thing to point out with the right mode is if you use rights on, then you open the same fall and try and write again. If you use w is going toe overwrite everything in the file. So if you want to add on to the end of the file without replacing what's already there, you should use the dot a pent. Sorry, not Dr Ben. Just a So this is a penned mode. So you make sure that you do that suddenly. So we're open this in read mode. Now we can say for line in file, Reda. So we could just put far reader dot reid and that that outputs it nicely using a four leap prints out line by line, which I think is a bit nicer. So only four line in far reader. And remember this could be anything to make it readable, have put line. But just to show you it can be anything for I am far. Read a print I, as you can see, it prints off each line one by one and then the end. We just do photo place, case that's reading and writing files. Next, we moved on to sets and two bulls so sets trying to find yourself now before I go into it. Basically, sets are a collection of only unique items. So if we had a list comprising of numbers and some were repeated, then all that would happen is that if we this is just a standard list put into the very will be and then we're going to turn be into a set. Then, as you can see, it's only the unique values have been returned, so we can. Then let's put this in variable. See, we can look basically at the number of unique items we have here by just putting Len, which stands for length of C, and that'll tell us how many unique values we have in the in the list B. Okay, so now let's look at two pools so The important thing about two boards is that they are immutable, which means nothing within them could be changed. So we just put up equals and then it brackets Well, 3 to 5 get in list. We went over in the tutorial that you can change them. So be zero is currently number one. We can change it by just putting B zero equals 255 for example. Now, if we look at be overruled, you'll see Oops, my bad from this from this. Okay, you can see now if we just print be as to 55 as its first index, which is cool in two pools, that cannot be done. So this is our chief. This are to pool. And if we put people in Syria, that's one of the moments now that's trying reassign its to 55 I didn't see it saying Hell , no. The to pull cannot support eyes assignment. You can't change the number basically so moving on to dictionaries now. So with dictionaries, essentially, you have key key value pass. So you use the curly brackets for this and you give you give each of each sets a value. So you give it a key and then you with a code on you, assign it the body. So that's pretty early on. Say, let's say, uh, John four. So let's say this is the under their current balance. Let's say you see three. Of course, This is, uh, millions. Simon Simon is a rich man, So here we go. We have three different pass here and say, if we want to find out any of these, we basically just puts Let's give this dictionary very well day. So if we have to put just d zero like an index, it's not gonna work because we don't do it by indexes. Here we do it by keys. So we put d square brackets John, No output four Lucy, etcetera. We can always change the values. So Lucy has just become a gazillionaire. So good for now, if we were to print off de again, you see, Lucy is a gives it enough. Okay, so going onto Lambda Lambda is just like a functions bike were doing before with the F, except these are kind of used you. You do them in one line, which is really useful. So the important thing is that they're easy to do, but they're very yet ready. Used Any time you use them really is when you want to do a one off function. So the way that you do that did you put Lambda and then, for example, of a placeholder like X nexus per prints you London? So you're basically saying, do a function as we've seen with Thunder X is the placeholder and then do something with X and then straight after it. You put what you want extra B. There you go so that we can change this and it's good change. Say, essentially, put lambda placeholder what you quote on what you don't want to do with the place order. And then you can put what you want to put into place artistry after so now moving on to map and filter. So I recommend for mapping filter because he's a very useful things toe to know about Bulls lecture here, see if you can fill this in yourself. Site map. Basically, it takes a function and it irritable, irritable it a rebel. So on it and it it runs the function on every element in an irritable. So let's start with the function Leper. This is quote that good. That's X here, and we won't do. Each time is the X. That's the power 19. I put spaces. That s so let's the print 2 19 x x to the power of these two aspects is because if you do want districts as multiplication, if you need to exes, that's doing to the power off. So that is a function that's having miserable cooled mapper list because 13 whatever numbers you want, then after that, we can just put, uh, we want to create a list. A nudist we're mapping. They were doing function two member list. Let's put that into a new variable cool new list and they we have some lovely, long, weird numbers. So if we look on your list some reason it's saying no, Which is quite strange, of course, because basically we are putting print, whereas we want to put. So that's an important thing to come up. Actually, printing let you just print something out. If you want the output to be used in some way, then you need to do the return function now, looking at generators where we can use a very basic function for creating generating are in it. Trebles. So for I in range next yields. So we're using this queue at the yield now have created our function. We can now use another four leap. Generate a lot of numbers from this. So let's say for K in, uh, food. Okay. Food, for example. 10. Sorry, Brent. Okay, then. This is basically gonna it straight through this function. Give us a nice list off numbers going up to nine. Okay. Going on to decorators. We can no cool functions within functions. So let's go for deaf food again. We have a function being input as a parameter print. Who and then we can dio call this function where has been put in there. So now we have the opportunity to create another function which will be called within this function so deaf to for example, print, This is food two. Let's go. Another function Deaf food three print. This is Food three. Okay, so now we could cool either these food two or 33 from within food so we can call food within this week. It puts Fouty when we don't need to put brackets here because in the function. It's already being cooled with the brackets. So skipping ahead of you, then this is for you to. And then I could change it to 33 and they'll come out output with 33 So that's decorators occur. Gin is where you're calling a function within a functions again. Except you could do, for example, food X No weaken, say print. Exe um X is for months X to make it look real pretty. And then we can call the function again except X minus one this time. So if we call feet and we start with nine, it's going to slowly go down and forever something to cancel that very quickly because I forgot that we could easily go into negative numbers. As you can see, it just kept on going until I can tell it by doing control. See, so moving on to classes now always that the ends. If you've been following this along without any pauses, my hat's off to you. Eso classes is creating blueprints now so we can create any class by first putting in class and then me to give it a name that say, for example, we're creating blueprints for animals class animal. The first thing we want to do is put death underscore, underscore in it. And then we put itself then the other promises we want for the blueprint of the animals. So we put size, um, noise. Come on. And then within this function, we debate. It's a self dot size because spies self put noise because noise, self doubts, color he calls color. And then we can have another function within here. So his best but deaf. Um, let's birth death, um, deaf jump and then within princesses born itself. They just print the animal has jumped. That has jumped. No, my most creative Right now. It's not my most award winning line. Arcade benefits. So we've got a class here, and then what we can do with this class? We can then create animals, so I'm gonna create a snake. So but slake equals as a variable. Ah, best to keep that lower case. And in life there's cool the class by pitting the name of the class. And then I need to input its size. Its noises cover, so I only have 10 hiss, but I'm just gonna put in those to see what happens. As you can see, there's narrow because I haven't been all the different parameters. You always have to put in all the parameters. So this one's gonna be green. Then this. Create a dog on a more 20 work and then I guess my stocks have around So we get enough. They click. It's now we've created to animals and we can get the information any point by simply putting the name of variable and then said asking it to this. Tell us what the size noise or calories. So let's put dog don't noise. No, Tell us its bark. Okay, We can also call the function for with it from within its class by pitching dog jump with parentheses on this one and then it does whatever it should do within the function. OK, moving on to inheritance. So we've created this class called Animal. So now what we can do is weaken puts. Let's put death that so Kloss Oops. Lotus class insect and then in parentheses. Some reasons isn't code. Okay, It's been in there close insect class insight and then with parentheses, we put in animals animals. So now the class on the move has been inherited by In Tector. Animal is now a super class. So we could we know no longer need to do this death in it. Okay, We can just put other things like death cruel itself. Here, print the insect. That was cruel. I know I am just coming out with the best functions today, so no, I can create an intact so I could put ladybug with the case equals insect. And I could put in these parameters again. That's but one. What was the ladybug noise? Make burn. And then it's red on black. Okay, So even though within this class we haven't put anything to do with these parameters because we've put animal here were saying Insect is going to inherit from animal we can no Chris Ladybug. Now let's see what happens if we try and cool some of these functions first. Well, let's see what happens if we try to call ladybug. Don't jump. See, it works just fine because it's inherited everything from animal. And of course, it should do if we're very lucky into this court. Of course, by that has nothing to do with luck. It's about good programming now, However, if we try to do Dog dog crew. It's not gonna work because dog has no inherited or has not been called within the class. Insect has nothing to do this this function whatsoever. It's purely within class. Animal A Kentucky. So if you've made it all the way through this really well done We have gone over a lot in less than an hour, which I'm very happy with. ESO. Yeah, hopefully this has been a help for refresher. If you feel like there's anything missing from this at this point, we have any questions. Feel free to leave a comment in this lecture, so otherwise I would see in the next lecture. 47. How to continue improving: by now, you should have a solid grasp of the foundational concepts of python. We've even gone into some of the more intermediate concepts, and hopefully you having a good play with them. It's really important, just like, as I said at the start of the course, to keep things practical and creative. So all these different things you've learned, I highly recommend you try just to create one program every day that you think might be interesting. It might be a problem that you're considering could be solved using python, whether you get it done or not. Even if you come up with loads of different errors, you will really help you on your learning journey. If you're feeling ambitious, you could set a target for creating a larger project. Maybe it's involved some concepts that you don't yet know what how to do it. Python is a very versatile programming language. It could be used in such a wide range of things, and it has a great deal of modules and frameworks that you can integrate to solve an incredible range of problems. So if you start setting yourself these higher targets, you end up learning how to use these different parts of python as you go along. Most of all, stay active and curious. I'm creating a range of different courses that will supplement this one. So I recommend you check them out. But there's a great deal of other on. My resource is that I've posted on the course I recommend you take a look at as well. 48. Any questions: thank you for taking part in the ultimate python masterclass. I sincerely enjoyed providing this course. I'm sure you have a lot of questions. I'm very keen to hear what they are. So, in this lecture, please do leave a comment with what things you want to learn next. And maybe we can help you to find the next steps to help you to grow into an intermediate python programmer on beyond. If you haven't yet rated the course, I'd really appreciate if you took a few seconds just to let me know what you thought of the course. It will mean a lot. And it also helps future students to see what the courses like on the inside again. Thank you for protest again. Thank you for participating in this course has been a rule pressure providing it on. I'll be creating a number of related courses in the future, So keep your eyes peeled on. I hope to see in a future course