Python for Everybody | Kalob Taulien | Skillshare
Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
91 Lessons (9h 23m)
    • 1. Course Introduction

      2:58
    • 2. Python 2 vs Python 3

      2:00
    • 3. Where is python used these days?

      6:32
    • 4. (Windows Only) Installing Python

      4:23
    • 5. Installing Python

      1:57
    • 6. (Windows Only) Command Line Crash Course

      4:03
    • 7. Command Line Crash Course

      5:40
    • 8. Running Python Code

      5:45
    • 9. (Windows Only) Jupyter Notebooks

      3:54
    • 10. Jupyter Notebooks

      7:26
    • 11. Where to Download the Code

      1:36
    • 12. Asking Great Questions

      2:30
    • 13. Taking Notes Beside Code

      4:20
    • 14. Basic Arithmetic

      3:25
    • 15. Variables

      6:03
    • 16. Formatting in Python

      6:23
    • 17. Python Data Types

      9:56
    • 18. Mutable Vs Immutable

      8:58
    • 19. Numbers

      4:47
    • 20. Strings (Sequences)

      8:27
    • 21. Lists (Sequences)

      4:26
    • 22. Indexing And Slicing

      6:42
    • 23. String Properties And Methods

      8:46
    • 24. User Input

      3:58
    • 25. Print Formatting

      6:26
    • 26. Lists

      10:07
    • 27. Dictionaries

      13:13
    • 28. Tuples

      5:56
    • 29. Sets

      6:59
    • 30. Booleans

      4:39
    • 31. None

      3:58
    • 32. Files

      11:32
    • 33. Your First Python Program

      8:55
    • 34. Comparison Operators

      9:21
    • 35. Comparison Shortcuts

      8:23
    • 36. Multiple Comparison Operators

      7:30
    • 37. Chaining Operators Together

      6:40
    • 38. Introduction to Loops

      3:08
    • 39. For Loops

      8:11
    • 40. Looping Through Dictionaries

      5:03
    • 41. While Loops

      3:11
    • 42. Break And Continue

      5:21
    • 43. Type Casting

      9:32
    • 44. Helpful Operators

      10:07
    • 45. List Comprehensions

      9:06
    • 46. Dictionary Comprehensions

      4:01
    • 47. Functions

      16:25
    • 48. Args And Kwargs

      8:14
    • 49. Comments

      6:46
    • 50. Map

      11:38
    • 51. Filter

      4:29
    • 52. Lambda Expressions

      3:30
    • 53. Scope

      9:03
    • 54. Welcome to OOP

      12:54
    • 55. Creating Your First Class

      2:28
    • 56. Class Attributes

      5:37
    • 57. Class Methods

      6:21
    • 58. Real Life OOP Example

      5:52
    • 59. Class Inheritance

      7:07
    • 60. Class Interfaces

      5:28
    • 61. Super Function

      4:53
    • 62. Dunder Methods

      7:04
    • 63. Introduction to Packages

      2:39
    • 64. Installing 3rd Party Packages

      4:19
    • 65. Finding 3rd Party Packages

      3:28
    • 66. Seeing Installed Packages

      2:47
    • 67. Introduction to Modules

      3:43
    • 68. Creating a Package

      8:04
    • 69. Name and Main

      7:19
    • 70. Errors and Exceptions

      6:14
    • 71. Catching Exceptions

      12:19
    • 72. Unit Tests

      12:10
    • 73. Nested Functions

      7:13
    • 74. Decorators

      8:22
    • 75. Generators

      14:41
    • 76. Linting

      7:38
    • 77. Virtual Environments

      13:24
    • 78. Requirement Files

      3:51
    • 79. Interactive Python

      3:13
    • 80. Python Versions

      5:34
    • 81. Local Server

      4:02
    • 82. Project: Demonstration

      0:51
    • 83. Project: Python Environment

      1:53
    • 84. Project: Required Packages

      1:53
    • 85. Project: Custom Machine Learning Model

      1:57
    • 86. Project: The Code

      4:28
    • 87. Project: First Detection

      5:11
    • 88. Project: Second Detection

      2:27
    • 89. Project: Confidence Matters

      4:34
    • 90. Project: How to Learn More

      1:34
    • 91. Summary

      3:13
17 students are watching this class

About This Class

Welcome to Python for Everybody, the complete Python course for beginners, intermediate and advanced developers. 

Python is the #3 most popular programming language on Earth. There's no software that Python isn't involved in. Whether you want to get into Data Science, Machine Learning, Artificial Intelligence, Web Development, Video Games or anything else, Python is the language you'll want to learn. This course is designed to set you up for success in every Python-related industry.

If you are new to programming, Python is the perfect language to learn first. It's easy to read and write and the learning curve is very low making it the ideal first-language to learn. 

If you're coming in from another language such as C or Java, you'll pick up on Python even easier! Python takes care of all the little things behind the scenes so you can focus on writing clean code that performs well. 

In this course we'll learn about variables, data structures, conditionals, loops, functions, Object Oriented Programming (OOP), classes, interfaces, the Python 3rd party package ecosystem, virtual environments, decorators, generators, try and except, and unit testing your code. Plus everything between the major learning points. 

This course comes with interactive coding notebooks so you can test out every piece of code I write in this course, you can edit it and experiment safely, and take notes beside your interactive code. It's the perfect way to learn! 

Transcripts

1. Course Introduction: welcome to Python for everybody on skill share. This course is designed to take you from zero to hero in Python. I've designed this course to be your best resource for learning python, So why should you learn python? Well, Python is one of the fastest growing programming languages on the planet. It is currently the third most popular programming language in the entire world, and it is used in every corner of software such as Web development, machine learning, artificial intelligence, data, science, machine vision like self driving cars, your everyday computer programs, video games and much more. Python can help you build anything you can think of. It's easy to learn and incredibly powerful. That's why so many universities are teaching python these days. Now who is this course for things? Courses designed for people who are brand new to programming Python for everybody is good for programmers coming in from another language. And this course is also approachable for people who already know basic python but wants a level of their skills with more advanced topics in this course. Now you might be thinking, What is this course like in this course, I will show you how to set a python and a coding environment on Windows, Mac OS and Linux. Then we'll step through the basics of python like formatting or code simple arithmetic and working with computer logic. Then, as you continue to a level up, you will learn everything from beginner python toe advanced python that you won't find in many other courses, such as object oriented programming, decorators, generators, unit testing and more. Through this course, you will have interactive notebooks to experiment with and to test your understanding. I will also provide you with detailed notebooks for your reference. And these notebooks are unique because you can write your notes alongside fully functional code there over 70 super high quality lectures and interactive notebooks and python for everybody. And you will also learn python best practices. And by the end of this course, you'll be confident enough to put Pike on on your resume. Now, when you enroll in this course, you will also get access to a huge community of programmers alongside riel. Question and answers, and you get to ask me the teacher questions at any given time, and I will answer every single one of them as a thank you for trying of this course. You can even keep all the interactive notes for more details about this course. You could further explore this landing page, read the full description and view the entire course curriculum. So what are you waiting for? It's time to start programming enrolled today and let's get started. 2. Python 2 vs Python 3: Let's take a quick look at the difference between Python to and python three. So in this course, we're actually not going to be learning about Python to whatsoever. Python to is completely outdated. Actually, as of January 1st 2020 Python to is outdated, and it is no longer receiving security updates whatsoever. So if you have, by any chance a program that's using Python to instead of Python three please up, created as it is now a security risk. And once again we're just not going to be using Python to it all because it is outdated, it's not supported. Nobody's supposed to be using it anymore at all. Anyways, eso in this course, we're going to be learning Python three. And to be more specific, we're going to be learning about Python 3.63 point 73.8. So newer versions of Python Python three right now is the current future, which is a weird thing to say. It's the current future. Eventually, I'm sure Python four will be the actual future, but just once again, we're not using python to whatsoever. And if you are enrolled in another course that is using python to. You don't have to pay attention to any of that stuff because most of Python three is very similar to Python to behind the scenes. There's some differences, but for the most part you're not really going to see too many differences now if in the future you're ever Googling a problem and you see this print statement where just as print and then space and quotations that is Python two. That is how you immediately tell that someone is writing Python to were not Python three. Python three looks like this print statement where there is print a bracket and then quotations and then some text inside of it. It has the brackets, so just a side by side comparison here, we've got python to print statement python three print statement, and that is the quickest way to identify if someone is writing python to or python three. There are some syntactical differences in python to versus python three, such as using brackets or no brackets for the print statement, but for the most part it is very, very similar. So when you learn Python three, you are learning about 95% of python to as well 3. Where is python used these days?: Let's take a look at a few places that you can use Python. It's actually not a few places because Python is actually so popular. It is deeply embedded in every single corner of software these days. And as of recording, this Python is actually the third most popular programming language in the world. And I'm just loading up a website here that says, Ah, up, up up of, Ah, the Tai O. B. I don't know how to say that index for April 2020 and we can see some growth here. So last year, Python was number four. This year it is number three, and it's ratings are 9.31 It's change. It's gone up by 1.15% which doesn't seem like a lot. But look at Ruby. Ruby went down by 0.2 Go went up by 0.35% and even JavaScript JavaScript is a really hot language. But year over year, it doesn't seem to be growing so far, not over. Not between 20 19 and 2020. Javascript is still the seventh most popular language in the world, which is huge. It is a very very popular programming language, but Python is number three. It is significantly more popular. So just as an example, a few places that you can use python and again these are just a few places. But let's start off with some of the cooler stuff, right. Python is used in machine learning. Python is used in artificial intelligence. Universities are all teaching python these days because it is simple, like it's easy to learn. It doesn't come with all sorts of like crazy things to look at. Its just. You can read it like a book, but it's also super super powerful, so it's simple and powerful. That's why universities are teaching at these days. You can also use it in data science. Raspberry PiS. You can use it in things like automation and robots. You can use python for things like image detection and machine vision. So, like self driving cars, for instance, which is absolutely the future. But also you can use it in things like Web development or small little programs or Web scraping programs or automating anything in your house literally anything to do with software. You can use python now. One other thing toe really think about here, and I know this is not a big motivator for a lot of people, but it is worth mentioning. Python programmers make more money than most other languages. So, for instance, if you were a Web developer and you already know PHP, while Python developer sent to make 2 to 3 times more money than a PHP developer, Python developers also tend to make 50% up to two times more money than JavaScript developers than front end Web developers. So you can see right away that Python already wins when it comes to economics. Now that number. Actually, it's even higher when we start talking about machine learning, artificial intelligence and data science. So if you have any sort of mathematics background or any sort of interest in machine learning or artificial intelligence or data science, when we talk about annual salaries, we could be looking at 121 151 $180,000 a year. Those air U. S. Dollars and most of that these days is python as well. There's also a ton of different jobs for python, like a lot of different jobs. So as an example, I'll just go into my brows here. Go to indeed dot com, and I'm just going to type in Python. Uh, let's just do a regular one. You're something they suggest. Let's do you have a python developer? Find a job? Okay, there are 25 a half 1000 jobs in the United States for a generic python developer right now , that's very impressive, because as of recording this last week, the United States had a record 6.6 million people file for unemployment. And that's because again, as of recording, this is in the middle of the Corona virus pandemic. So people are losing their jobs very quickly, and there are still a ton of python jobs out there. That's crazy. Let's look at remote work because nowadays everyone wants to work from home. I work from home, and it is a fantastic lifestyle. In the US There are 4600 python remote jobs, thes air, just jobs that actually say remote, either in the title or somewhere in the description. There's probably actually way more than that, their entire companies, like get Lab that aren't 100% remote as well, so you can work from home. Let's look at Python Web developments. Look at this one in the U. S. There, almost 16,000 jobs for Python Web development. Now let's look at some of these salary estimates. Al, just zoom in here. Salary estimate. This is for the Python Web developer. Ah, we've got over 2000 jobs here, 20 2700 jobs that are paying over $135,000 a year. The lowest bracket here is $90,000 for 13,000 jobs is not crazy. What about if we just went back to the generic one Python developer, 21,000 jobs paying $90,000? And there are more jobs in your lots of full time jobs and contract jobs. Part time jobs, internships, temporary jobs, commission jobs. I don't actually really know how you do a commission job with software that's interesting but full time contract, part time internship and temporary. There are jobs to fit your needs or whether you just started a family or your sick or you have a disability and you can't go to an office. Python is a programming language that can give you a lot of opportunity in your life. And again, I know that money is not supposed to be the biggest motivator out there. But for most people, making $100,000 a year is a lot of money and attacking provide for you and your family and can provide a lot of comfort in your life. So when people say things like, Hey, Caleb, should I really be learning Python like maybe maybe I should be learning Go or rust or something else. My answer is, yeah, you should be learning Python first. It is easy to learn. It is powerful. It pays well. It is a great entry language into programming. You can literally do anything with it. So my answer is Yes, yes, yes, A 1,000,000 times, Yes, learn python. There's so much opportunity out there for it. Stick with it and you will break into the industry. I can guarantee you that 4. (Windows Only) Installing Python: Hello, Windows User, If you are not using a Windows computer, then this video is not for you. However, if you are one of the people in the world who are using Windows, which is a lot of people like 60% of the world uses windows or something like that. You might be interested in learning how to install python on Windows. I'm using Windows 10 and also installing Anaconda along with how to run some python commands. So I just thought I would make a proper support video specifically for Windows users. So first things first we need to download Python. And so I'm gonna open up whichever browser, and I'm gonna go to python dot or go. I guess we can make this, you know, touch bigger and let's head on over to downloads. And now it's gonna automatically suggest which version to download for me. So I'm gonna download Python 3.8 point two and I can save it and I can run it. And all sorts of stuff obviously take security measures into account here. I'm just going to run this because I already have anti virus and all that stuff running on here If you don't, you may want to look into that just toe, you know, be safe on the Internet. All right, so let's go ahead and install Python. So this just automatically detected 32 bit for me. If you're using a newer computer, definitely get the 64 bit, if that is an option. And also, you're going to want to add that python path in there, so make sure you click this little box. So I'm just going to select the install now. Yes, and the set up is in progress. We'll just wait for it to do its thing here. Okay. Says the you set up was successful. Thank you. Marc Hammond, for all your work. Ah, disabled half length limit. That's usually a good idea. Commit Click that it's gonna ask me. Yep. I'm going to confirm that and clothes. And now Python is installed so I can go in here, and I could just type in command prompt, and you can see it here. And I'm going to run this as an administrator just so that I have proper permissions again . It's gonna ask me Do you want to do this? Yes, I do. And now typically throw the rest this course and throat. Ah, a lot of other videos you'll see on the Internet. You will see people say, Ah, they'll type Python Dash V or dash dash version like this, But that's not going to work for us, not on Windows anyways. We could do Python Dash V that also isn't going to work on Windows and said, What we use is just P Y soapy y Dash V, and it gives us the version that we're using P. Y dash dash version, and that gives us all of our regular python command. So what we can do now is instead of typing python or occasionally python three or python 3.6, and then whatever your version, your command is not your version. But whatever your command is, you just type pie. So if you're running a python file, you would rain. You'd run pie, your file dot pie, and that's it. Now your file DuPuy doesn't exist, so that's not actually going to do anything for us. But moving forward. If you run into a python file, you can always run it with just pie. Also getting into your shell. This is pretty important to know just getting into your python shelters two different ways . You can do this the first ways you can just type pie and hit. Enter and you can quit by hitting or typing. Quit with the parentheses around it. Here, you can go down here and it'll say, recently added, Or if it's not in here, it will be somewhere in here how you can just click Idol and this will spin up python for me. And so this looks a little bit different, but this is just appear Python. So this is not your command line. This is just Pierre Python. And so now I can print Hello World, and it gives me nice little helpful tips like what we saw there. And I can print that in a sign of variable python for everybody. And I can print that out as well. And Willa, And if I want to get out of it, you can just close us as a program, or you can type quit with parentheses and yet cool. So that's how you would download and install python on windows and also how you would run it in your command, prompt and in your python Idol 5. Installing Python: Okay, let's take a look at installing Python. A lot of computers actually already come with Python. If you're on a Mac, it probably already came with Python to maybe a version of Python three. Ah, lot of Windows computers these days come with Python as well. Lennox probably already has Python, but let's not. Let's not make any assumptions here. So what I want you to do is open up your browser and go to python dot org's and you see this website that looks like it hasn't changed since 1998 and let's go to downloads. And the latest version, and this has detected that I'm already on a Mac computer is 3.8 point two. So is going to suggest that I download this. You could download the suggested version as well for your operating system, or you could scroll down a little bit and you can download a different version so you can see we have all these different versions. There's lots of them in here, so I'm going to highly recommend that you download either python 3.7 or 3.8 or if you're watching this a little bit after recording of this course and python 3.9 to 3.10 is out. Download the latest version, so I'm gonna suggest getting Python 3.8 point two right now. And if you click this, it's actually to bring me down to a page. Will bring you down to a page, I guess to, and you have to scroll down to the bottom. And if you're on Windows, you'll probably want these 64 bit execute herbal installer. That's going to be the easiest way to install Python on Windows. If you're on Mac, you probably want to the Mac OS 64 bit installer. That's probably going to be the easiest way. And if you are on some sort of UNIX type system, also known as Lennox Ah, you could download or curl the source Tar ball or the G zipped source. Tar ball un compress it and install it. So once you have python downloaded and installed, you need both of them. Download and install it. Then let's head onto that next lesson. But don't move onto the next lesson until you absolutely have python downloaded and installed 6. (Windows Only) Command Line Crash Course: Okay, let's do a quick little crash course. A command line. Crash course, four windows. So throughout this course and through a lot of other videos on the Internet, you're going to see a lot of UNIX like commands. So commands like ls or ls Dash L. A. And that clearly is not going to work in our command, prompt. And just to take a quick step back there if you're wondering, OK, love, What is a command prompt Command prompt is when I go down here in type command prompt. You can run this as an administrator. It might ask you. Are you sure? You say yes. You click the yes button, and it will bring you to something like this. So if you want to see everything that's in a folder instead of L s Dash L. A. Which is what you'll often see on the Internet, you can write de ir dirt, and this will show you everything inside of a directory. And look at all that. I have a lot of things inside of this directory. Now, which directory on my own? I am on. See Dr Windows System 32. How to change your directory you can type CD to change your directory. Dot dot dash will move you up one director, and you can actually see that is changing here. I could do that again. CD dot dot dash goes up a directory and I can do D IRC What's in here About a few things, but I will usually want to go to the users because that's usually where you're going to be working out of is your user profile. So you do CD users and then I can do. I eat during here and I have a user called Caleb and a directory called Public. So a directory called Killed in Public. So that's CD Caleb, and this is likely going to say whatever your name is on Windows ER, and I can see all sorts of files in here. Now let's say you wanted a folder just for your projects. You could make a directory so NK and then directory D i R. And then you could call it like your projects. If I do D r D I r. You'll see the full during year called your projects. So now I can go in there CD your projects change directory into your projects de ir. You'll see there's nothing in here zero bytes and I can create a new python filing here if I wanted to. Now I'm also inside of my profile at this point. So if you're using Thea's code or pie charm or some sort of text editor, you can put all of your files in here and you'll be able to see them as well. And just, for instance, I created a folder called Your Projects Inside of My Accounts. Let's go explore that. Let's go to my documents and that's kind of cool. I did not realize that would be there, but there's Python scripts already in there. Let's go, Teoh pc See Dr Users. And this is just matching this location down here. It's gonna go into Caleb and I'll have a folder there. It is your projects. And then you could create a new filing here. You could open up your text editor, your code editor. You could create a new project, and here you do all sorts of stuff in here. But the main thing to know at this point is really you need to know. How do you change directories? Go up a level you need to be able to go into a directory. So it's just like CD. Whatever your folder is called, you need to know what is in your directory or in your folder with de IR there just like that. And then, lastly, you need to be able to run your python files, and running your python files is as easy as P y and then your file dot pie. So your file dot pie, assuming your file dot pie actually exists. Last but not least, you might want to get into your python shell your python idol. All you have to do is type P Y, and you can write all of your own python in here as well. If you ever get stuck in here and you want to get out, you just type. Quit opening and closing parentheses and you will get out of it as well. If at any point in time, you like Oh, no, actually close this. That's not a problem. Let's go back here and find your command prompt. I always like to run this as an administrator. Yep, and we're back to where we usually start off so that is a quick command line crash course on windows. You don't really need to know too much more other than that for the rest of this course. 7. Command Line Crash Course: okey dokey. At this point time. You should have Python installed already, and it's now time for a quick lesson on some command line basics. So if you are on a Mac, there's a program called Terminal and pretty much every Mac comes with this, and you can find it by hitting command space and then just typing terminal dot app or just terminal and then go to terminal app and that will open up your command line program for you. If you're on Windows, you'll probably have a program called Command or Power Shell, where you can download one called Commander cmd er, and that will be a command line program that you use for the rest. Of course, as well. If you're on Lenox, there's a program called Bash, but there's also a ton of other programs other that you can install likewise for Windows and Mac OS as well. So, really, if you don't want to use what's already on your computer and every computer will come with a command line program, you can download and saw a different program. Okay, so I've just zoomed in on my terminal here so you can see what's going on And for a quick little command line crash course, there's a few things you're going to need to know. You need to know how to list files in a directory. So on UNIX based systems, so limits and Mac, you can usually type ls Dash L. A. And it will show you all sorts of things in here. You can see I've already got Ah Fuller called Python for everybody. Uh, where is one that I would want to go into? Let's go into movies. So let's say I can see that there's a folder and they're called movies and I want to get into it. I can type CD and then the name of the folder, and now I am inside of it. And most programs will also tell you which directory urine as well. Ah, directory is a folder, by the way. If you did not know that now, just going back a quick sec I did the example of ls Dash L. A. If you were on Windows, your command is going to be different. It's going to be D I r dir and dear will show you all of your files and folders the same way that ls Dash L. A. Does for me. So let's CD into a directory called movies. That's just change directory. You can use this on all operating systems. A CD just means change directories. PWD will show you exactly what directory you're in. So I'm in the user's directory. Caleb Tallinn movies. If you're on Windows, this is going to look a little different. This also say something like, uh, See, Dr, I remember exactly where it is. Users. I would be Caleb Colleen movies something along those lines. Anyways, that's what you'll see on Windows and on Lennox. That might actually just look like slash home slash Caleb Colleen slash movies. And it was something like that. So that's how you see where you currently are, is pwd. Now let's say you wanted to make a directory, and this is going to be important eventually down the road. So if I do ls Dash L. A order on Windows. I can see that I have a few files in here. None of them are really important. If I wanted to make a new directory, I could do M Kader that sense for make directory and let's call it a test Dir a last dash L . A or Deron Windows, and you can see that there is a new directory in here and I can change directories into their and do P W. D. Now, if you are in a directory and you want to move out of it, you can always you change. Directory dot, dot, slash and that will move you up a directory. You can do it again. CD dot dot slash moves you up a directory. And if you ever wanted to move into multiple directories, you could do CD movies and then whatever the other directory is. So a sub folder subdirectory. And for a lot of cases, you can just usually type most of the word hit tab, and it will auto complete for you. So seedy Movies Test directory. I moved into two folders at the same time there. Cd dot dot slash dot, dot slash will. Bring me out of test directory out of movies and back into my main location, Which for me, is users slash Caleb telling one last one you're going to need to know is Python Python is a command. Let me clear this out as well. Python is a command you're going to need to run. And it's probably a good idea to try to figure out what version of quite thing you have right now by typing Python Dash Capital V and you can see I'm using Python 3.7 point two. You might be using python 3.73 point 83.9 something newer if you see how do you do? Yeah, if you see Python 2.7 point something, or rather without having to type Python to. If it just shows this in here, when you run this command, that could be a problem. So for me, I just need to type Python and it assumes Python three. If your computer is not assuming Python three, you might have to type Python three Dash V and you can actually see because I'm using multiple versions of Python. If I use Python three instead of just the word, Python uses Python 3.8, and again, that's just because I have multiple versions of Python on my computer. There's also another way. If you have Python 3.7, you could do Python 3.7 Dash V, and we'll show you and I don't even know if I have Python 3.6 on here anymore. Turns out I don't, but I could insult with Pie N. That's something we can talk about. Down the road is multiple versions, but the thing to take away here is if Python Dash V says Python to point something, rather, you might want to try Python three Dash V and moving forward. You're going to want to use Python three, your file dot pie. We'll talk about that again in the future lesson, but that's just something to be aware of on the command line as well. 8. Running Python Code: There are lots of different ways to run your python code, but when you get into an actual job, you're going to be using your command line more than anything else. And so in this course, we're actually going to look over two different ways. We're going toe, go over rather two different ways of running your python code. The 1st 1 is the command line, which I really want you to get familiar with just at the very beginning. And the second way is using a Jupiter notebook, which will cover in a different lesson. But for now, what I would like you to do is open up your terminal or your command line program. For me, it's called Terminal. If you're in Windows, that's probably command commander or power shell. And if you are on Lenox, it's probably like Bash or some custom terminal that you've downloaded on your own. And let's go ahead and take Python Dash V, and that's going to show us the current version of Python we're working with. We can also take which python, and it will show us exactly where the Python program is being called upon. Now that's actually not super important mines going to say pie end of shims because I'm using pi N viewers might say something totally different, but regardless, it will say something that's not actually writing any python code. That's actually just figuring out where Python is insult on her computer and showing us the version to get into Python R Python Shell, where we can actually write python. Just type the word python and hit Enter. And here we can see that I'm using Python 3.7 point two. I think this is when I set the default. I'm not entirely sure why that is so far behind to be totally hottest. Ah, but there there's a little helping here as well. Eso type, help copyright credits or license for more information. Let's type help. Okay, type help parentheses for interactive help or help object for help about objects. We don't know about objects yet, so let's just keep this imbalance type help with parentheses, and it gives us a bunch of information in here. This is kind of cool. Welcome to Python 3.7 help utility to get a list of available modules, keywords, symbols, topics, type modules, keyword symbols and topics Let's type modules. Now. We aren't going to learn what all these are right away. This is just sort of exploring the command line a little bit. And so that showed me some stuff. That's kind of cool, but I want to get out of here. So let's type quit did nothing. Or so it seems it did nothing. What actually did was get rid of the help tool that we were inside of, So we were technically inside of a program in our command line. Now, help is a super useful function when you're just learning python. But to be totally honest, it is not Superfund. I can't run clear because I'm not actually on my command line. I'm actually inside of Python, so I'm gonna clear up some of this stuff. And to write your first Python script is incredibly simple. So type of the word print with the parentheses and opening parentheses, use a quotation mark and say Hello. World ended with another quotation marks. We've got an opening one right here, and we have Sorry, we haven't opening one right here and we have a closing one over here. Same thing with parentheses. We have one here and we have one here. Go ahead. Hit. Enter says, Hello world. And just like that, if you have followed that along on your computer, you have actually written python. It's literally that easy. So right now we're inside of our python interactive shell. We can do all sorts of python stuff in here, and we're going to be using this and Jupiter notebook throughout the rest. Of course, as well. Now, to get rid of this to get outside of this because currently were stuck in like a python program, just type. Quit with opening and closing parentheses and you'll get outside of your python program. And to get back in simply, just type python quit. And if you are one of the unlucky people who has a type Python three in order to see the Python three program actually execute on your computer, you simply just type Python three and that will go into your python three showing you can actually see for me that changed my version of python as well to python 3.8 and same thing quit. Now, last thing to note is, python files are usually stored in some sort of python file dot pie file the dot pies The extension here, that's the important part. And to run your Python file is simply just running python and then the file name. And so this is getting into command line stuff again because this is the program you want to call, and this is the first argument you're saying, Hey, run Python. But don't just give me the show. Actually run This file knows file doesn't exist. We'll get into that a little bit later, but that is how you would run a python file one last thing to keep in mind again. We'll talk about this much more. Down the road is python is case sensitive, and it's also indentation sensitive, so we don't use things like curly braces like you see in JavaScript or PHP or in a lot of different languages. We don't really use curly braces too much in python and said, we use indentation, makes her code nice and easy to read makes it nice and easy to debug. And honestly, a lot of people really love the fact that it uses indentation rather than curly braces. I love it. I thought it was weird at first but I actually love it now, and it is so much better than right and curly braces everywhere. So what I would like you to do is open up your command line program tape and python type in print. Hello, world. Just like I did hit, Enter and you'll see. Hello World, then quit. Once you've done that, you've successfully written in Python and it is time to move on to the next lesson. 9. (Windows Only) Jupyter Notebooks: Let's go ahead and download Anaconda so we can run Jupiter notebooks. So what we need to do is go to Anna Conda. I think it's dot com. Let's not risk that. And a condom Python and Google will know or being, because Windows that makes sense does anaconda dot com. So we want to go into products and let's go into our individual edition here. And let's just get rid of that and make her pages the touch smaller here. And so really, all we want to do is just download this. And for this one, I'm going to download the 64 bit graphical installer using Python 3.7. So so again, you can save this scanning for viruses and just run it. Okay, honest Anaconda is up and running. I'm going to install it now. Agree? Just me. Sure ill and sell it into my account. Now, if you want to use Anaconda, you can you can say register. Anaconda three is my default Python three. Now I've already installed Python I using python 3.8, so I want to use that. But if you just want to use python this way, that's totally cool too. Something a go through here is going to install. Okay, so for me, that took, like, five minutes. That was very of long set up. Ah, but it is finally done. Click next. You want to get a python specific editor called Pie Charm? You totally can. I don't. I use V s code because I'm a little more full stack. And I liked rice. JavaScript, html CSS, SQL, Django. All sorts of stuff. All right, now that that is installed, we can go into our Anaconda three folder here and go to Anaconda Navigator. That's the one we want is the navigator. So this is asking if I want to help Anaconda improve. I currently don't, but you might want to. Okay. And don't show again and let's go back to our program back here and we can see all sorts of stuff now your screens probably going to be a little bit bigger than mine. But you're going to see all sorts of stuff in here, and the one we're going to be using for the most part, is going to be notebook. She's going to want to click launch on that now. What's really cool about this is You can run python right in your browser. So I just ran this from Ah, standard folder and you can traversed through your folders and creates new python files anywhere you like. So, for instance, if I wanted to go to my desktop and create a new python filing here, I could I would just go over here New Python three. And now you and I are using Jupiter notebook on Windows and we can check that this is going to work by typing something like Print Hello world. And then you can just run yourself and it says, Hello world. Once you have that up and running, you successfully are using python with Jupiter as well. We can also check to see what version of Python were using by executing the command line command with an exclamation mark P Y dash dash version. And what this does is says, Hey, actually, get out of Python for a quick second. Just run this on the command line Run P Y dash dash version, and this will do Python 3.8 point two for us. That's how I know what version of python amusing at any point in time. You can always save your file. You can rename your file. You can do all sorts of stuff. If you ever wanted to, you could just totally killed this, Colonel. So what, you're running in this particular window is called a colonel and shut down our Colonel. All we have to do is shut down. Yep. Shut it down. And now we can see there's no colonel in here, But if we go back to this tab, we have a new file called untitled dot i p Y N b. So that's all there is to installing Anaconda and Jupiter notebook. 10. Jupyter Notebooks: there's another way to run your python code. You don't have to do it through a command line, although I like the command line just because I've been exposed to it for so long. But if your brand new the command line, can be very overwhelming, another way is to use this thing called a Jupiter notebook. Jupiter dot or guy believe, is the website J u P Y T e r. And if we just click on install, there are a few different ways to install Jupiter notebook. So if you're already familiar with some python, you have a little bit of background. With python, you can just simply do Pip install Jupiter Lab or Pip Install notebook. Now, chances are you probably don't have that kind of experience right now, and that's okay. If you don't, you can go to ah, Anaconda. I don't actually remember what this website is. I think it's anaconda dot com. Yes, anaconda dot com. So Anaconda is a python distribution. It also comes with a lot of different tools. So if we click on download you can download four Windows Mac and Linux. It will install python for you. It will also install a bunch of other things for you as well, including a Jupiter notebook. So just scroll on down. Click python 3.7, or if 3.8 or 3.9 is out, Go ahead, click that, download it and install it. Okay, So I'm just booting up Anaconda here, and you're going to see once this loads it comes with a bunch of stuff. It comes with things like V s code, our studio and Jupiter notebook. This is the one we want. I'm gonna click launch here and that spun up my terminal and is going to run the command line command from Terminal. And here we have Jupiter Notebook. Yes, is probably be pretty hard to see on a smaller videos. Let me zoom in here. A Jupiter notebook is basically an interactive way to go through different files and create these things called interactive python notebooks. No, I have a folder in here called Python for everybody. This is where I'm going to be keeping all of my code now to create a new file. All you have to do is click this new go to Python three. I have Django installed. So it's going to say this. It might not say that for you, Python three and we're going to see this cool little thing. Now, this doesn't look like much to begin with. However, if we run that print statement we saw in the last video Hello world and we hit shift, enter, We can see Hello, world. Now let's just walk through Jupiter notebook a little bit because this is not super intuitive. So let's first turn on our ah toolbar. Here we go. So you can go into a cell here and you can change. This text changed and you can rerun it. You just click run and it will rerun your code for you, which is really nice. You can actually go back and do this over and over and over again. Let's go ahead and turn on our line numbers here. So in this cell, we've got line number one just as print Hello. World changed down the road. You're going to see me? Ah, use something called Mark down and it will just say hello. This is ah title, and there's actually no code to execute its just mark down. So that is a markdown. So usually we're going to stick with regular code cells. There's also a bunch of shortcuts here. Ah, which, if you are a short cut ninja, you probably want to learn most of these because there's some nice shortcuts in here, like how to delete us out, how to move up and down to sell things like that. The most part, we actually don't need to know a lot of that in this course because we're just going to be using these cells to really explore Python. Let's go ahead, change up and rerun it. Now I'm going to save this file and you can save your file as well by going to file. And this is all just done in the browser. So this is not actually in my browsers files settings. This is in what looks like a websites browser settings, so I go to file save As and let's just call this first notebook. Now, I'm actually not going to make this publicly accessible because this one is just going to throw this file way. It's not useful for anything, but this is how you actually save one. So this is the folder that I'm in. I wasn't called first notebook dot i p y and be save. And just like that, it saved it doesn't look like it did anything. And it could change title of it up here if I wanted to. But whenever you see some of my coat and I'll show you where to download all of my code down the road, you want to do file open and then you can open. Let's say first notebook dot i p Y N b and you can see all of my code and execute all of my code as well. Now, last but not least, sometimes you want to run something from the command line. This is not your command line program. This is simply python. This that's all this is. This is a little interactive way of working with python. But if you needed to run something from the command line, you have two options here. You can either open up your terminal. I've got to open one that I'm writing code on and one for Jupiter notebook that runs behind the scenes. Or you gonna type exclamation mark and then whatever your command is going to be, so mind is going to be exclamation Mark Python dash fee. And that's just going to show me the version of Python that I'm currently using and hit, shift, enter and says Python, 3.7 point two Last but not least, there is a way to actually theme this. So if you don't like all the bright colors and and the light grays, you can actually theme this in your command line. You could do Pip install Jupiter themes and then, yeah, see its installing Jupiter themes for me. Okay, Cool. So did a bunch of stuff, and then you could run. I think it's J T Dash T. And then the name of the theme. Something like that. You'll have to look into that on your own because I'm just going to use this standard version just so it keeps it nice and simple and as I don't really want to blow this course with too many things. But I do want to show you that you can change the theme of this so it looks a little nicer . Maybe it looks more like your regular text editor so you can do that as well. I think one of them is actually, uh, more okay, I have no idea how to spell that, right. But you could do something like that. And then you just shut down notebook and start it up again from scratch, and it will look different anyways. That is a Jupiter notebook. In a nutshell. If you want to, you can go ahead and you can explore all the different cells, things that you can do, the commands, your command palette or all your shortcuts. You could search through them. You can create new files. You can cut text. You can move up and down cells and do all sorts of stuff in here. So for the good majority of this course, we're going to be using a Jupiter notebook. And when it comes to learning Python, I would highly recommend downloading Jupiter or Anaconda and using Jupiter notebook. Just that you can learn and tinker with python. You don't have to worry about retyping anything. You can always just come back and you can undo something. Rerun the cell with shift enter. I wanted to get rid of it. Get rid of that one. Get rid of that one. Care to that one. So I just deleted cells using a shortcut. So no big deal and if again, you ever wanted to changed again. If you ever wanted to change something, it will just automatically run for you. It's very, very nice tool toe have you don't have to worry about retyping anything, so definitely, definitely. Get Jupiter notebook. It's completely free, but if you don't want to, you can always just use the standard python interactive shell. 11. Where to Download the Code: all right. Before we get started, let's talk about where you can find this code. So you condone. Download all of the Jupiter notebooks from the resource files on this platform. Now, if you happen to be taking this course on a platform that doesn't have the resource files, you can always go to get hub dot com. And if you look up in the URL here, you'll be able to find exactly where all these files are all the code for all the lessons if there is any coat is all available here on Get Hub for free. You can also download it by either running get clone or or you can download all the files in a big zip and then once you have it downloaded or cloned, you can either extract the files. If you ended up downloading the ZIP, you'll need to extract the files or you'll need to CD into your Newgate project, the one that you just clone down. You need to see the into it with your terminal or your command line program, and then you could run, for example, a python file with Python, my program dot pie or if it's a Jupiter Notebook file. You can open it in your Jupiter notebook as long as it ends in dot high p. Why nb last but not least, you can also view all the interactive python, the Jupiter notebook files here on Get Hub as well. You can just click into one of these and get Hubble show you probably something very similar to what you'll see in the videos. So there are several places that you can download the code. I would highly recommend downloading the code and just taking a look at what I have written and feel free to break stuff. And honestly, if you break something or you can't undo something, you can always just re download the code, and that's okay. Once you have the code on your computer, let's head on over to that next lesson. 12. Asking Great Questions: Hello and welcome to Python for everybody. First and foremost, Thank you for taking my course. I appreciate that there are other Python courses out there, and you've decided to take a chance on my course, and I just want to say I appreciate that. With that said, I have a couple of rules that can help you ask questions better. And the reason I'm bringing this up is because if you ask a question, I want to give you a good answer in a timely manner. So the first rule is, Please write your questions clearly, so ask what your question is. But if if it's about a certain problem, make sure you describe what that problem is or if it's about a certain piece of code, make sure you reference what that certain code is. The second rule is, if you are going to share code, please make sure that the code is formatted. If you formatted, then I can simply copy and paste it into my command line or into a python file, and I can run it very, very quickly and get you an answer very, very quickly. You can use a service like paste bin or if the comments down below allow you to you can also use code formatting in there, the third room that I would like to put out there. It's actually not really a rule. It's more of a guideline, but the 3rd 1 is always provide your version of Python python. Every new version of Python comes with new features, and so if you're trying to use a feature on an older version of python, it helps me to know which version you're using. And if you don't know, you can always open up your command line and you can type Python Dash V, and it will tell you something like 3.7 point two. So if you could please provide your version of python as well, that just helps me with debugging a little faster. And last, but not least, if you're asking a question about a particular video or something you saw in a video, if you could please tell me which video you're referencing and which time you're referring to In that video, I have a few videos that are upwards to 15 minutes long, So if you're talking about a particular video like introduction to classes, and it's like four minutes and 15 seconds in. Just let me know that it's in the classes video and it's four minutes and 15 seconds in. That helps me jump to that video, and I could see exactly what you're talking about. I have over 1500 videos made, I think now in my teaching career, and so it's it's actually really hard for me to keep track of all of these. So if you could just sort of help me out with that, that will help me provide a good answer to you in a timely manner, which is what I aim to do. I want to help you learn python effectively and efficiently. And this is going to help me do that. Thank you so much. And I look forward to helping you learn python. 13. Taking Notes Beside Code: through this course, you're going to see me taking some notes and I'll leave like little titles and stuff in here and in the final notebooks. You're going to see a lot more organized code, and you can do the same thing that I dio. So when you were in a cell like this, all you have to do is come up here and switch it from code to mark down or even a heading. And in this case, Jupiter, saying Jupiter no longer uses special heading cells and said, You use marked down now, if you're familiar with, get at all or get Hub read me. Files are marked down files and in a markdown file, you can have headers. We can have smaller headers, and you can actually see that this is getting smaller every time I add or remove one of these, and so markdown is very commonplace. And if you want to take really nice notes, you can Google mark down. It is a very simple language, so one number sign when your cell is marked as mark down will be a large title, and then you can make a new line in here. And if you want to write some of your own code, but it should display his code and not actually activate. As Python, you can use three back ticks and then three back takes at the end. And in here you could say print some code and var is equal to I don't know, python. And then all you have to do is execute this cell. So if you run this cell Mrs now formatted like code, you could always double click in there as well. And if you want to, you could put some warm ipsum in here. And let's say you're talking about some code you can do in line code and you just use one back tick and another back. Take there and let's do one here and one here and this once we run this out, Well, actually, look like it has code formatting. And so in here we could write some python script like print. Welcome to Python for everybody. And we can have this code actually execute. Now. This cell is a code cell and below it we could have some notes if we wanted to. Now, if you see any of my code and you want to write some of your own notes. You can always just click on the cell and go to sell. Uh, not so actually meant insert. You can go to insert cell above or below, so let's go ahead and add a cell below. And let's change that style to a markdown. And in here we can write a note. This is how we write a print statement in Python. And then we could say I e print hello, and that actually didn't break onto two lines because mark down doesn't care for a single line, so you have to write two lines. But it seems you execute that sell. It will put it on a new line for you, just like that. Last but not least, you can also add links as well as pull quotes, so print this is going to be a link see below. So that's some code. And let's go ahead and change this one too mark down. And we could say python for everybody dot com, Or let's just really prove that this is going to be, ah, proper link dot Come. So that's hard brackets that's going to be your text. And then in soft brackets in parentheses. You could put http s python for everybody dot com, and as soon as you run that sell, this becomes a link. I can actually click it, open it in a new tab, and it has my text in there. So that's a link we can also do. Pull quotes, pull quotes and let's go ahead and change is back down to Marc down. And a pull quote starts with a greater than symbol in marked um, not in Python, but in Marked Down I can put some Laura Ipsum text in there. Just 50 words of Lauren Ipsum hit Enter and this looks like a pull quote. It's got a nice little border there. So as you progress through this course and you were looking through the interactive notebooks, don't forget that you can always go ahead. You can insert your own cells. You can delete the cells that I have. You can modify it and really make it your own. You can add all sorts of notes as well, and they don't have to be formatted nicely. They could be in whatever format you like, and that is how we take notes beside interactive python 14. Basic Arithmetic: alrighty. Let's take a look at some basic arithmetic now when I say basic arithmetic all I mean here is math and I don't mean advanced math. It's not algebra, it's not calculus. It's nothing complicated, but we do need to know how we can add, subtract, divide, multiply and will probably even use exponents. Oops and give you a sneak peek there exponents. So in python and in most programming languages, these rules hold true. So when you're trying to add a number, you can add, let's say, 89 plus 11. And that's just simply going to add the number that will give us 100. And likewise, if we wanted to subtract a number, it's the subtract symbol. It's a 100 minus 49 is equal to 51. Dividing is a simple as 100 then you use a slash divided by. Let's divide that by 10 that will give us 10 and if we want to multiply, we could do nine times nine, and to multiply. It's just an asterisk. So it's the little star symbol, and that's how we multiply and exponents air one we're going to be using throughout this course quite frequently and in exponents. In some programming, languages is like three to the power of three. But in python we use two asterisks side by side. So three to the power of three is going to give us 27 3 times, three times 33 times, three times three is what that is. And that is how we do an exponents. And there's one other thing that we're going to look at a little bit down the road, and it's called module. ISS module is, and you know, when you divide a number and you get a remainder, that's what a module is is. So if you divide in 10 by three, you're going to get three with some remainder. So 3.333 now what if you wanted to get that? Remainder is a number, so three goes into 10 3 times 369 and there's a remainder of one. We can do that with the percent symbol. So we take one number and we divided by r No, no, not divided by we module iss it by a second number and hit enter and we get one. So what that means is three goes into 10 3 times 369 and then 10 minus nine is going to be one, and that's your remainder. Beyond that, we're actually not going to be doing too much arithmetic in this course. And, believe it or not, there's actually not a lot of mathematics in most programming these days. There is mathematics if you get into data science or if you want to get into. Even some forms of machine learning has some math, but for the most part, programming does not have a lot of math. And so, by no means do you need to be a mathematician in order to learn how to program. People always think that, Oh, because you're a programmer, you must be good at math, but that's simply does not have to be true. So that is basic arithmetic, we add with a plus symbol, we subtract with the dash or the minus symbol. We divide with a slash. We multiply with an asterisk or the star we exponents with two stars, and this is just multiplying three numbers together and we module IHS or get the remainder with a percent symbol 15. Variables: Okay, Dokey. Now we can actually start getting into learning python properly. So a little while ago, what we did Ah, we had this thing called a print statement or a print function and we said, Hello, world hit shift Enter And it says Hello world. And that is essentially all it takes to run a python program. But there are these things called variables and what I'm going to do. Just delete that and a variable is really just a way to assign some sort of name to have some sort of value. So let's not do name, Let's do course. That's a variable name is equal to, and we see just one equal sign. Maybe I can make that a bit bigger. Here course is equal to, and then we have different variable types, data types, but we're going to keep this symbol. For now. Let's use a quotation with an opening and closing quotation mark There not course. Let's do python for everybody. Hit, shift, enter and it looks like nothing happened. But if we type course and the new shift enter, our interactive shell here will tell us that it is a value of python for everybody. And now what you can do is print your course name Python for everybody. Now, the difference here is print will actually print this out. Whereas just because we're in an interactive shell here, this is sort of displaying it for us in terms of which one you should use currently, When you're using Jupiter Notebook, you can use either one. It doesn't really matter, but any python program. When you're actually creating a dot pie file, you'll want to use the print statement because that will actually display tax in your terminal or in your command line program. So what I would like you to dio is create a new Jupiter notebook or open up your python shell on your command line, type in courses equal to python for everybody and then type in course and then print course . And that's it. At that point in time, you have already assigned a variable. Now the nice thing about a variable is you can reassign it so we can say initially, courses Eagle do python for everybody. But we could also say if we wanted to change that value, we could say the course is now going to you for some reason, transform into JavaScript for everybody. And if I hit course, enter print course shift enter. You can actually see if I scroll up here. Course was originally Python for everybody. We printed it. We know that that's exactly what it is. And then we changed it to JavaScript for everybody printed that, and we now know that course is now JavaScript for everybody. So any time we access it down the road, it's always going to be JavaScript for everybody. So we set the value python for everybody, and then we overrode it. Now that's basically how variables work. It's just a name that points to something, and that's actually the key behind a variable. What a lot of courses won't tell you is how a variable works behind the scenes, So a variable is just a name. Python behind the scenes does not care what this is called. It could be called literally anything. There are some rules it should not start with a number, for instance, should not start with special characters. Just give it a normal name with just regular letters and maybe underscores. And if you want uppercase letters, some something like that as long as it's just a regular text name. Python doesn't care what it's called. Then we use an equal sign. And what this says is, Hey, Python, please give me a little piece of memory from the computer. So a little piece of that ram that's going on or some processing power, However, memory is allocated on the particular computer. I just need, let's say, 128 bytes of memory, and wherever that is, I don't really care where it is. Just give me 100 28 bytes of memory and then I'm just going to use a code name, course toe access, those 128 bytes of memory. Now, this point in time, that 128 bytes of memory inside of it, says Python for everybody. And so really, what we're doing is we're taking this text and we're jamming it into some sort of memory inside of your computer. And so when the script runs, Python says, Okay, there's a name called course I know that's a sort of a code name for this piece of memory that I don't know way over here, and the user never needs to know about it. But I know that it has a code name, of course. And inside of it it says python for everybody. So whenever the user types course I know that it's supposed to be python for everybody. So really, all it is is Ah, you've got let's say a code name a k a variable name is equal to And this will actually assign a piece of memory to this variable for you and then anything you want in here And I'm actually not do that cause I don't need that. But then let's say down the road, I overrate that variable, which we did now pythons going to say Okay, well, this has the same variable name. It's already allocated to Python for everybody. But what I do about it, I mean, it already has some data here. So what do I do? And behind the scenes Python is going to say this already exists. You know what? Throw it out, Delete it, get rid of it, get out of here. And I'm going to create a new variable with code name, of course. So it's just going to be the exact same code name, but is going to point to a different memory location. That's how a variable works behind the scenes. No, that's a little important to understand down the road. You don't need to know about it too much right now, but just tuck that in your back pocket because we're going to reference us a little bit later. In this course for now, setting a variable is super easy. You say the variable name is equal to, and then whatever the value is going to be, make sure you have quotations in there because that is a particular data type that allows you to use spaces and characters like P Y T H o n. So go ahead, give this a shot creative variable, and then prints that variable out. Once you have done that, I think we are ready to move on to the next lesson. 16. Formatting in Python: formatting and python is very different from other programming languages. In languages like PHP, we have this opening syntax and every variable starts with a dollar sign so it will say hello is equal to how low And then we've got Semi Coghlan's and then we can print Hello. Actually, we don't print we echo Hello and that is and so this is PHP syntax formatting. We don't do any of that in Python. In JavaScript, we use a lot of curly braces as well. So in javascript you'll see something like function name Curly Brace and doesn't stuff, and you'll see a lot of curly braces in JavaScript. You will not see them very often in Python Python instead has opted in for a cleaner style of coding, and it looks a little weird at first. But once you get used to it, it is a beautiful thing, and it makes your code really easy to read right away. So python largely works on indentation, so we're going to look at a few more advanced features right now. You don't need to know these, but I just want to show these as a demonstration of how formatting works in python. So in Python, every piece of code originally should start on the very left right here so we can create a new variable like course, is equal to python for everybody. And because it's right up against that side, Python will immediately evaluate that incitement. Okay, there is a variable, and inside that variable is python for everybody. Let's go ahead and space there that will drive me nuts. Now the javascript example that I wrote was like Function does a thing. Curly braces. And then, if we wanted to, we could write some stuff here. Usually you see some inventing, but it's actually not necessary. And it's not necessary in languages like PHP, either. What Python dozens done is I'm going to create a function here. But don't worry. You don't need to know this right now. We'll learn about functions down the road. But Python does this thing where it's like OK defined a function called name, and instead of a curly bracket, we use a colon, and then, instead of having a closing curly bracket, we simply in dent everything so we could put a variable in. Your welcome is equal to hello world, and as long as we have logic in here, that's always indented. Python will say all of this indented code belongs to this function. And to get out of that function, we can always just delete and go back to the left most space. So as an example, I'll get rid of this because that's going to break my code. But then I could say Print. Hi, hi, hi. Hi, I and it still works versus if I intend this. It doesn't work. Python now knows that there's a function named name again. Don't have to worry about knowing what a function is at this point in time, but it didn't print high, and that's because it wasn't hugging that left side. In other programming languages, you'll also see lines ending with a semi colon. We don't use those in Python. You can use them, but generally we just don't We don't need them. And so any time you put something on a new line, Python says, there's a new line. Okay, I understand that that's a new line, whereas in other programming languages you sometimes need to put a semi colon, and that tells the programme that there's a new line there. But Python is smart enough. It just says, Oh, there's a new line. Okay, well, do something new. So the biggest take away from this particular lesson is actually just that in denting. So we don't use curly braces like you might have seen in movies or other programming languages we always use in denting. And whenever something is indented, it means it belongs to the thing that is out dented most from it. So as an even more complex example, we could have another function in here called thing. And we could say Print high, high, high, high in here. Actually, it's a bad example is do. Hello. Hello, hello, Hello, Hello. And this print statement now belongs to this function, and this variable belongs to this function. So in denting is very important. Now there's two ways to in Dent in python, you can either use tabs or spaces. There's been this ongoing war forever. What's better tabs or spaces? But I think most people prefer to use spaces. However, we tend to just use that tab key. So if you hit Tab, you'll see that it's jumping four spaces at a time. 12341234 And last, but not least and again, this is a more advanced subject. But if you ever see some sort of inventing and there's nothing underneath it, Python will freak out about that. So you could say if something is true and again, you don't need to know what that is right away. But you could say if something is true and it needs to be indented for it to run. Whatever code is in here, if you simply just said, if true, and then over here we did print Hello. This is going to give me an error indentation error to be exact, and it's because it's expecting an indented block. It is expecting some code to living here, and if there is no code in there, you can just type pass, and that will tell Python you can still execute this, But hey, there's nothing in there, so just don't do anything. Just skip it and it works. So again, the biggest thing about formatting in Python really is indentation, trying to keep it the same. So if you're using indentation of four spaces used four spaces everywhere, don't use four spaces here and then used tabs here because python will think those are different things. So if you spaces, stick with spaces. If you use tabs, stick with tabs. And typically, if you invent with four spaces or one tab, then always use four spaces used. Four spaces here. Use it here, and then you can also use four spaces here, and that just keeps your code looking nice and symmetrical and keeps it nice and readable. So that's formatting and python. You're going to see this through the rest, of course, and it's good to know why this works and how it works. 17. Python Data Types: Hello and welcome back in this video, we're going to be talking about python data types now a data types, data structures. These sound like really scary things, but actually it's not. There's a really easy way to look at data types because really, programming is just mapped after what we have in reality. So in Python, we have different data types we've got, uh, let's say, numeric, let's go ahead and add another one in here. And this one's going to be called Boolean ins, and I'm gonna go over each of these individually. Okay, so there's four of them in here that we're going to cover. Initially, there's actually more, but these are the ones that you're going to be working with literally every single day as a python developer. So we here we have numeric numeric is really just means we have integers, we have floats and we have complex numbers. All that really means is, for example, an integer is a full number. So we've got 12345 There are no decimal points. It's just a full number. That's an integer. Then we have these things called floats, and a float is a number with a decimal, so that could be 1.0 3.14 100 point five. It could be any number that has a decimal in its even if that decimal is totally redundant in real life is called a float. Because even if that number is something crazy like this, you can sort of think of that decimal as being able to float around between the different numbers. We could put it there. We could put it over here. We could do that. But over here, if we wanted to, So the decimal consort of bounce around it can float between the numbers. And then lastly, we have these things called complex numbers, complex numbers and complex numbers. Actually, we're not going to get into this because I'm going to be pretty rare that you get into this unless you get into data science. But for now, we can actually sort of somewhat avoid complex numbers. But complex numbers are, for example, in real life, if you had 10 to the power of 15 or in my case, because I didn't type 15 10 to the power of 45 so in computer and sort of look something like that and programming It looks like that. So we've got this strange, complex number that could be really, really big. It could be sort of fractional if you want it to be. Anyways, complex numbers were not going to get into those, but that is a numeric type. Boolean is on the other hand, Boolean Zehr Easy billions are either true or false literally. That is it. And you can actually see that all three of these are keywords in python. So true with a capital T false with a capital F, and the word or is used in statements will talk about those down the road. But really a Boolean is Hey, are you watching this video right now? Yes, you are. So it's true. And if I asked you hair you currently watching this video from a different planet? Well, no, you're watching this on Earth right now, so that's going to be false. And that's all the Boolean is and a lot of programming logic, really just come comes down to Boolean says something true or false. Now billions have this darker, deeper side to them where things can be turned into billions. We could turn test into a Boolean like this. We'll talk more about typecasting a little bit later and let's go ahead and run that. And it says true eso. There's a little bit more to billions and just true or false. But really, it boils down to Is something true? Or is something false? That's all it is. And when we talk about computers and the word binary, that's what we're talking about. True or false, it can only be one or two different things. A sequence is like a list. It is something that you can loop through, so it's a lot like your grocery list. So let's say you go to the store and on your grocery list you need You need a few different things. Let's say you need milk, you need eggs and you need bread. Well, this is your grocery list, and so you go into the grocery store and you say, OK, my first stop is going to be milk item number one. Then we're going. Teoh, look for eggs. That's item number two, and then I'm going to look for bread. That's item number three. That's really all of sequences is a list of things like that. Now in the world of Python, we actually have a data type called a list, and that's exactly what it is. It is literally a list of things like milk, bread, eggs, something like that. And that's actually a list. We also have these things called topples or some people calm pupils, and it looks almost the exact same. But we have parentheses around him. We'll get into all these down the road as well. I just want to get you sort of familiar with how some of these look. And lastly, we have these things called sets, and a set is again looks very, very similar, but has curly braces around it instead of parentheses or a hard bracket. Now there is a difference. A list can be added to can be modified. A couple cannot. So this is like saying you went to the grocery store and you were only allowed to buy three things. You have to get milk, bread and eggs. You're not allowed to get anything else. No chocolate bars, no chips, no orange juice. Nothing. You can only get these three things, and a set is a lot like a list, but technically, a list can have the same item over and over and over again. So while this lesson this list would be, Hey, Caleb, can you go to the grocery store to get milk, bread, eggs, eggs and eggs? That doesn't make sense. Instead, a set says, OK, well, eggs appears three times. It's the same every time. So let's just make a show of once. It's unique. That's what a set does, and we'll dive in. The sequence is a little bit later as well. Dictionaries, on the other hand, are very different. Very, very useful, very, very powerful. A dictionary sometimes just called D I. C t a dict with a T at the end there. It also starts with an opening and closing curly brace. But this one has a thing called a key value pair, and so the key is the name you're going to give it. So let's say I had to go to the store for a particular type of milk, and for whatever reason, I needed to get goat's milk. And then let's say I was also needed to get eggs, but I needed to get free range eggs and so now we can actually use this as a variable that holds other variables or data types that can hold other data type. Now we can actually mix and match a lot of these. And before I actually continue, I missed one sequence in your one really strange sequence. This one doesn't look like a list at all. This one is called a string. We've actually worked with this already. Python for every buddy we've seen this before, where the variable name is equal to, and then we have quotation marks around it. And technically, this is a sequence to because behind the scenes, Python says, Okay, there's a P. There's why t h o and space F o r space E v E R Y b o D y. And every one of those letters gets set aside in Python. And so, technically, this is a list as well. It's just a list that's sort of compact and looks like it's not a list. So this is the odd one here, anyways, for the most part, we can mix and match a lot of these. So instead of a list being a string of milk, bread, eggs, eggs and eggs, We could also say there could be a true in there. There could be a false in there. There could be a dictionary in there. That's just an empty dictionary. We could say that there's an empty topple in there, and if we wanted to, we could even say that there is another listing your so a the see and let's just close off that list. And so we have all these different data types inside of a list. We can do that with topples. We can do that with sets as well a string. Although it's a sequence technically can't really do that if we put the word true in here. Well, we know true is a Boolean, but because it has the quotations around it, Python says, This is a string, and so it acts a little bit different. Although we can technically go through each one of these and say, Oh, there is a b o D Y space T R U E as well, so little different. We'll talk about that down the road because that's, ah, a strange one to deal with. But it's also really, really useful, and the same thing with the dictionary as well. So let's go ahead and create a new dictionary. It will call. This person is equal to. And then let's give this person a name. The name is going to be Caleb. That's just going to be me. How many cats do I have? I have to, and if we scroll up here, we can see to is a whole number. So it's an integer. And let's look at family members, family members, and this one's going to be A list of family members. Actually is going to be a temple of family members because it's currently this can't change that. I know it could technically change eso. Let's say we have mother, father, brother, sister. And so now this person has a name, cats and family members, which also includes a list of mother, father, brother and sister. Now, that's all really cool. You probably don't know how to apply that right now, and guess what. You don't need to know. We're going to go through each one of these one by one with proper examples and is going to make a lot more sense as we progress through this course together. So the last note on this last but not least is Please do not feel the pressure to have to memorize. All of these thes will come to you over time. These will become second nature to you over time. So don't feel like you need to sit down and study this for an hour. Anything. We're going to work through proper examples together, and it will become a lot easier to understand as we actually create real life examples. 18. Mutable Vs Immutable: all right, before we get started with actually playing around data types and getting to know them and work with them and how they work and getting some hands on practice. Let's actually take just a quick minute or two to talk about mutable versus immutable. So an immutable thing is a value that basically can never change. And a mutable thing is a value that can change, you know. Basically, in the world of programming developers and programmers such as myself, we like to use bigger, fancier words than what we actually need. So things like mutable and immutable really just means changeable and not changeable. That's all it means. So one thing to note here is, sometimes we actually don't want a variable value to ever change. We want to set it and basically have it set for ever. And there's 12 reasons that we actually want that the first reason sometimes is performance . And if we say that there's a variable that can't change for any reason, Python behind the scenes says Okay, well, I can't change it, so I'm not going to. I'm not gonna add anything extra to it. It's just here's your data do whatever you want with it, which isn't much. And so it doesn't have to keep in the back of its mind or in its memory that it can be turned into upper case or lower case or transformed or sliced or anything like that. And the other reason is data integrity. Sometimes you want a particular value to never change. For instance, if I was to say My name is Caleb, well, that's never gonna change for the rest of my life. So I don't want that to ever change. Or if my age is 30 I don't want that to change ever. I want to be 30 forever. So let's take a look at some immutable versus immutable examples. So immutable example would be like a list. So let's say we've got a food list and we sort of dove into this a little bit in the last video on. We'll talk more about lists and strings in these data types, formerly in just a little bit. But let's say we've got a list of food here, and so I've got eggs, milk and bread. Well, lists are immutable. So what I can do now is if I run that cell I can do food hit dot and then if I hit Tab, you can actually see that. I can append to it. I can clear it, copy it, counted, extended. I can do all sorts of stuff, so just keep this in mind. And so what I can do here is I can append to this and say, Hey, I actually don't need eggs, milk and bread. I need eggs, milk, bread and chocolate because I'm an adult and that's what I'm going to eat for breakfast. And if I take out food and run this cell, it now says eggs, milk, bread and chocolate. And in fact, what we can do here is that just print this out and rerun all these cells. So originally, food was eggs, milk and bread. And that's what Python says it is. Eggs, milk and bread. And then we said, we can add to it. It's mutable. The list that can change. So we added chocolate to it. Eggs, milk, bread and chocolate. Now let's say we have a list that we never want to change. Let's say we get sent to the store by Grandma because she gives us $10 we can only buy things for baking cookies with her. So basically, we need to buy one big bag of flour. So let's say Grandma's list is going to be a couple because they topple is not changeable, its immutable. And she sends us for flour and, um, maybe butter, cause that's what we need. So we've got this list of flour and butter, and if we print this out grammas list to against his flour and butter. But unlike the original list, if I hit dot and then hit tab, I only have two options here. I can count it. Oregon Index. That's it. We'll talk more about what? These are a little bit later, but I only have these two options. Whereas food, if I come back up here, had dot hit tab, I have all these different options. Now that's where performance increase comes in. This list cannot be changed. Its a couple. It's a list that can never be changed. This one can be changed. And because of that, Python says, Oh, you you want tohave? Ah, changeable list. I'm going to give you all these different options and down here it says Oh, you want to have a list? I can never change. I'm not going to give you those options. I'll give you two options, but you can't have 10. And so it doesn't have to keep that in. Its memory. Doesn't have to think about that for too long. Go ahead and clean those up. Now there's one more in here, and this is a strange one. The strange one here is a string. So I could say my name is Caleb because that's never going to change. I mean, I guess I could change it, but I will never change in my life. I like that name. So my name is Caleb, and it looks like on the surface, I could change us to anything else. So let's say I wanted to rename myself to my cat's name. Zephyr on a hit name, Python says. Okay, it was Caleb. Now it Zephyr, and it's ever so On the surface, it actually looks like it did change. But strings air immutable strings cannot change. So what this did behind the scenes was this side. There's a variable called name. It's allocated a piece of memory, and in that memory it says Caleb. And then when we overrode us, we didn't actually change anything, Python said. Okay, it already exists. Get rid of this one and then take the name and assign another piece of memory with the word . Zeffert knew the names effort in it. And so these are actually two different variables. They just happen to have the same name and one overrode the other one. Now, where this gets really confusing is if we do name hit dot we can see that there are a lot of different things in here. So in the example of Grandma's list, we only had two options count and index. But with name. We have all these different options because, well, it's a different data type so we can capitalize it. Weaken case, fold it. We in center. We can do all sorts of stuff, so let's go ahead and let's turn name. Let's do this on a another cell. Let's do name dot upper and I can type U P Hit tab, and it will auto complete for me, and that's a function, so we're going to run parentheses at the end of it. We'll talk more about that in the future as well. Let's go ahead and run that and we can see it turned all my letters into uppercase letters . Now that is really cool. But name itself didn't change notice with our list. When we did food dot upend, it actually changed the whole value. It went from three items in here to four items, and we didn't have to reassign itself. That's because it's mutable. A string being not mutable doesn't work that way. Instead, what we have to do is say, name is equal to name dot upper. So this is where it gets a little bit strange because name here is a new variable at least . Ah, least Python thinks it's a new variable. And so it's going to assign a new piece of memory over here, and it's going to say is equal to Okay, well, name. Currently it exists because this whole thing has not been evaluated yet by the computer. So this name here still exists. It's referencing Zephyr, and then we're going to turn that into uppercase, and then we're going to take whatever this is, which turns out to be Zephyr in Upper case and jam it into this new variable called name, and that's going to overwrite this one. So again, on the surface, it really does look like it is a mutable thing. But strings, the data type called a string is not immutable. So when I type name is going to be uppercase Zephyr just like that. Now, that might be some crazy behind the scenes python stuff, and you may or may not ever actually use this least not with strings, but you will definitely use it when it comes to topples and lists again. This is one of those things where I'm just preparing you for the future. You don't need to know this or memorize this. Rather, you don't really need to memorize us at this point, you will experience mutable versus immutable objects down the road when you're writing your own programs and you will experience why one is better than the other sort of with your own projects as well. And to me, that's a better way of learning than me just telling you through a video that, hey, this is mutable on a This is not mutable, yada, yada, yada. Anyway, so for now, just tuck that in your back pocket. mutable versus immutable, mutable, mutable is equal to changeable. I don't know how to spell that word. Apparently changeable. No, that doesn't look great. Too changeable and immutable. Immutable is unchangeable, and that's all there is to it that's important. Moving forward in the future, but not important for us right now. So once you've had enough of this video, let's head on over to the next one where we learn about something a little more applicable to us right now. 19. Numbers: Let's talk about numbers. So we're going to start this video off by talking about simple numbers. So we've got integers. So an integer, as previously explained, is just a full number, So an interviewer could be the number one. It could be the number 42. It could be the number 1000 1,100,000,000. It could be a googol plex. It could be any full number that does not have a decimal in it, so three is a full number, but 3.0 is not a full number. So let's go ahead and assign a variable and say age is equal to 30 a full number. And if we display that age and just as 30 now, we can also explore what this data type is. If you're ever curious about what the data type is, let's say for whatever reason, you're working with some code, and you don't know that age is equal to 30. Could be anything at this point time. Go ahead and use the type function, so type parentheses. Put your variable in there and then close your parentheses and you will see that it is an int that is an integer and That's what I was saying at the beginning, and it is a full number. Now. Let's say you have a really big number. If I said num is equal to this number, could you tell me exactly what that number is? Just by looking at it like instantly? Maybe you can if you can. You are unique because I cannot do that. I personally have to count the zeros after. Go 123123123123 But Python gives us a nice way to deal with large numbers. So in most programming languages, you cannot simply just add a comma. This doesn't work, and you can actually see the syntax highlighting breaks. It goes from green to red to green to red to green to red. That's not gonna work. And let's let's try this. That's not a number. So what if we do type numb? It's actually a tubal interesting, but we don't want that because we want an actual number. Maybe we're going to add a number. Maybe we're going to say if you're over 21 you can drink alcohol in the United States. If you're over 18 you can vote in any country. Double is not going to allow us to do that, couple says. 100 000 That's hard to compare him. That's not a simple as are you greater than 18. But instead, what we can dio is because Python gives us this nice little feature we can use underscores . So let's go ahead and rerun the cell rerun that one rerun this one, and we can now see that it is still an integer. And all this underscored does is it allows us the reader, to understand what we're looking at. So if you have a large number like this, say, 100 billion, you can actually format it like 100 billion, and the computer will still understand that it's still an integer. All right, let's move on to floats, floats. Now a float is a number that has a decimal in it. So, for example, a variable called pie could be 3.14 something something, something trump them. The fact is, this has a decimal in it, so it is in fact, afloat. And if we do type pie, it will tell us that it's afloat. Now what? The big difference here really is is just that decimal point. That's all it is. That's the difference between afloat and an integer. Now flutes also allow us to do this nice little thing where we could say, Let's create a large variable here large float is equal to And again let's just do some crazy number here dot some other crazy number. So I have no idea what this number is just by looking at it. But what I can do is I can and underscore Here. Add one there. Add one there. Add one there, and now I can actually see what this number is. So we've got tens, thousands, millions, billions and trillions of 123 trillion. Let's go ahead and run that and let's run type on this as well. Large float and it's still afloat. Versus what could have happened before is if I just copy this entire thing over, and I replaced this with commas, which is usually what we do when we're writing a number on paper, for instance, I do large float Well, that looks like a tubal, doesn't it? Let's go back up here and let's run type on this and see what this is going to be. Sure enough, it's a tough one. That's not what we want. So whenever you're dealing with large numbers, integers or floats and remember afloat just as a decimal point, that's the only differentiator here is that instead of using a comma, you can use an underscore and it wont break your program. 20. Strings (Sequences): Let's talk about strings. Strings are a thing called a sequence, so a sequence is really just a generic term for an ordered set. That means you have a list of things toe work off. And so when we said Let's not do nameless due course is equal to Python for everybody. This is called a string, and so if we run, type, not string type course, this will just say string. But behind the scenes Python is ripping this apart. It is saying there's a P Y T h o n space fo r space e v E r Y b o D y. And it is trying to map all of it. Now, before we get into the sequence of a string, let's actually break down. What a string is. Mr Ring really is just a sentence. So let me actually rate that out. A string is just a sentence. That's all it is. It can have spaces. It can have commas underscores special characters. Upper case. Lower case. It can have pretty much anything as long as it starts with one of three things. A string needs to start with quotation marks. It needs to start with either quotation marks or apostrophes or a set of three quotation marks or three apostrophes like this. Now there are different reasons for using these, and let's explore some of them right now. So let's say I have a sentence, a sentence, and it says What's going on? And when I display the sentence says, What's going on? Not a problem. But we can also create this sentence with apostrophes instead of quotation marks. You can actually see the syntax highlighting here is broken, and that's because, Python says, Oh, you're starting with an apostrophe. This whole thing is going to be a string, and I'm gonna keep thinking that is a string until it matches the next apostrophe. Now we, as humans, said, while the last one should be over here. But because this is eight, I think it's called a conjugated word. It has an apostrophe right in here, and instead of saying what is? We said, What's and this is going to break invalid syntax? Python is actually telling us exactly where is. It's a syntax air. So what we can do here is use quotation marks instead, and that works and that continues to work. We could also use three quotation marks or three apostrophes. Either one here is going to work. So if I keep running these cells, you're going to see that nothing actually changes and did it, Uh, and it continues toe work. Now the thing that I was getting at before is if I just copy this over and get rid of those that's syntax air because we're using the same quotations. Well, sometimes it's not super easy to just change your quotations are your apostrophes to quotation marks or to a thing called the Doc String, which is the three in a row. But what we can do is we can say, Hey, python, this one in here right here is not actually the end of the string. And we tell that is not the end of string and to rendered as a regular character by adding a slash in front of it. And this is called escaping. So Python now sees slash apostrophe and says, OK, well, when I render this, I'm going to make sure that slash apostrophe shows up as just a regular apostrophe. So let's go ahead and run this as well, and it works now, sometimes you're going to want a string or a sentence on multiple lines. That's a fairly common thing that you're going to see in Python. And there are a few different ways we could do this. We could say, of course, is equal to Python and we put that in a string so it's starting and ending with quotations . Then we add a slash backslash and then on a new line we could say for everybody and let's run this and we can actually see that to put it all in one line on because I didn't do the spacing properly in there. There we go. I needed that extra space inside of the string for to basically say, Hey, there's one here and there's one here But because they're on two different lines, followed by this little slash in the middle, put them together. So that's one method of doing it. Another method would be to use parentheses so we could use and opening and closing parentheses here. And so let's say hello. Make sure we had spaces this time. My name is Caleb. It's run that and let's not call that course. Let's call that greeting because that's not a course, and that's just a terrible way to improperly name variables. And so let's run greeting in here and we see Hello, My name is Caleb. So that's the second way is with parentheses. And because there's an opening and a closing bracket in year, Python is automatically going to say Okay, well, I understand what you're trying to get out here, so you don't need tohave the slash in there. It's just going to understand that this is a string beside a string beside a string and just put them all together. And when Python puts things together like that when it puts a string together with another string with another string just like this, that's called Concatenation Colin Cata Nation. Now there's one more way, and you're gonna see this one a lot in the wild, and this is more of a thing called the Doc String. So let's actually call this a doctoring Doc String, and it is equal to three opening quotation marks or three opening apostrophes. He could be either one and has to end the same way to that's important. Whatever it starts with, it needs to end with Hello, this is ah Doc String and we're going to see something a little different with this one. Doc String. Go ahead and run that. And if I do? I didn't name that right either. And I also type of that one like that. At least I'm consistent with my typos. And if I put Doc String in here and run it, you have these things with a slash end. Now in programming, you can make new lines like this and you can have it displayed up. And whenever you see a new line and actually you see it a lot in any code, any text editor, any website, you see new lines all over the place. This slash N is a new line. That's what it means. It's called an invisible character, and it doesn't actually show up. But whenever a computer recognizes that, there's a slash and it says, Oh, okay, well, let's put that on a new line and that's what this did here. So it's a the doc String started, and then there was a new line. Hello, New line. This new line is new line, a new line doctoring new line, but because we just wanted this as a regular string. It said, Hey, just so you know, there are supposed to be new lines in here now. What would happen if we were to print the doc String instead of just displaying what the value is? Let's actually print the value of Doc String. Look at that prince. The function print looks for Slash and and says, Oh, there's a new line. Hello, There's a new line, this There's a new line and it continues to go on and actually creates new lines for us. Now, if you're just jumping into this video and you haven't watched the previous videos Ah, fun. Little fact about strings is they are immutable. That means they cannot be changed. All we can do is overwrite the variable name with a new value. Now I mention that this is a sequence and a sequence is basically a generic term for, like an ordered set, like a grocery list. And so what we can do here and this is getting a little advanced so you don't have to know this part, but I'm going to demonstrate this. Let's do word is equal to Python and let's create a four loop four letter in word, and this demonstrates that this is a sequence of letters. This isn't just one word called Python. It's actually six letters, individual letters, according to Python's internal workings, so we can do print the letter, and what this is going to do is print p Y T H o n. Let's go ahead and run that. Sure enough, it took every single letter and printed a one by one, and that is what makes a string a sequence. 21. Lists (Sequences): Let's talk about another data type lists, which are also a sequence. A list is literally just a list. But we have a few different types and python. We have this one called a list. We have another one called a couple or a to pull. Some people call it a double and a set. These are the three main ones you're usually going to work with in python code. No, these lists or these type of sequences, you can think of them as a grocery grocery list. So you're going to the store and you have to pick up milk, bread, eggs. And I've made this metaphor a few times now, but you've got milk, bread and eggs and you walk into the store and you're like, Oh, hey, I'm gonna pick up milk, cross it off your list. I'm going to go pick up eggs and cross that off your list. I'm gonna go pick up bread when you cross that off your list. That's all these are doing. So let's actually turn this into code. So a list starts with and ends with these hard brackets, and I just made that one step bigger there, and you could say milk and that's a string. You could say eggs. That's also a string bread that's also a string. And remember, each one of these is also a sequence. But it is also its own item in this in this list in this array and then just for fun. ZIS I want to show you that we can also use a number. So let's say the number 42 and a Boolean. And if I just display this groceries, we can see we've got milk, eggs, bread 42 true. Now I'm going to create this thing called a four loop. You don't need to know what that is right now. You don't need toe, understand how it works or the syntax behind it. Because this is just for a demonstration. We'll get into loops down the road and we'll get some proper education around that as well . But for now, this is just going to be a demonstration. So four item in groceries and because this is a sequence or a list is going to go through milk, eggs, bread 42 true. And so what I'm doing here is I'm just saying for each one of these, whatever it's called in here milk, eggs, bread for bread 42 or true. Just call it an item. And so that is a variable called item. And I could just print that. And when I run this milk, eggs, Bread 42 true and now if we want to, we can actually change this to be a tubal. Let's rerun this cell this so and you can see that the brackets changed here as well. So we know it's a couple, and when I write rerun the four loop. It looks like nothing happened, but that's because it just has the same items in there. We can't even do the same thing with a set, and a set looks almost identical. But let's go ahead and add bread for a second time and also milk for a second time. So we've got milk, eggs, bread, bread, milk 42 true. Let's run that and run this, and now you can actually see that it's not in any particular order, but bread and milk only show up once, whereas up here it was specified twice. So that's the difference between a set and a list a set to make sure that every item in there is unique. So you have 42 bread, eggs, milk and true. It is also a sequence. So when we rerun this, instead of saying bread twice and milk twice, it only shows up with milk and bread once because it's unique to that particular sequence. Now, one thing to keep in mind here is that this sequence did not keep its order at all. It started with milk, eggs and bread. And then, for whatever reason, when python internalizes, it went 40 to bread eggs. And then even in our four loop, when we just wanted to print back all these different items on their own lines. It started with true Bread 42. So none of those actually match up, so we didn't keep their order. So if you need something to absolutely keep their order, definitely used a couple, which has the softer parentheses, brackets run, run, run, and that keeps its order. Or you can use the list with the harder brackets run, run, run and yet the exact same results. So that is lists and lists like sequences. In a nutshell, now that you sort of understand what those kind of look like a little bit, let's move onto the next one 22. Indexing And Slicing: strings are what are called an irritable and their sequence, meaning that we can break them apart and we can take action based on every single letter in a string. So with that comes this idea of an index, and we can do this with a list or an array or a topple as well. So let's go ahead and make a string. So the course is equal to python for everybody, and an index is literally just a number. So it's your variable name, and then it's got the heart brackets, and then you just put a number in there. So number zero, because computers always start counting at zero, is going to be the P, and then we can just simply count from there. So if we go 012345 the fifth letter in your the fifth number rather is going to be the end . So let's go ahead and test these assumptions. So Index zero again. That's just with your variable name hard bracket than your index number and then closing hard bracket P just as expected, and course what I say it was five, I believe, is going to be n just like that. So in most programming languages and index tends to start with the number zero. Not all of them, but most of them. So to humans, zero really just doesn't mean anything. Zero actually means literally nothing, and it's kind of crazy to think about. But to a computer, zero is the number. So if I said you have five apples and I have zero apples, I have nothing. I have a basket of nothing. It's just an empty basket of nothing. You might have a basket of apples. I have a basket of zero apples, a k a blank or empty or void basket. But to a computer, there's always that zero number. And that's why computer languages usually start an index with the number zero. It's because it's actually it's a real thing for a computer. So that is indexing through a strength. If we want to index of through a list, we could do LST short for list because if I do, l I s t you can see it sort of glows green a little bit. That is syntax highlighting That means it's a reserved keyword, so let's just do LST is equal to car truck airplane and a blimp. I don't know why I'm using any of these in this example, but let's take a look at this anyways, So I have this variable called LST short for list. And if this follows the exact same pattern as up here, car will be zero truck will be one airplane will be too. And blimp will be three. And we can actually test out our assumptions here so we can do list Index zero. And that's not gonna work because I actually typed list. It should be at last T index zero. And there we go. We got a car LST to just take a sec and think about this one Which one is going to be, too? If you are thinking that index to is going to be airplane, you're absolutely correct. If you think Index to is going to be truck well, remember, we start counting at 0012 And if you've made that sort of mistake already, that is OK, because I've been doing this for 20 years and indexing steel occasionally. It still comes out and bites me as well. So it's just something to sort of wrap your head around, but we can see that list with index to Is airplane Now just for fun Z's. Let's go ahead and see if we can get the reverse. So let's do list with a negative number. Which one do you think this is going to provide if we start counting backwards from zero, this one is blimp negative. One negative to negative. Three Negative four. Let's try that again. LST minus three. And if this holds up minus one minus two minus three should be truck and there we go. So now we have indexing forwards and backwards. Now that's just part of indexing. The other part of indexing is this thing called slicing. So if I type of the word course here, we have python for everybody in a string weaken slice very easily. All we have to do is say course. Where do we want to start? Let's start at the very beginning. That's the P. And for how long do we want to go for? Or up until rather, let's say we want to go up until the number five So 012345 and let's take a look at this well, this one only gives us Python, not Python. So if we wanted the whole word, we would have to use course 0 to 6, and that will give us the word Python. But let's also let's slice the word four out of years we've got 0123456 so we have to start on index seven 89 10. Let's do course 7 to 10. Let's see what this gives us gives us the word for and that's slicing a string. Now we also have that list, right? And we can slice a list as well. So let's slice this list. Let's do LST Let's grab number one and go up until number three. So 0123 We're gonna start at 101 We're gonna start a truck, gonna grab airplane as well, and we're gonna go up to the third index. So we're not going to get blimp. But we're just going to get up until blimps truck an airplane is what we should be getting back. And sure enough, there we go. We have now indexed and sliced a string and a list, so sequences last But not least, we can also take these three slices or any of these indexes, and we can put them into another variable. So we have this variable called course. But what if we wanted to get a variable called language? Language is equal to course. Start at zero, go to six hit, enter and there we go. We have language as python and course is still python for everybody. So all it did there was it took out this little piece of text and throw it into a new variable called language. No, In most python cases, at least Python cases I've run into you won't use this one too often, but you will use list slicing quite a bit. So even though slicing or indexing a particular string or a sentence who is not actually super useful, it is good to know, because you can also apply it to lists you complied to topples and things like that 23. String Properties And Methods: in Python, you were going to see two primary ways in which you can change data. One is called a function, and one is called a method. Now, in Python, most things are considered an object, saying that as an object now for now and for a little while, this is going to be a little bit of I don't really know how else to explain it, but it's going to be a useless word to you while you're learning about them. Because an object in English at least, is just a think. It's any physical thing, really. And so if we did something like name is equal to Zephyr. That's one of my cats. This name if we did tape Name is a string, but let's go ahead and put this into our Python interpreter from our command line so I'll just take Python. Get in here and let's say name is equal to know through the other cat. Henry and I do type name. We can actually see that it's a class. It's a string just like what we saw here. But it's a class, and with a class comes this thing called a method. Now, a method is a lot like a function. Just the way that you call it is a little bit different. So a function looks like print. We put stuff in here that's a function because it has a function name, then parentheses, and then it takes our arguments in here. So in this case, we could say stuff in here we put a common. We put another argument in here another parameter more stuff in here, and we could run this and it runs both of them together. And that's because it is one function that takes one or more arguments occasionally. These are also called parameters. We've also used type, which we already used in this lesson as well. And you put in some sort of variable name and he gives you exactly what that function is. And I think I just said function. But what I meant was, the variable tells you what the variable is. So you say type name gets string, you say print stuff in here and more stuff in here, and it's going to say stuff in here more stuff in here, but because name is a class when we can see that in our proper Python Interactive shell. In here, it's a class. Classes have these kinds of functions as well, and behind the scenes they look almost identical to writing a normal function. However, the way we call them is different. So name we know is a string. It's a class. If I hit dot and then tab, you can see all the different things that I can I can do with it. I can check to see if it's a digit. Is it a decimal? Is it lower? So this is just checking a bunch of stuff in here. Ah, but we can also and split it multiple lines. There's a lot of things we can do. Let's do upper. And all this is going to Dio is take zed E ph yr and turn it all into uppercase. That's it. So the difference here is with a function you're giving it an explicit parameter or multiple point parameters with an object. Our name is being our object because it's a class. Think of classes as objects. It already knows what that name is. That name is suffer. And so, in order to make that upper case, you say name which python then points to Zephyr make it uppercase, and that's exactly what it does. So this one is called a method when it's attached to an object. When a particular function is attached or pre attached to any sort of object, like like a string like our name here, then we call it a method, and it gets called with dot and then the method name and then parentheses. Now in the title here is called String Properties and Methods. We now know what a method is. Let's go ahead and take a look at a property a Peru up er t. So a property is a lot like a regular variable, like what we defined up here, but it exists inside of an object. For example, name is Zephyr. How many letters is that? While it's easy enough for us to count their six letters in there, So if we said hey Python, tell us how many letters there are, it should return just the number six, and we can find that out by doing L E n short for length and putting the name in here. Now we actually have to call a function, not a method to get us because somewhere inside of this object inside of this name called Zephyr, Python said, I know that there's as Eddie pH Why are, and that there are in fact six characters in there, and he keeps track of that for us. And so that is what a property is. It's just a variable inside of it, so you can sort of think about it this way, and maybe I can do this in Mark. Down is we have this variable called name is equal to Zephyr and then behind the scenes we have things like the total number of letters is equal to six, and then we also have functions behind your, such as upper, and that's just going to take whatever this value is here, and it's going to make it all uppercase for us, It'll say, is ever something like that, and so you can sort of think about it This way is Zephyr has total letters behind the scenes. Python keeps track of it, and it's not just with length or upper. There's a lot of other ones in there as well, so when it comes to objects, really, you can type in any sort of variable name hit dot and then tab, and you can see what else is in your. So let's say, does it and and with ah say doesn't end with an R. It does. But does it end with Is Ed? It does not. So it returns a Boolean. So that's a method because it's a function is running some sort of logic name dot count. Here's a good one. We can count to the number of peas in year. And remember, when we're talking about sequences and strings, How behind the scenes? Python says. OK, I know you have a sentencing here with Zetti pH. Yr, and it's going to log all of those individually, sort of behind the scenes exactly what it's doing here. So it says name run the method. The function on this name called Count Look for the number of peas. And so when I hit, enter on this or shift enter in Jupiter Notebook. This is going to say one just like that, you know, if you ever want to test any of these haute, by all means, open up this notebook, hit or type name dot hit tab, and then you can just explore any of these that you want. Some of these are not going to be as intuitive as others. And a lot of these we're going to cover, sort of. Throughout the rest of this course, A good one here would be lower. Okay, It's a lot like upper, but just turns everything lower so that zed is going to be a lower case. Is that little Zephyr? So you can go ahead and test some of those out. If you ever get stuck on one of them, you can always just throw it into Google is Well, it could be like, Oh, python count method python. Find Method Python is asking method, and we'll bring you to the python docks. That or a stack overflow question or a nice block post that will sort of help you understand. And there's a lot in here. We can't possibly go through every single one, but there's quite a few in here that you're gonna end up using quite often. So one thought I tend to use as a Web developer. Count ends with find format. Join lower. Replace are split. Regular split starts with strip. Our strip was in there too, right? Yep, are stripped title and upper. Those are the ones I usually use on a string anyways, on just for funds. Let's see what Swamp case does. Look at that. It's want the cases. So that's kind of something fun that weaken dio now. The big thing here, the big take away is really the difference between functions and methods. And just as a quick little recap, a function looks like the function name then has parentheses, and then you put some sort of parameter inside of it, like type or print, and a method looks like dot and then the function name or the method name and then parentheses, and it can take a parameter might not take a parameter. And a property is really just a variable inside of an object like name. And a good example of that is length. Name and Python said There were six characters in there, so it somewhere inside of Python, it says Hey, Name has a attribute as an attribute as a property has an internal variable called length, and that value is six 24. User Input: python can accept user input through a command called input actually, is a function called input. Now, one thing to keep in mind when using the function called in put is it can take a string as , like, a sentence or a question. Ah, you can store this as a variable, for instance. But the biggest thing to remember is that no matter what someone answers here, it will always come back as a string. So let's do a few examples here. Let's say your name is equal to and let's say it's going to be input. What is your name? And so okay, says here, what is your name? You can see that the cell is still running, said a little asterisk beside him. My name is Caleb. Okay. It looks like you did nothing. But your name is now assigned to Caleb. And if we run, type on your name is gonna come back as a string as expected. Now, what if I said age? What is your age? And this also needs an input function. Not a method is a function because it starts with the name and then parentheses. And it doesn't have something attached to it like that. So this is a function this is going to ask What is your age Now? My age is going to be 30. Cool, so I can now enter Age says 30. But if I tighten age still comes back as a string Now why is this important is because down the road and not too far from now, we're eventually going to need to be able to ask Python a question. We need to say, Hey, is the age higher than 18 or greater than or equal to 18? And so one thing to keep in mind here again is just because everything comes back as a string, it's going to be a little bit harder to compare things. So if you wanted to make sure that this was a certain number, you could technically ask if this was a certain number. But what if someone lied about their age? Right, So let's rerun this example. Let's say age is equal to what is your age? We're gonna rerun this and I'm gonna put in. I'm gonna type in the word 30 because I'm gonna be weird about it. Instead of putting a number, I run this it says 30 type age, still a string. But now in Python. What if I said, Hey, Python? I need to know if someone is 18 or older. I could say if age is greater than or equal to 18. Well, this is already a number. Strings tend tohave quotations around them or apostrophes around them on numbers. Do not. So if the age is greater than or equal to 18 print, you can vote so a very boring example, but nonetheless a good one here. And look at that. We're running into an issue now. We'll get into what if statement is a little bit down the road because we're going to be working with a lot of them. But Python gave us this thing called a tight there and he said, greater than or equal to is not supported between instances of a string and an integer. And that's because it thinks this one here is a string, and sure enough, it is. It is the word 30. And so it's sort of like comparing a word to a number it just doesn't work out. Mathematically in a program cannot understand that it's not smart enough to say Oh, this is the word 30. And what it actually means is 30 does not understand that whatsoever. And so it cannot make this comparison and will error out on you. Now I'm gonna get rid of this because you don't need to keep that in your memory bank for now. We'll talk about those a little bit later. What I would like you to do for funds ease is in your command line or in a Jupiter notebook . Creative variable doesn't really matter what it's named is equal to input and then ask a question Hit enter and is going to ask you for an answer. Then answer it and then just print out whatever your variable is. I want you to actually execute this input function and then print out what the answer is. Give that a shot. And when you were done, let's head on over to that next lesson 25. Print Formatting: Let's talk about printing. Printing in Python is especially useful for debugging your coat. Now, Right now, our code is actually not very hard at all, so it's pretty easy to you to debug it. But eventually our code is going to become several dozens of lines or hundreds of lines. Long and debugging is going to be a lot harder. And because we don't have some sort of debugging tool or or program installed, most people will just rely on the print function, the print statement, and so in their code, they'll say, Does this work and then test more stuff? And somewhere down the line, they're going to say, Does this still work? And the idea is that this one will show up, and this one probably won't. And then they can assess that the code sort of breaks or their logic breaks somewhere in the middle. And that's how a lot of people debug with Python. That's actually not wrong. That's not a wrong way of doing it. But when it comes to printing, there is a nice way to print things like variables. So let's go ahead. Delete that and let's talk about two different ways. to print. So prior to Python 3.6, you're going to see this a lot. So let's create a variable course is equal to python for everybody, and the print statement will look something like this. The course you are in is you've got these curly Britain, these curly brackets inside over this string, so inside of your quotation marks here dot format. So this is a method. And whatever you put in here as that first parameter is going to be automatically filled in here, so dot format course and let's go ahead and just run this. And it says the course you are in is python for everybody. So we didn't actually write this in here. Python was smart enough to say, Take whatever this is and oh, okay, there's a couple of curly braces in here, so let's go ahead and apply whatever courses to this so we can also changes to anything. Rerun this, and it says the course you were in is anything. It's all just undo that. No, that's prior to Python 3.6. You'll see that quite a bit in python 3.5 now. You can also do this with variables. So you could say, Ah, greeting is equal to welcome person's name. You are sitting in the course name and we could do format. Welcome. Let's say, Caleb and the 2nd 1 in here because this first one's going to match up with this first parameter. This method parameter and the 2nd 1 in here is going to be the 2nd 1 and that one's going to be course. And when I show you greeting it says, Welcome, Caleb, You were sitting in python for everybody and again, that's very popular. Be four python 3.6. Now, just to show you which version of Python amusing, I'm going to use a command here, right on the command line. Python 3.7 point two. So I have placed on 3.6 and newer, and there's a better way of doing this in Python 3.6 and newer. And it's this idea of an F string F strings and so on. F string really is just starts with the letter F and then you have some sort of string in there, and you could say anything you want now by default. This is going to work totally fine. The nice thing about F and you can think about this as a shortcut for the word format is you can put your variables directly in here. You don't have to use dot format or anything else. You can just say, uh, let's use a different sentence. Hello Name? Welcome