30 Days of Python: Coding for Beginners | Tony Alamo | Skillshare
Search

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

30 Days of Python: Coding for Beginners

teacher avatar Tony Alamo, Spark Your Brain

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

    • 1.

      Introduction

      3:28

    • 2.

      How The Course Works

      2:26

    • 3.

      Day 1 - Install Python (Mac)

      14:41

    • 4.

      Day 1 - Install Python (Windows)

      11:59

    • 5.

      Day 2 - Variables

      11:39

    • 6.

      Day 3 - Strings

      9:23

    • 7.

      Day 4 - Functions (1/2)

      10:01

    • 8.

      Day 5 - Rest Day :)

      1:02

    • 9.

      Day 6 - Object Oriented Programming (OOP) - Methods

      6:52

    • 10.

      Day 7 - String Concatenation

      11:52

    • 11.

      Day 8 - User Input (Numbers, Integers, Floats, Comments)

      9:15

    • 12.

      Day 9 - Conditionals (if/elif/else) and Code Blocks

      13:33

    • 13.

      Day 10 - Rest Day :)

      1:12

    • 14.

      Day 11 - Functions (2/2)

      9:21

    • 15.

      Day 12 - Lists, Ranges, Sorting

      19:59

    • 16.

      Day 13 - Loops

      13:46

    • 17.

      Day 14 - Dictionaries

      11:18

    • 18.

      Day 15 - Rest Day :)

      0:47

    • 19.

      Day 16 - Tuples and Sets

      15:18

    • 20.

      Day 17 - OOP - Classes Definition

      13:15

    • 21.

      Day 18 - OOP - Class Attributes and Methods

      21:00

    • 22.

      Day 19 - OOP - Inheritance

      11:20

    • 23.

      Day 20 - Rest Day :)

      1:22

    • 24.

      Day 21 - Files

      11:41

    • 25.

      Day 22 - Exception Handling

      12:26

    • 26.

      Day 23 - Modules and Python Standard Library

      14:55

    • 27.

      Day 24 - Project - Python Learning App (1/5)

      18:16

    • 28.

      Day 25 - Rest Day :)

      1:16

    • 29.

      Day 26 - Project - Python Learning App (2/5)

      8:47

    • 30.

      Day 27 - Project - Python Learning App (3/5)

      7:55

    • 31.

      Day 28 - Project - Python Learning App (4/5)

      4:58

    • 32.

      Day 29 - Project - Python Learning App (5/5)

      4:37

    • 33.

      Day 30 - Endings Are New Beginnings

      0:48

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

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

3,783

Students

16

Projects

About This Class

What is this class about?

This class is designed to show you how bite-sized lessons can lead to significant progress! Most people tend to overestimate what they can accomplish in a single day but often underestimate what they can achieve in just 30 days.

Python stands out as one of the most popular and versatile programming languages available. Throughout this class, you'll acquire the essential knowledge required to write your Python programs. The course is structured to span 30 days, with daily sessions lasting approximately 15 minutes each. You will grasp the fundamental concepts necessary to embark on coding your own practical applications, laying a strong foundation for exploring any programming fields you might be interested in.

Python's remarkable flexibility allows its application in a wide range of domains, including Artificial Intelligence, Machine Learning, Data Analytics, Data Visualization, Web Development, Software Programming, Finance, and even Game Development! Beginning with basic Python concepts such as variables, this course will progressively guide you towards your final project: developing your Python command-line application. This project will integrate all the concepts you've learned throughout the course, helping you connect the dots effectively.

Who is this class for?

Learning how to code can be valuable for everyone, even if you're not looking to use it professionally. It broadens your understanding of the digital landscape that surrounds us nowadays. This class is right for you if any of the following statements resonate with you:

  • I’m completely new to coding. Where do I type my very first line of code?
  • I learned to code in the past but I’m looking for a refresher.
  • I’m looking to demystify coding and get a sense of what it can be used for.
  • I want to set a strong foundation to get a job related to coding down the line.
  • I want to stretch my brain by learning something new.

How will I learn?

The course is designed to be taken through 15-minute bitesize lessons each day for 30 days, and it focuses on learning smart and not hard. You can go through it at your own pace, so if you'd like to do two lessons each day and finish the course in 15 days that is fine, and if you'd like to take it more slowly that is completely fine too.

We’ll leverage evidence-based learning techniques such as Active Recall and Spaced Repetition to enhance your learning and commit the knowledge you gain to long-term memory. We have hands-on daily exercises that will help you internalize what you’re learning and even rest days to recover and review. All in all, this is how it goes:

  • 15 minutes/day for 30 days (you choose your pace)
  • Follow along with each lesson as we go
  • Daily exercises to implement new learning
  • Rest and recovery days after every 4 lessons
  • Final project to connect the dots

What type of software will I use?

We'll kick off the course by downloading and installing the necessary software:

  • Python 3
  • iPython - an enhanced Python interpreter
  • Visual Studio Code - a popular and powerful code editor

Course Contents:

  • Installation
  • Variables, numbers, strings, string concatenation, indexing
  • Conditionals, code blocks, For loops, While loops
  • Lists, Ranges, Dictionaries, Tuples, and Sets
  • Functions
  • User input
  • Intro to Object-Oriented Programming (OOP)
  • Classes - definition, attributes, methods, inheritance
  • Files
  • Exception Handling
  • Modules and Python Standard Library
  • Hands-on Project - Python Learning Application

Meet Your Teacher

Teacher Profile Image

Tony Alamo

Spark Your Brain

Teacher

Hey, there! I'm Tony :)

Right after I graduated as an engineer in Boston, I jumped right into Data Analytics - starting off at a startup accelerator in Cambridge, MA, where we worked to start web companies from scratch and launch them into the world!

Even though this was super exciting work, I eventually decided to focus my attention on what I'm most passionate about - learning how to learn and teaching others how to do the same.

Most of us were never taught that the brain's structure can change based on our experiences, and learning is one of the best brain exercises there is!

I hope you find my Skillshare classes, YouTube videos, and other sharing platforms helpful, and that you join me on my journey to wake up and live a more meaningful life in the pr... See full profile

Level: Beginner

Class Ratings

Expectations Met?
    Exceeded!
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

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

Transcripts

1. Introduction: Hello, my friend, my name is Tony and I've been working in Python for a while now. And it also happens to be the, up until last year, I worked on Internet Venture Accelerator in Boston, where I worked on coding related projects aimed to start where companies from scratch and lunch them out into the real-world. That was exciting work, but I'm even more excited to say that I recently party ways with that job to pursue what I'm genuinely excited to wake up every morning to, which is learning how to learn and teaching others how to do the same. That is what brings me here today and also to my YouTube channel in this programming course will work smart and not hard world dive deep and focus for only 15 minutes each day. For 30 days, there will be daily exercises for you to learn by doing more, even have rest days every four sessions for you to internalize why you're learning. And finally, we are going to have our final project in which your code and your own Python application. You'll learn the skills you'll need to write your own Python code. Some of the things we'll look into our variables and data types, such as strings, numbers, and lists. We will also look into functions, conditionals and even object oriented programming and much more. And even aside from Python, we'll touch on one of the key techniques and concepts related to accelerated learning, such as active retrieval and space repetition. And all of these might not make a lot of sense right now, but we'll learn what those are throughout the course and you'll be able to connect the dots in the final project in this course is meant for anyone who doesn't even have a clue about what programming or coding even, or anyone who has learned how to code in the past and simply needs a structured and refresher if you're looking to learn how to code to eventually get high-paying jobs. And developer are looking to automate repetitive tasks to earn yourself some more time, or are here just out of curiosity and seeking to learn something new just for the sake of learning, then this is the right course for you and the only tools you'll need our computer and willingness to learn the way island Python was way harder than it should've been, mostly because they had no structure and I did it all on my own. And discourse is exactly what I wish. I would've had it the day I tried to write my very first line of code, a structured step-by-step process taught by somebody who not only knows how to code very well, but most importantly, someone who knows how the brain works and how to use scientifically proven techniques to accelerate the learning process. You've chosen an excellent programming language to start with because Python is a very popular coding language around the globe, as I mentioned throughout this course, you will build your own Python application in the final project in which the app will use all the tools we learned throughout the course. And it will quiz you on any topic that you want to study. And it will keep your scores so you know how well you're doing in each topic. And when you come back, you know, what are the weak spots you need to work on. The final product will be critical for connecting the dots and what you learned. And that is why it's really important for you to stay consistent and take small but delivered steps to complete the 30 days. Because each day will be like grabbing a paintbrush and painting up well-thought of and delivered dot into Canvas. It won't make complete sense when you step back and look at the canvas right away. But over time, simply by coming back and painting each additional dollar in the Canvas deliberately and consistently, you will eventually stepped back and you will be amazed when you finally see with clarity what he had been working for. All the ones. Like Steve Jobs once said, the dose will only connect in hindsight. So remember that it keeps coming back with nothing else to add today. I really hope you decide to give this a shot and have a good feeling or see you very soon. 2. How The Course Works: Welcome programmer to learn Python in 30 days. I am so excited to have you here in the EOB coding and you know, time. So you're probably wondering how this is going to work in more detail in this course, we're going to have 30 daily lessons that will take up around 15 minutes to complete. We even have rest and recovery day 74 lessons in these, there won't be any new material and they're meant to give you a chance to recover and review previous sessions you think you might be worth revisiting. We got a different pace. So you might even find that it works better for you when you do two lessons each day. And that would mean that you would finish the course in 15 days instead of 30 days in half the time. And that is totally fine if that works for you, it just makes sure that you're not crowding the knowledge and that you're taking your time to internalize and digest what you're learning. So that's why I wouldn't recommend taking more than two lessons each day. There's a Chinese proverb that says y here. I forget what I see. I remember, but what I do, I understand. That's why this course is focused on hands-on learning. I want you to experiment as much as you can with everything that you learn every day you're going to be able to follow along with what I do on screen. And at the end of each lesson, we even have exercises for you to do and start coding right away what you learned back then, you'll see somewhere under screen, likely to the right, a list of all the videos clearly labeled and numbered with each date are meant to be taken. There should also be likely at the bottom, a message section where you can post messages and comments or questions for anyone to see so we can help each other out. There are also tools that you'll see in the video around the screen that works similarly to other video platforms that you've already used. One of the most useful ones might beat the playback speed button. This will allow you to speed up or slow down the video as you wish. You might also find throughout the course that I speak at a relatively slow pace this on purpose because this button gives you the flexibility to change the speed to whatever works best for you. And finally, I wanted to ask you to play full out on this and commit to completing the course, grab a calendar and set some time aside each day. So you will be more likely to sit down and complete each lesson. I've already put in half the effort by creating this course for you, but this won't work for anything unless you put in the other half of the work. So I invite you to come back and have funny state, ready to focus and ready to learn without further ado. Let's do this. 3. Day 1 - Install Python (Mac): Welcome my friend into learn Python in 30 days, and today is day one. Today we have some objectives and the main one will be installation. This video specifically is for Mac OS installation. Make sure that you're using a Mac. If you want to watch this video, if you have a Windows computer, you can go to the equiva***t video that you'll see on the video list which says installation for Windows. Looking at the other objectives, we have to look into the biggest obstacle to learning. We need to understand what the biggest obstacle to learning is, we can tackle it. We're also going to understand how our questions, the answer. Next we're going to move into installing Python and what we need to make our lives easier. So a couple of other things we'll need to install. And finally, we're going to end by verifying the installation and printing our first commands into the screen. Let's move on to the learning section. Okay, so the biggest obstacle to learning is the belief that you already know it. And that is a sense saying, once we lower that barrier of thinking that we already know something, we open our minds up into learning new things. Next, we need to know that we need to be open minded in order to learn. Because the mind only works when it's open. It's like a parachute. It is really important for us to keep asking questions. If you have questions throughout the course, write them down because it's very likely that we answer those questions later on throughout the course. Another advantage about asking questions is that when you ask a question, you prime your mind into seeking the answers. Whenever the answers come along, you will be that much more prepared to absorb them. Think about this elephant. It's limiting belief is that it can't free its leg because it failed when it was little, but never questioned this belief again. Even after it grew strong enough to free itself by constantly asking questions instead of settling for answers, we are more likely to break limiting beliefs. If you've ever thought that you can't learn how to code, this is a good time to start questioning that belief, because what happens to your brain when you ask a question? It engages with the question right away and starts thinking about possible answers right at that moment. This means we can think of questions as being a live answers in the present moment. On the other hand, once you assign an answer to a question and take it at face value from then on, the fixed answer might prevent you from seeing more of the whole picture. This is why questions are the answer. Keep that in mind and let's move on to installation. So the first thing we're going to do is that we're going to go into our browser and we're going to Google download Python. We're trying to get to the Python.org website. And once you get here, you're going to go into download section. You're going to click download for Macos. Then you're going to open that file that gets downloaded and that will open the installer. You're going to click on Continue and agree on all of these. And once you click Install, that will be installed in your computer and you'll see that folder that you just installed with the Python software. Next, you're going to wait for the install to finish, and then you're going to close and move the installer to the trash. Congratulations, you have just downloaded Python into your computer. The next thing that we're going to do is that we're going to open up our terminal. I'm going to use command space and then type in terminal. The terminal is super useful when we want to interact with our computer through the use of written commands. Here we can operate with files and we can navigate folders the same way that we use Finder for example. We can use our terminal for this. One thing that we can use the terminal for is to verify that you have installed Python correctly. For that, we simply run Python three space version and press Enter, and you can see that you have Python three installed. Another thing that you can do with your terminal is that you can run Python. To do this, we simply enter Python three and Enter. What this does is that it simply opens up Python's default interpreter. This interpreter is what's called the Repl, REPL which stands for read, evaluate, print loop. This simply means that the environment will read and evaluate our commands and then it will print them to the screen. And do this in a loop. The first function and the first command that we're going to learn in Python is the print function. For this, we simply write print open, round bracket, and then between quotes. And you can use single or double quotes, whatever you prefer. Here you write down some text. In this case, we're writing down Hello World. And then you close the quote and then close the round bracket. When you hit Enter, you'll see hello world or whatever text you put into the print function printed on the screen. Finally, when we want to exit the Python's default interpreter in the environment, we simply write down quit and round brackets and press Enter. The next thing we're going to install is going to be Python. Python is simply another Repl and another Python environment. Very similar to Python's default environment, but it has more functionality and it is an enhanced version of this default environment. To install Python, we're going to use pip. The command is the following, it's going to be pip three, install Python. If this doesn't work, you might have another version of pip. So you could use Pip without the three and then install Python and that should work. What Pip is, is that it is a Python Package Manager. It manages modules that we can download from the Internet into our computer. And we're going to look into modules later on in the course. So when we press Enter, we see that it gets downloaded into our computer. And for me, in my case, I already had it downloaded. So your screen might look a little bit different and it might take a little bit longer, but that should work just fine. Now to run Python, we simply type in Python into the terminal and press Enter, and that would open up Python. And we now have another repel environment that's similar to a default environment as I mentioned. And we can use the same print function as before. So break down, print hello world, Enter, we'll see hello world printed on the screen. Then to exit Python, you simply type in Quit and Enter. And that will take you back to your terminal. The next thing we want to download, and the last thing we're downloading is VS code or visual studio code. For that, we simply Google download Visual Studio code that should take you to the website. You're going to download the version for Mac. What VS code is, it is simply a code editor. The same way that you might use Microsoft Word to write your essays or anything you want to write. You would use VS code to write your scripts. It has functionalities that will be super helpful when we're writing our code. So you would download VS code as you would any other application. Right now we have this zip file that when we open it, it would take the application into my download folder. I simply move that into my Applications folder and I'd be ready to open up visual studio code using command space. Here we can click on Open. That would open up the application, make that full screen. And we can close these tabs, we can move on to creating a new file. In file. New file. And then it's simply a text file right now. So we can write the same command as we did in the Python interpreter. Print hello world. We can do file, save as, and then save that as. I'm going to name it Hello World. And I'm going to keep it in my desktop and make sure to add they extension which tells the computer that it's a Python file. Allow VS code to access the folder you're trying to save it at. Now you have a saved Python script. One really cool feature that VS code has is that it has extensions. For our case, we're going to want to download the Python extension. I already have it downloaded. But in your case, you might have seen a pop up message whenever you try to save the py file, recommending for you to download the extension. Or you could simply go into the extension section and you can look up the Python one and you can download it. And that would apply to your Python files automatically. Okay, so let's say that we have our file that we saved our script that we saved and we were to open VS code and we're trying to find that file. Now in this case we can go here in the following, we'll try to open a folder. I move that file into my desktop and then into the devel folder in my desktop, which stands for development. And I'm just going to open that folder up. We can see that we get this get started tab, which we can close, but then we'll have the folder right here on the left. And we can just click on the file that we saved, which is our script. And it'll open up in the code editor. Now if we wanted to run this script, we could go to our terminal. So I'm going to do command space terminal to open up my terminal. Then we're going to have to learn a couple of commands before the terminal which are going to be super useful. The first one is the PWD command, which stands for print working directory. What this does in the terminal is that it tells us exactly where we are. We can see this is the file path to where we are. We're under the users Antonio Alamo and then desktop folder right now. Then there's also the LS command which stands for list and it lists of the files that are in the current folder. Here we can see everything that's under our desktop. This would be the equiva***t of going into Finder and saying, okay, let's see what's in our desktop. And then we see that we have all these files. We can see the same on our terminal. Now another useful command is the C D command, which stands for change directory. For this one we do CD, then do space, and write down the directory where we want to go. In this case, imagine we want to go into the devel folder. We could say users Antonio Alamo, desk top and then devel, I'm using the tab for the completion of the folders. Now we could press Enter. And when we do print working directory, we can see that we are in the development folder right now, when we do LS for list, we can see the files that are under the current folder and the working directory that we're at right now. An even more useful command to learn is the CD. And then instead of writing down the absolute file path, which is what this is, we can print a relative command. We can say full stop, Full stop. And then press Enter, and this means go to the previous folder. Now you can see that when we do print working directory, we went one step backwards. We're now at the desktop instead of the devel folder, now we do LS and we see the same thing. And then we can go back, change directory to the devel folder and go right now because you don't actually have to write down the absolute file, You can also write the folder depending if it's in the current directory. Now that we're in the devel folder, we could do LS and we see that we have the hello world script. If we wanted to run that script, we simply run the following command, which is Python three space, and then the script that we want to run. And then when we press Enter, we see that we're running the script. And the commands or the lines that are under that script are executed. And we can see Hello world printed to the screen. Visual Studio actually provides that service for us. We can go to terminal and click on New terminal and we can see the same thing. It's a terminal four VS code specifically run the same command. We can do print working directory and we can see that we're under the devel folder right now. If we wanted to go back a step, we could do change directory to the one above and we could see that we're under desktop. If we do LS, we can see everything that's under our desktop. We could go even further back if we wanted to, but we can also go back to our desktop, change directory, and then change directory again to our devel folder. Another useful command is to clear command simply to clear the terminal so we can get it real clean. Then we can run the LS command again to see that we're under our devel folder and we can see our hello world Do script. If we wanted to run this script, we can simply run Python again. Three, hello world. And we can see hello world printed to the screen, everything within VS code. Finally, the last way we're going to see on how to run this file is using a VS code function, which is just clicking the play button right here on top, on the top right of your screen. And you can see that the hello world script runs. We can try that again, clear the screen and we can say the play button. And then we can see that the script is. So that will sit for today's learning section and we're ready to move on to the recap. We learned that we need to be open minded if we want to learn fast, and that we need to ask a lot of questions and understand the importance of questions and how questions are the answer. We also moved on to install Python three into our computer, and also Python as well as visual studio code. Visual studio code is the code editor. Finally, we ran our first Python commands using the print function. Now let's move on to the understand section. The understand section each day is going to be where we do our hands on learning. We're going to ask questions here, we're going to have some exercises we can do with our Python. And now for today, the first one is how are questions the answer. So I want you to answer that question and think about that question. Next, I want you to print the version of Python you have installed into your screen using the terminal. And then print your name using Python's default interpreter. That would be using the print function, and then print your name and other words using Python. Finally, print your name by running a script with the py extension. I would recommend using VS code for this and saving that file. That will sit for today guys. Thank you all so much for watching. Remember, if you have any questions, post them in the comments below so the community can help. And I'll see you back here tomorrow. 4. Day 1 - Install Python (Windows): Welcome my friend into learn Python in 30 days. And today is day one. And today we have some objectives and the main one will be installation. And this video specifically is for the Windows operating system installation. Watch this if you're working on Windows and if you have a Mac operating system, you can go to the equiva***t video that you'll see on the video list that says installation for Mac. So looking at the other objectives, we have to look into the biggest obstacle to learning. We need to understand what the biggest obstacle to learning is so we can tackle it. And we're also going to understand how our questions, the answer. Next we're going to move into installing Python and what we need to make our lives easier. So a couple of other things we'll need to install. And finally, we're going to end by verifying the installation and printing our first commands into the screen. Let's move on to the learning section. Okay, the biggest obstacle to learning is the belief that you already know it. And that is a sense saying, once we lower that barrier of thinking that we already know something, we open our minds up into learning new things. Next, we need to know that we need to be open minded in order to learn. Because the mind only works when it's open. It's like a parachute. It is really important for us to keep asking questions. If you have questions throughout the course, write them down because it is very likely that we answer those questions later on throughout the course. Another advantage about asking questions is that when you ask a question, you prime your mind into seeking the answers. Whenever the answers come along, you will be that much more prepared to absorb them. Think about this elephant limiting belief is that it can't free its leg because it failed when it was little, but never questioned this belief again. Even after it grew strong enough to free itself by constantly asking questions instead of settling for answers, we are more likely to break limiting beliefs. If you've ever thought that you can't learn how to code, this is a good time to start questioning that belief. Because what happens to your brain when you ask a question? It engages with the question right away and starts thinking about possible answers right at that moment. This means we can think of questions as being a live answers in the present moment. On the other hand, once you assign an answer to a question and take it at face value from then on, the fixed answer might prevent you from seeing more of the whole picture. This is why questions are the answer. So keep that in mind and let's move on to installation. To download Python, we're going to open our browser and we're going to search for download Python. We're looking for the Python dot website, Here it is, right under the download section. We're going to click down here, underneath Download for Windows. And that is going to download a file, which we're going to open as soon as it finishes loading. That will start the installation. We're going to check this box where it says Add Python two path. We're going to click on Install. Now a way for that to load. And then we can close this. And now we have Python installing a computer. The next thing we're going to do is that we're going to open up our command prompt application. This application works as a terminal between us and the computer. The terminal is super useful when we want to interact with our computer through the use of written commands. Here we can operate with files and we can navigate folders. We can use our terminal for this. One thing that we can use the terminal for is to verify that you have installed Python correctly. For that, we're going to run Python version, and that would print the version of Python that we have right now. Another thing that you can do with your terminal is that you can run Python. To do this, we simply enter Python. And enter what this does is that it simply opens up Python's default interpreter. And this interpreter is what's called the repel REPL, which stands for read, evaluate, print loop. This simply means that the environment will read and evaluate our commands and then it will print them to the screen. And do this in a loop. The first function and the first command that we're going to learn in Python is the print function. For this, we simply write print open round bracket, and then between quotes. And you can use single or double quotes, whatever you prefer. Here you write down some text. In this case, we're writing down Hello World. Then you close the quote and then close the round bracket. When you hit Enter, you'll see hello world or whatever text you put into the print function printed on the screen. Finally, when we want to exit the Python default interpreter in the environment, we simply write down quit and round brackets and press Enter. The next thing we're going to install is going to be Python. And Python is simply another Repl and another Python environment. Very similar to Python's default environment, but it has more functionality. And it is an enhanced version of this default environment. To install Python, we're going to use pip. And the command is the following. It's going to be install Python. What pip is is that it is a Python package manager. It manages modules that we can download from the Internet into our computer. And we're going to look into modules later on in the course. So when we press Enter, we see that it gets downloaded into our computer. And now to run Python, we simply type in Python into the terminal and press Enter. And that would open up ipython. And we now have another Repl environment is similar to a default environment as I mentioned. And we can use the same print function as before. So write down print hello world, Enter and we'll see hello world printed on the screen. Then to exit Python, you simply type in Quit and Enter, and that will take you back to your terminal. The third and final thing that we're going to download is going to be visual studio code. For that, we'll search, download visual studio code or VS code. Then we'll go into the Visualstudio.com website and we'll look for the Windows option. Next we'll be like downloading any other application. We'll simply click on this file that we've downloaded and it'll start the installer. We'll click Accept the Agreement. Click Next, and then click on Next. Next again, and finally, Install, and wait for the installation to finish. Now we have VS code installed in our computer. Once we get into VS code, we can close that Get Started tab and we can hit File, New file. This would bring us to a default text file. And we can simply write the same code that we wrote on the Python interpreter. Print hello world. Next we can hits and give our file a name. And make sure that we save it as a file, which will tell the computer that it's going to be a Python script. Once you save the file, VS code is going to ask you if you want to download the extension for Python, we're going to install on that. And that'll take a second. Then you have the extension installed. This extension will be useful for us when we write Python code because you'll have some features that will make it easier for us to write code in. Now let's say that you're opening VS code from scratch and you want to find your hello world dot file. What we do is that we open folder, hit and open folder and we look at the folder where we have it for me. It's the devil folder for development. I open that folder up and you can see in the left you have the explorer with that folder and the contents. And at the right you have the editor. So now that we've clicked on our hello world file, we can see it on the editor. What if we wanted to run this file? One option is to open the command prompt, and we're going to learn some super useful commands for the command prompt. The first command is CD, which stands for change directory. If you enter it by itself, it gives you the current directory or prints the working directory. But if you do CD space and then a different folder, it will take you to that folder. In my case, the helloworld file is in the development folder. I change directory to the developing folder within the one that I was currently at. That moves me to the folder that I want. Another command would be the IR for directory, which will list the contents of the current directory. Here we can see that we have the helloworld file as well as the text files folder. And it's the same thing that we see on VS code. If we wanted to move into the text files folder, we could do change directory text files and then do DIR, we can see that we have a couple of text files and it's the same thing that we see on VS code. Another command would be the CD. Full stop. Full stop. And this will take you one step backward in the file structure. You would go back to the devel folder. Since we know that the script that we want to run is in this folder, we can use the command python space and then the name of the file that we want to run. And press Enter, and we can see that that will run the script. One last command that is super useful is a CLS command which clears the screen. It also turns out that VS code has a built in terminal. As a feature we can, we can click in Terminal and then open up the terminal. This will work exactly as the command prompt. We can use CD, we can change directory into the text files folder. We can do DIR to see what's in it. We can go back one folder. We can do DIR to make sure that we went back. And then we can use a Python command to execute our script. And finally, there's an even more straightforward way to run the script, which is by clicking Display button at the top right of the screen. And you see that the script has run at the bottom. That will sit for today's learning section and we're ready to move on to the recap. We learned that we need to be open minded if we want to learn fast, and that we need to ask a lot of questions and understand the importance of questions and how questions are the answer. We also moved on to install Python three into our computer, and also Python as well as visual studio code. Visual studio code is the code editor. Finally, we ran our first Python commands using the print function. Now let's move on to the understand section. The understand section each day is going to be where we do our hands on learning. We're going to ask questions here, we're going to have some exercises we can do with our Python. And now for today, the first one is how are questions the answer. So I want you to answer that question and think about that question. Next, I want you to print the version of Python you have installed into your screen using the terminal. And then print your name using Python's default interpreter. That would be using the print function, and then print your name and other words using Python. Finally, print your name by running a script with the py extension. I would recommend using VS code for this and saving that file. That will sit for today guys. Thank you all so much for watching. Remember, if you have any questions, post them in the comments below so the community can help. And I'll see you back here tomorrow. 5. Day 2 - Variables: Welcome my friend into day two, and we're going to start with today's objectives. The first one is going to be that we're going to look into Python variables. Next, we're going to look into one key to learning than Python objects. And finally, we're going to meet our new best friend. But for now, this jump right into a learning section. In this graph, we see a plot of progress over time. We can see that our expectations tend to be linear while reality is exponential. In the beginning, reality may be slower than our expectations. And this is what we're calling the value of disappointment. And you can read more about this in James feels book Atomic Habits. Now, most people quit at this stage before realizing that learning can be exponential and that eventually reality drastically exceeds expectations. Consistency is important because without it, we wouldn't overcome the value of disappointment. So that is why one Q-learning is consistency always come back because daily increments compound over time and lead to long-term exponential growth. If each day you improved by 1%, that would mean a more than a 37 x improvement after one year. What if I told you that you could make habit out of this bite-size efforts and make them feel like a briefs and even end up enjoying them. And that's what I aim to do with this course, to hopefully show you that learning can be fun and that we can grow each day by enjoying the process. The big problem with not being consistent is that if you decide not to come back, you won't reap the rewards of what you saw. It would be like making all the efforts to plant and grow an apple tree. And then now coming back to collect the apples. In the course, we're starting off slowly on purpose and we'll progressively accelerate each day. If you think this is going to slowly or if you're finding it too hard, remember that it's intended and that bite-size efforts plus patient's plus consistency equals long-term exponential growth. With nothing else to add on this today, Let's move on to variables. Now, we'll go into the Python topic of today. We're gonna go into variables. A variable is simply a reserved memory location to store a value. That's what a variable is. And we give a variable user-friendly name to help us know what kind of value they store variables allow us to get a value and refer to it again later by just referring to the variable name to look into this and dropping off their terminal here. What I did was Command Space and then just type in terminal and it takes me to a terminal application. No-one do Command Plus, Plus, Plus a couple of times just to make it make it more visible, non-linear, I'll go into IPython. Clear the screen just so we don't have anything in there. Awesome. So to declare variable, we use the equal sign. If I want to say my variable, for example, and I want to say, this is the value. Now whenever I refer to, whenever I refer to my variable, it's going to reference the value that it's into that variable and store it into that variable. Let's say I wanted to find variable with my player. Then if I did it, my player, I could print Ronaldo would say Rinaldo. Now let's say that I want to assign the value. I want to keep it the same variable. What I want to change the value that I have into that variable. I will just simply reassign it. Messy. Let's just say my player is messy. So whenever I do print my player again, then it's gonna be saying messy, which is the new value attached to that variable. What if we tried to reference a variable that we haven't defined already? Because we know that in my player is already defined. But let's say that we tried something like my var. What do you think would happen here? Whenever we try to do something like this, we would get an error because we haven't defined it yet. This is what an areas, this is what I mean that you would get to meet your new best friend. And I'm telling you that your new best friend our errors just because whenever you get an error, that means that you're pushing your comfort zone and you're learning something new. You want, you want failure to tell you, to come and tell you, Hey, you're failing at this because you're trying to learn something new. This is how we read in there and we get the error type, which is a name error in this case. Then we get the error message which has name myVar is not defined. So that's how we would read this error. And we'll look into errors more in depth later in this course. But I just wanted to introduce to you to your new best friend that tells you that you're pushing your comfort zone, that you're learning something new. But another thing that we're going to look into today. That everything in Python is an object. We'll learn more about that throughout this course. But for today, all you need to know is that every object has an identity. I mean, object has a type, there'll be object has a value. The important thing about the identities that once an object is created, the identity doesn't change. To look at the identity of an object, we use the ID function. That is, it's usually like this. We're looking to what a function is in a bit and then other day throughout this course. But the important part here is that let's see how we have a variable, variable one just equal to one. We wanted to see the ID of variable one. We would, we would do ID variable one and that would give us the id number of that variable. We can think of this number as the address in memory of that, of that variable. But for example, if let's say we wanted to create another variable, variable two, and we wanted, we could set that up equal to a variable one. What would happen if we reference the ID variable, variable two? We would get the same number even if we're looking at a different variable name, both variables are referencing the same object which is located at this ID name variables are referencing the same object. We can use an operator called the operator. For example, instead of having to check each individual ID and see if we're getting the same number back. We could do variable one. Variable two. We're going to get a value return back, which is going to be true if they are referencing the same object. Just wanted to be false if they are not referencing the same object. For example, if I create a third variable saying this shrinking string, and then I said a variable one is variable three, we would get false. Again. We're going to look into these types of variables later on in this course. But for now, the important part is this operator in to understand that the ID is pretty much like an unique number for each object. And you can think of BID as being the unique address in memory of the object that you're referencing. We already know how to look at the ID variable, how to look at the the value of a variable like this. So variable one, variable two, variable three. Now we're going to look into how to look at into the type of the variable. And that is simply by using the type function. We did type variable one would get what the type is, the same for variable to what the type is and the same for variable three, what the type is. Now we're going to look into these later. For now we can see that the first two are int for integer, and the third variable is STR, or string. And again, we're going to look into that later on throughout the course. But for now it's important to seek to understand that the type function returns the type of the object that we're passing in. And finally, let's talk a little bit about variable names. Variable names are case sensitive and by convention they are all lowercase. They must start with a letter and can contain numbers, but not as the first character. You can also use an underscore. Some examples of variable names are the ones that we've used already, or let's say name could use this var name. You can see the return value you can use also like last name as an example of an underscore name. You can do animal, country 123, whatever, whatever number you can simply, the only thing you can't do it start with a number. By convention, get started with letters and on lower score. So one Cuba learning remember is consistency. Always come back because you'll be surprised if you stick to it. And we want to make sure that we go over that valley of disappointment. And the only way we can do that is by always coming back. Next. We learned that everything in Python is an object. And optics have a type and unique IDs and a value as well. You can find out what the type is and what the idea is with these two functions. Useful, then variables are simply labels that point to an object that lives somewhere in the memory. And you can use the is operator to see if two variables point to the same object. This is what we talked about. If they have the same IDs, that means that they're the same object, then you can use the exalt period or to look into that as well. We also learned that variables are case-sensitive and all lowercase by convention. And they will start with a letter and can contain a number, but not as a first character. And finally, we learned that failure is your best friend. And if you're not failing, it means that you're not pushing your limits. You want to make sure that you're seeing that red errors come up because that actually means that you're learning something new and that's actually great. Today's understand section. The first one is, what is one key to learning? Second question is define different variables and print them onto the screen. Third is use the is operator to see if two variables are the same. Then finally use the ID and the type functions to get the ID and the type of objects respectively. And try this with a string like this, and with a number like this. These are the four questions for today. And good luck with this. And if you have any questions, don't hesitate to ask in the chat section and we'll be active there with a community there. Good luck and I'll see you tomorrow. 6. Day 3 - Strings: Welcome to day three. The first objective for today is to look into the forgetting curve and why we do bite-size sessions each day. Then we're going to look into strings, string indexes, strings and variables. And finally, we're going to look into how to print strings to the screen. It turns out that there are studies that say that we forget between 70, 80% of what we learned within 24 hours of learning it. That's why cramming for an exam, learning everything that day before, pulling an all nighter and then splitting everything out into the exam might seem to work for the exam. But you might notice that most of what you learned simply disappears after. Fortunately for us, we're learning the smart way here since we know how we can crush the forgetting curve and make what we learned stick. We can learn much more effectively by revisiting the concept we learned multiple times over increasingly longer periods of time. This is what's called spaced repetition, and this is why this course is strategically designed the way it is 15 minutes of deliberate and focused learning each day for 30 days is considerably better than the equivalent 7.5 hours in a single day, which would be cramming. Cramming is not effective because your brain will not absorb. And remember nearly as much information compared to spread out bite-sized sessions. When you revisit where you learn over time, your brain considers that information as important and strengthens the neural connections related to that learning with the purpose of making the job easier and reducing work. Next time it comes around, think about this. Neurons that fire together, wire together, but this will only happen after some quality rest and recovery. This means that if you learn something today and then come back another day soon later after sleeping well, eating well, relaxing and exercising. You'll notice how when you come back you're doing things considerably better than last time. And now let's move on to strings. Strings are objects meant to represent text in Python. In the previous exercise, wherever the text variables that we assigned, those who are all strings. To create a string, we can use either single quotes or double quotes. For example, we can say string one equal two. Is a string. This would be with single quotes. We can see we assign that variable to stream one. We could do strength too. This is another string with double-quotes and we can use it in the same way. So it's the same thing. We can see the directors and other string. Just make sure to stick with such that if you use some single quotes, keep it consistent in your code. If you're using double-quotes, keep it consistent with what if you wanted to use quotes within a string? Let's say you wanted to save it with the word your. You enclose STR, string one. Let's say that you do that. Your, you see that this doesn't work because the things that you're close in the string. So to avoid this, we can make this work. We can simply add in the escape character, right before I did quote Python nodes and it will escape, that quote, won't take it into account. And then it would, it would use it as a text literal and add it to your string. Whenever we print string one, we can see that it's Your. We could also use double-quotes to avoid even having to use a backslash. So we could say string one, your equal to your. And that way. You can also get the same result without needing to use the escape character. But what if you had a quote within a quote? For example, if you say, I said, you're the best, then in this case, you would need you will need a close and character. You would need a backslash here. Then when you print string one, you would get the string that you are intending to get. She said, Hi, You're the best. Now let's talk about string indexing for a second. That's yeah, For example, you have a country that has a string, New Zealand. New Zealand. Now, you can call each, each letter of the string is going to be an index in that string. You said country and you're gonna call the index with the square brackets format. So if you say country. Is 0. Going to reference those Z index with the reference 0 on that string. In this case it's Dn because it is zero-based reference country. Let's do a single sample that's above a reference one. You would get the next index. If you're finished three, the next one which is a space, and so on. You could also even use negative index indexes. We have our variable, country, which has New Zealand. Well, if we reference country, did negative one, what do you expect to get from here? Exactly? So we would get the last one, the last number. If we did negative two, we get the second last. So it's a way of start from the end. When we know that we could use a 0 to get the first value, then we could go negative one and so on. Where we could go plus one and go. Thought the next quote from start to finish or from finish to start. It's also useful to know that we can assign these two variables if you know, if you have country, let's say first letter. That's my new, my new variable. And then I could say, Okay, country. Since we're looking for the first letter, we want it to be, to be the 0 index. Then we have refers to letter, which is n. When we look at country, New Zealand, perfect, that's exactly what we're looking for. Awesome. So that was it for today's learning session. Now let's do a recap. We first learned that we forget most of what we learned when we just learned once I shown by the forgetting curve in the graph that I showed you. But we can crush that forgetting curve by implementing space repetition on our learning. And that's exactly what we're doing in this course. Next, we wanted to inner strength. We saw strings are objects that represent text in Python. You can use single quotes or double quotes to create a strings. Just be consistent to hold your code. Then to add quotes within the string we can use to keep the escape character, or also called the backslash. Strings have indexes, start at 0 for the first character. You can use negative indexes to pick the last characters and starting from the last and so on. You can assign these strings to variables, and then you can print those, those variables to the screen using the print function. Sweet. So now we're ready for the understand section for today. Now the first question is, how do we crush the forgetting curve? Next, assign a string with the text I'm programmer to a variable called myString one. Assign the same Texas before to the variable myString to, but alternate the quotes you used. You use single, use a double, and vice versa. The fourth question is the print both strings to the screen. Print the type and the ID of each string. Use the ACE operated. Find out if the variable is point to the same object. The fifth question is, create a variable called myString three. I assigning this new label, the object inside the variable myString one from step one. Hint there's no need to write any text or use quotes here, just variable names and the equal operator. Then final question is to print all three variables from step 124 to the screen and print their type in ID and compare them to each other using the operator. Write down any questions that you might have and might have that arose and consult them with your pillow tonight. Ten will review this tomorrow. You can also use the chat again. You can use the community section to ask any questions and we'll be active there. Good luck and I'll see you again tomorrow. 7. Day 4 - Functions (1/2): Welcome to Day for today's objectives are all about learning about hyphened functions. Will look into Python built-in functions. We're looking to user-defined functions. And finally, intertwined with all that we're looking to what code blocks our function is simply a reference to some code that will run whenever you call that function. Think of a function similarly to a variable. Once you define the function and give it a name, you can later use that name to call that function. So in other words, you call a function by their name, and this would execute the code inside that function. There are some functions that have already been included in Python, and we don't have to define those functions ourselves. And those are called built-in functions. Perfect example of a built-in function is the print function, which you pass in a string and it'll print it on out to the screen. But you'll need to define what the printf function will do. So that means that print is a built-in function. Other examples of built-in functions are sampled. The Len function. Let me define a string first. I can use the Len function to find out the length of whatever I'm passing in. So you can pass in a string, you know, passing it'll tell you seven because there are seven characters. Industry. Other examples of built-in functions or the type function. We've talked about this before. So it tells me, okay, It's a type string, the object that's in this variable. We can also have BID function, as we mentioned earlier as well. That tells you the equivalent of the location in memory of that variable, that object, sorry. Then we can also have their two new functions that we can use that are useful to debug, which are the function which stands for directory. Will understand what this output means later on in this course. The dear, dear for directory function. And then there's also the help function. Function gives you, gives you some no documentation. So in this example for this variable, we don't have any documentation for this. But we can, we can use the help function as well for debugging to, you could find all Python built-in function simply by looking that up online documentation. Let's see Python built-in functions. And here you go. Here I have a list of what they are and what they do. So for example, if we went to print function, we get a detailed description of what the print function dollars. We can create our own function using the following syntax. You can use DEF for def definition. And then you have the function name. And we'll call this function my function. Then use the round brackets and then a colon. When you press Enter, you'll see that if you're using ipython, it'll do the indentation for you, but you would need to add indentation in this case it's forced basis. And here it, here it would be what the code block would be. The function code block. So whenever I reference this function, this is the code that would run. In this case, I'm using the past statement because I don't want the function to do anything. I just wanted to pass. Whenever I run my function, that code runs. And it simply doesn't do anything in this case because it's simply passes non-square function that says hi and then prints name. Let's do def. Say print. Then let's say print. Run out. Whenever I do. Print tie. And you call a function using the round brackets, you'll see that the code will run. In this case, you'll see that we use the brackets, but we would not providing any attributes to that function the same way that we did whenever we did print with the print statement, we provide a string. For it to print a string. We can see that whenever we were running this function that we defined without any, without any variables, it's still runs the code that the function has. You can optionally add in doc stream to your function. You would do this like this. You create your function. Then right underneath it you add a triple quote. Then this would be the doc string. A doc string. Whereas for documentation. If you use whenever you create functions within your code, it would be useful for whoever tries to read your code to understand what the function does. This works for documentation again. Also, let's say that we wanted to use a function, but we wanted to have a value that Garmin, that go and go in to that function. For example, let's put a name and a last name. First, first name, name, and last name. And then we're going to say print. We're gonna say hi. And then first, firstName, lastName. That function will do whatever we call it My function. We can say, let's say messy. Then the function will know the firstName is a first argument, then the second name is, the last name is a second argument for that function and you can reference those variables within your function. Finally, as I mentioned before, you can use the help function to help a built-in function to look into, look into some of the variables that you have. In this case, it's the function. So whenever you use the help function, it takes you to a screen and it provides you the name of the function. The name of the attribute is a function takes in. And finally, this would be the dogs bark stream, the documentation. If you had any documentation for your function, you wouldn't be able to see it through the help built-in function. And then to exit here you press Q and it brings you back. Do I Python? I was late for the learning section. And now let's do a recap. A function is simply a block of code that will run whenever that function is called. And functions are called by their name and using round brackets like this. Python has built-in functions that are always read it ready to use. For example, the print function is first one we learned. Then we have the Len function to get the length of an object. You have the type function ID there for directory. And then the help function. You can see the Python documentation for the full list of functions, which is the link I showed you before. We can define our own functions by using DEF and my function name, round brackets and semicolon. And then the respective code block underneath that, where you have an indented code block underneath f function, which is a code that will run. We can also dot strings could that function using triple quotes. And then the help function, the built-in help built-in function gives us useful information about different Python objects which include functions. Then to define a function that takes in arguments, we can add them to the definition. Like so. We do the definition you do within the name. And then within the round brackets you add the arguments. And then you can reference these arguments within the code block or within the function that you can use. Shelf with you understand section. First question is to use a lens and the print built-in functions to print the length of this string. The second is defined a function called reading that prints any greeting to the screen. Then define a function called add that accepts two integers, adds them Princeton to excrete. And finally, used to help built-in function on your two new functions. If your function has didn't have docstrings, docstrings students and run the help function again and see the difference. But awesome. Good luck with this. And if you have any questions, feel free to ask them in the chat. And we'll make sure to be active in the community there. Thanks again and I'll see you tomorrow. 8. Day 5 - Rest Day :): Welcome back. My friend. Today is actually a rest day. We've been pushing our limits for a couple of days in a row now today what we're going to do is to settle what we've learned and rest a bit. I want you to go back to the exercises and make sure that you've internalized everything we've learned so far. And finally, I just want to remind you of the three keys to effective learning. We've seen so far for questions or the answer. Well, we know that when you become radically open-minded, you start to ask a lot more questions, which starts to get you to better answers, then it's hard to see progress in the very beginning. But if you keep coming back and if you're consistent with consistency, you'll be surprised by what you can start to achieve. And finally, we saw the concept of stage repetition. How we can crush it forgetting curve by not just familiarizing yourself with the concepts once, but instead acting on what you learned, spaced out through time. And that way we can make it's taken, learn more effectively. So that is it for today. I hope you get a good rest day for today and I'll see you back tomorrow. 9. Day 6 - Object Oriented Programming (OOP) - Methods: Welcome to day six. So today's objectives we have to see what beginner's mind is. Whenever we're going to look into object oriented programming, and we're gonna see that in Python everything is an object. Then we're gonna see that objects can contain data, attributes, and functionality as methods jump right into the learning session. Beginner's mind means approaching learning through a fresh perspective and seeing things as a beginner would. There's a sensing that goes to the base. Obstacle to learning is the belief that you already know it. So approaching learning with a fresh pair of eyes prevents you from facing that obstacle. So I invite you to come back every day to this course with a beginner's mind and so you can get the most out of it. We also know from before that python is an object-oriented programming language. In Python, everything is an object, and objects can contain data throughout attributes and functionality through methods. We've seen already, we know that objects can have a type. So if we create a variable, one that's say, equal to this string, then we can see that type of variable one. We can see that it's a string because that's what we assigned texts within quotes up here. If we wanted to print variable one, we could see the value of this object. This would be an object and this would be some data that it's attached to that object. And that's what the print function shows, that we can think of this as data attached to an object. So aside from data attached to an object, we can see that objects can also have functionality through methods. You can think of a method simply as a function that belongs to an object to call a method we use the dot notation combined with the syntax we use to call on our normal function. For example. For example, we would be my variable, my method. If we had, of course, defined a variable called myvariable and a method called my method. But for this example, let's do this, use variable one, which we have and we know what's a string. For variable one, we could use an example of a string method that's called Upper. What this method does is that it takes a string and it returns the string with every single letter capitalized. Another example is the title method. Which capital X is only the first letter of each word in the string. Finally, another example is the count method. There is an error because it takes an input. So the count method actually takes in an input, it's what we want to count in that string. So in this case, I want to save the letter I. And it tells me a number two. Number two because our two eyes and that string, this string, there's two eyes. We can see the area that we got. We got a type error with the account, with the message. That's it. Count takes at least one argument and 0 where given, that's how I knew that I needed to give it an argument, That's how I changed it. And I learned that the count method takes in an argument and it returns a count of two for that specific input we can use for R1, we can use the dir function, which will receive an object and it will return a list of all the methods it contains. If we do it right here for the VAR one, we can see that we have all of the methods contained in that type of object. In this case it's a string. We can see the vaccine, we have a lower one, which those lower for every single letter in the string. We have the count when we just used as well. We can see capitalized as well. We can see every single method that it has. And for now we can ignore the ones that started with two underscores will look into that later. Here we can see every single method that it has. You can use as a reference. You can use it there, the dir function. Awesome. So now let us do a recap. First of all, approach experiences with a beginner's mind. There will always be a path we've never traveled before and seek those paths and you'll never stop learning. Next, we learned that everything in Python is an object. Objects can have functionality through methods. Each object has a type, and we can see that using the type function and each type will have methods of its own. Methods are called using the dot notation. So do you have the object first and then the method with D round brackets. Some string methods are lower capital, nice title, upper strip, lstrip, rstrip, count, split, replace. As I mentioned before, we can use a dir function to get a list of all methods in an object. If we have any questions on what each method it does, we can look into the Python documentation for those. But we'll look in this course and the most used once in the ones where you'd be using the most, we have now the understand section. The first prompt is to notice what it feels like to learn Python for the first time. And how can you take that perspective into your day-to-day experiences? Next variable called myVar and set it equal to space, space space. Discover what you enjoy space, space, space, and use the type function to get the type of object that it is. Then you use the dir function to get a list of all the methods available for that object. And use the dot strip method to remove the extra whitespaces from the string and reassigned the new string to my VAR. Next, use the replace method for replace it with spaces and reassign this to my var, usually lower capitalized title and upper methods to see the different outputs. Awesome. Hopefully, you'll find these a bit challenging but not too challenging. And if you have any questions, you can always post them in the chat and it will be active in the community there. Thanks again for watching and I'll see you again tomorrow. 10. Day 7 - String Concatenation: Welcome back. Today seven. Let's look at today's objectives. We're pretty much going to look at what else we can learn from the other phonology. Then we're going to look into string concatenation and finally string formatting. Let's jump into the learning section. So let's go back to the ELF and analogy for a second and remember that questions are the answer. So every time that you generally ask yourself a question with a beginner's mind, your brain comes to life with novelty and you might find paths that you never gone through before. You get a more accurate perception of reality compared to the last time you asked yourself that same question. If you settle for a single answer, then we're closing the tap on learning because answers will always be a fragment that representation of reality. Ask questions and write them down. When you ask specific questions, you prime your mind to take in the answers when they come along. There's a part of the brain called the reticular activating system, or RAS, which acts as a gatekeeper of information. Without it, we would be overwhelmed by the vast amount of information we have all around us. So the RAS lets us focus our attention. So you can think of this part of your brain as a deletion device and you need to tell it what to look for him. Questions will prime your brain to focus on the answers when they appear. That's how you tell your brain what to look for it. Throughout this course, you can ask yourself questions like, why am I learning Python? And the answer to that might be well to exercise your brain and make new neural connections, or to gain more perspective on how the world, the digital world that's all around us works. Or to eventually find a high paying job. So developer, Those are all good reasons. So ask yourself why you're learning Python. Another good question might be, how can I use this new concept I'm learning today? Or how can I apply these accelerated learning concepts to other skills in my life? So it's good to keep all this in mind. And for now let's move into the Python topic of today. Now we're going to look into string concatenation. This just simply means just appending strings to each other. We're adding strings to each other. So this is a simple as just using the plus sign. For example, you can use this plus sign string and then print that to a string. Notice that we don't have a space within it because we didn't add any spaces between the strings. So if we wanted to spacing, we need to add it literally to a string to get the spacing printed to the screen. You can also have variables printed to the screen and concatenated. For example, if you had a variable with a name, you can print. And then the variable, you can see how it prints. What do we expect it to. We could also use the star operator to print the same string multiple times. For example, if you went to print the certain string multiple times, you could simply do the following and you would get the string multiple times. It's one thing to note about printing integers, for example, variable to, let's say it's equal to number three. If we wanted to print the number to the screen concatenated with another string. Let's say we tried it to print this, for example, it satisfies to that as well. Let's say that we tried to print variable to the screen. We would get an error, a type error, with the message that we can only concatenate string, not integer to a string. So it's telling me we cannot concatenate an int to a string. For what that means is that we need to convert this, this integer to a string using the string function. Now we can see that we print it. We print it that way. Because for example, whenever we do a type string, variable two, we see that it's a type string because we convert it to a string. It would be equivalent to saying type string to number three. It's a string because we convert the string to the number three. We can also use the format string method to concatenate strings. For example, let's take this statements as an example. So this is a string. And then when we use dot format, calling the format method, then we say format. We pass it in. We pass in value to the format method. Then the format method is applied to this string. And then whenever we execute this, we see, okay, this is a formatted string. If I would've said random. We see that whenever whatever we inputted format method gets inputted into the brackets, we could also use the same. You can say this is how you enter value. Let's say whatever value, value, another value format, and then we can say 12. Let's use this as an example. It would print this is how you would enter a value one and value two. Notice how we don't need to use the STR, the STR function to transform or to convert the interior into a string anymore, whenever we use a formatting string, we could also use references within those brackets within the string. This way. If we said the second positional parameter is, if we put one in here. The first is, and we can put a 0 here, then get format, and then 12. Again. We would see that the second positional parameter is two. I had a typo here, but it's should say if T2 and the first is one. Again, we can say first. We said here first. Second. We can say that the diameter is second and the first is first. So you can see, you can reference by indexes. Indexes as well if you specify within the square brackets, we could also use a, the format method to format spacing. So take this for example, except print, and then we pass in this particular string. Then we use the format method and pass it in the string one, string two. What do the mean? So the first number is the index we saw in the previous one. So 0 means that it will reference the one. Then one here means that every reference to here. Then we use colon. And we have our character here. This character means alignment is rest of references alignment. If we have an opcode like this, this means center alignment. We have a right arrow here, it means right alignment. And if we had a left arrow, it would mean left alignments. But let's see what this outputs. As you can see, the first column or this first spacing line, spacing would get 12345 because we inputted five up here. Then on the other hand, will get 12345678910 because that's suspecting that we passed in and we passed in the carrier. This is how you can use maybe if you had a table or something that you wanted to input with a table or something you would get, you would be able to use this type of formatting. Let's change the example now let's say one instead of two and then 0 instead instead of one. And let's say that here we will write spacing in here, one left spacing. But actually we wouldn't want to specify that the spacing because that would be the default. But let's see what we get in here. Awesome, yes, we get two instead of one and then we get one and we can write spacing with the ten characters in total. Finally, probably the most useful formatting string and go ball, which is f strings. I'm gonna write down the example. First, my variable and then here I want to save one. Because that's the variable I think we had defined previously. Exactly. So that's how we would print var one. Ronaldo. So as you can see, it's simply the string, but then just, you just add the f before. That's pretty much it. That's pretty much a pretty simple way of writing and formatting strings as just using the FBI right before the string, and then using the variables within brackets inside the actual string. So let's do a recap. Turn limiting thoughts and beliefs into something empowering from, I don't know how to code to unbecoming a better coder each day. You can concatenate strings and multiple ways using the plus sign, using the format string method or using F Strings. F strings is pretty much the one that we're gonna be using the most, since it's pretty much the most convenient way of formatting strings. And finally, etching is one of the newest and most readable ways of formatting strings. Finally, let's jump in. Do you understand section? I want you to think about a limited belief you have and how you can turn that into an empowering beliefs. Next, create a function called greeting that takes a name as an input and then prints hey there input name using the plus to concatenate strings. Change the above function to use the format string method. Change the above function uses the S strain and then use a format string method along with the underscore it, the curly bracket notation, to create a table with two columns in one row. Play around with different minimum width and texts alignments and see how that works out. Yeah, good luck with these. Ask any questions that you might have in the community section. And I'll see you again tomorrow. 11. Day 8 - User Input (Numbers, Integers, Floats, Comments): Welcome to Day eight. So let's look at today's objectives. We're gonna see what else we can learn from the value of consistency. We're also going to look into how to accept user input. We want to look into numbers to integers and floats. We're going to look into number operators. And finally we're going to look into comments and how to use comments in Python. Okay, so let's use our imagination for a second. Will you be in one month if you kept learning at this rate each day? What about three months? What about six months? What about a year? What about five years? The truth is that you will become a proficient coder way faster than you think. The problem is that we don't usually keep a consistent rate of new learnings each day. The great news is that the only thing standing in the way between us and mastering a skill is ourselves. Remember that we perform at the level of our last recovery. We should approach recovery as we do everything else with a beginner's mind. That's how we learn how to listen to the body and keep ourselves calibrated between training and testing to avoid burning out, think of learning as an excellent exercise for your brain. Your brain likes novelty, and that's exactly what we're giving it when we learn something new. But always remember that the brain is like a muscle and the rest of the body, the more we use it, the stronger it gets. But only as long as we find a good balance between effort and recovery, pushing ourselves too much could lead to burnout. Listen to your body and stay calibrated. That's why we have rest days every four days of lessons. And if you feel like you're pushing yourself too much and that's totally okay. Simply add a bit more rest, but remember to stay curious and consistent. So keep this in mind and let's move into Python now, getting input from the user is as easy as using the input function. Whatever we input after that, after that would be the user input. We could assign this to a variable. Let's say Actually user input is used for input. And then whenever we printed user input would get whatever we have from that variable. We can also see that with whatever we pass it into the input function is going to be the prompt for the user. Enter input. Then this would be the input. We can also see that as we've seen them a bit earlier in the course, we could use numbers in Python as well. If you do. We can, we can store integers, for example, numbers like this, like whole numbers, any whole number, 567, Let's do seven. Or we could do my float, which would be any type of number with decimal places. You can see that you can see this by looking at the type as well, but it changes. We can see a type of integer, but then type of my float, float. The difference is that the flow has decimal places and the integers are whole numbers. We can also have number operators in Python. So let's give this a try by creating two new numbers. Let's do number one equal to two. For number two equal to two. Then different operators work in Python. We can pretty much use Python as a calculator. You could do num1 plus num2. That would be equal to six normal plus. We can do some minus as well that would be equal to, we could use the star as a multiplier for multiplication, would be eight. We could use division as well. Would return a two. Please note that that division will always return a float regardless of if these two are integers, MD basalt is a whole number, but it's, Python still returns a float because division always returns a float. Finally, we have what? We also have the exponentiate double star, that's four times four. And finally we have the modulo which is four divided by two. And then what is the remainder or how many numbers remain? And that is a 0 because four divided by two has no remainder. Also worth. Emphasizing on the fact that whenever you use input, for example, you ask the user to input a number that would return a string. It's actually gets drink. It is not a number. If I said variable one equal to input, enter an input. If I said Five, for example, and I did type variable one, I would get a string. So it's important to notice that you would get a string instead of what you might have expected, which was an integer. For this, we simply, we could simply do variable one equals variable one. We could do int variable one. We reassign the variable to an int version of itself. Now if you run the type of variable one, we would say it's an integer, but only after we converted it to an integer. And the same applies for the float. If you wanted to turn variable one into a float, you could use the float function. Then you would see type equal to a float. Finally, let's look at comments in Python. To do a one-line comment in Python, you will just use the pound sign to do a multi-line comment. You usually triple quote version. Then you can also use actually triple quotes and single signal that would work as well. So comments, you can use a pound for a single line comment or triple quotes, single or double. And that would work perfectly for comments in Python. We use comments throughout our patellar code simply to document our code and make sure that other people who didn't write it understand what's going on throughout the code, and can navigate the functionality of the code. Sweet, so let's do a recap. We saw that long-term consistency leads to outstanding progress. So make sure to stay consistent, coming, keep coming back. Next, we saw that the user function, the input function, is used to get input from the user. And you can optionally pass in a string that will be displayed to the user. Python also supports numbers, integers are whole numbers and floats have decimals. The available operators include the plus minus star operator for multiplication, division bulbs, double star for exponentiate and modulo, which is the percent sign. You can use the int and float functions to compare two objects, two integers and floats respectively. These come in handy when using the input function, since it takes data into string, by default, the input function always brings in a string. We have to transform, transform that. We have to convert that into a float to an integer for one that would be a number. Finally, we use the pound for comments and triple quotes for multi-line comments. And finally the understand section. Awesome. So for today, first question is, where would she be in one year if you develop the habit of consistent learning? Next question is define a function to prompt the user to input a number and then prints the square of set number to the screen. There you have a hint, it might be helpful. The third question is define a function that prompts the user to input a number and then prints whether the number is odd or even. You also have a hint that might be helpful. And then finally, use comments throughout your code to document what goes on in relevance steps of the code. That is it for today, guys. If you have any questions on these questions, make sure you ask them in the community and I'll see you here tomorrow. Good luck. 12. Day 9 - Conditionals (if/elif/else) and Code Blocks: Welcome Today Nine. Today's objectives we have. What else can we learn from space repetition? We're going to look into booleans, are looking to conditions. And then we're going to look into Boolean operators. So let's jump right into the learning section. One excellent way to make the most out of space repetition is through active recall. Active recall is what happens when you produce the answers yourself without any supporting material by asking yourself a question and making the effort to answer it on your own eliminates the ambiguity between being vaguely familiar with something in actually knowing it. This is an extremely effective way to move information from short-term to long-term memory. This is also directly tied to space repetition because every time we're revisiting a subject, we're engaging in active recall. The understand sections of this course are a great way to learn through active recall since you get the chance to produce answers on your own and strengthen the neural connections on the topic you're looking at, as long as you're not using the supporting material unless it is completely necessary. Active recall is a great way to committee or learning to long-term memory. So keep this in mind when you're trying to learn something new. For now, let's go into Python. Now we're going to look into conditional statements. Conditional statements are one of the most important pillars of programming since they allow your code to follow a specified logical flow. Conditions are everywhere in our day-to-day lives. If hungry, go get some food, if sleepy, go to bed, and so on. To use conditional statements, we use a specific specified datatype called Booleans. Boolean can either be true or false, and we write the true with a capitalized letter and false with a capitalized letter as well. The if statement evaluates a Boolean expression, and if it is, it evaluates as true, then the code block would run. So in this example we assigned boolean value of true, the variable called hungry. And then we said if hungry, then run this code block. Since hungry equal to true. And when we press Enter here, we see the print. Print getting a sandwich to a screen. It's what happens and what runs through the code block. It turns out that we can also use along with the if statement, we can use an if statement else, if, an else state into 12. So let's look at the example of, we know that we had the hungry variable which is equal to true. Let's add a lazy variable and assign it to false. Now, we're going to use an if statement and we're gonna say if lazy, lazy. Then we're going to say print, doing nothing. But then we're gonna say L if, else, if missing the colon, sorry, let me say colon. Hungry. Print, getting sandwich. Else. You can print. Let's say if nothing else, nothing False, False through either of these, these conditionals, then it'll fall to the else statement. We can see right now that it goes into LF because it says if lazy, which is equal to false, then it goes back to the hungry. And then it says, okay, I'm not lazy and I'm hungry. I'm going to go get a sandwich. And you can see getting a sandwich. Objects can also evaluate to true or to false. In a nutshell, think of anything that can be empty or a non would evaluate as false. Everything else would evaluate to true. If I said if none, this would imprint it because if none. But if you've said If empty string, for example, print this, it also will imprinted because it's an empty string. 0. Print this. In this case, it also doesn't print it because he didn't 0. And finally if, but if we have, for example, this string print that we can see that it prints it out because it is, it is something and it's filled with something. So pretty much everything that's none or empty or 0, what will evaluate as false and everything else would evaluate as true. There are also what are called Boolean operators which result in a Boolean value. These operators are equal. The greater than, greater than or equal to, equal to, and so on. So we run the examples. So let's just add a variable one number, Let's do two and then variable to equal to five. If I said if variable one equals to variable to print, Let's just say this. We see that it doesn't print because it's not equal to each other. What if we said that they're greater than variable one, greater than variable two. Now we'll see that it doesn't print either because two is not greater than, five, greater than or equal to. We know it's not going to print either. Then we're gonna say, well, let's say less than. We see that it prints this. We can also do less than or equal to. This, will also print this. And finally, we can say not equal to, which is an exclamation point and an equal sign. We can see that it prints this as well. Other Boolean operators AND OR and NOT. To see if we look into these and x2, if let's say true and true, print. Let's say print this. Of course, sub-frames because true and true both. But what if we said if true and false? It wouldn't print anything because we would need both conditions to be true in order for the amount of the outer condition to be true. Let's say if true or false. Print this. And then we can say, okay, it prints to this, which is perfect, which makes sense because we want or the other, we need one or the other to be true in order to evaluate as true. So we can see this one is true so that in view over alternative would evaluate everything is true. Finally, the NOT operator. What that does is if you put the not operator before any value, it will, it will revert wherever it evaluates ads. For example, if I said if not true or false, print this. What do you think this would evaluate to? Exactly? It wouldn't print this because if you can think of this as saying false or false, both are false so it doesn't print anything. So the order of operation is the NOT operator goes in first, evaluate this first assessing not true. Then the end operator goes, and then the OR operator goes. It is also handy to know that the end and the OR operators, they return the value that represents whatever the Boolean value should represent. For example, if I had this, Let's say something empty. It would return the empty string because that's what it represents. It represents of falsey or a false value. Because this expression evaluates to false, this expression returns the value that represents that falseness. For example, if I had this and that, it would return that because it's the last one evaluates, but it returns, but it still represents a truly value in the end. Because for example, if I had, for example, this or that represents this, because this already but already represents a true value. So it returns, uh, this, this value. But if I had, let's say this, or let's say, let's have an empty one for that. Then it will represent, it will return that value. Because this is the one that represents the true. If I had both empty, it would return just an empty, an empty string, the empty one. This is useful in some cases. You'll see later on in the project, we'll use this in one of the statements that might be useful to know. You can also use a Boolean function, the bool function, to see whether an argument that passes in what it evaluates size. For example, if I do this, you know that it's true. If we're referencing one of the other examples that we did this and that we can see that evaluates as true this and that would return that. That would be the same as saying boolean of that, which evaluates to true. There's also a shorthand way to write an if statement. You write it like this. Let's say fire. It's true. Else. You can see if this is true. You return fire sites. This is a way to write a shorthand. Shorthand if statement might come in handy whenever you don't need the other. The longer way to write it. Fire. If false, elseif, fire false, else ice, we will get ice elsewhere. Awesome. So let's do a recap. Active recall is the action of actively producing the answer yourself without any supporting material. Here's an extremely effective way to move information from short-term to long-term memory. Boolean data type that can be true or false. And remember that that is k substituted. Conditionals allow you to create logic form logic flow in your program using if, elif and else. Boolean operators return a single Boolean value. So the equal, equal sign greater than, greater than or equal to, less than, less than or equal to, not equal to. And then, AND, OR, and NOT. Operators returned a value that would evaluate as the bottom line boolean. For example, if you said this and thought, for example, if you said this and an empty string, you would get return the empty string because the empty string represents that false value. And then you could use the Boolean function, the bool function, to return the Boolean equivalent to whatever you pass it in into it. Finally, we saw how we write shorthand if statements. And we can look something like this. Fire, if true, else ice and this would return fire. Finally, here you have the understand section. So the exercises for today, I'm not gonna read through them today since they're too long and I think this video is already a bit to offer today, but make sure to look into the fan. Good luck with this. If you have any questions, feel free to leave those questions in the chat and we'll be active in the community. They're so good luck and I'll see you tomorrow. 13. Day 10 - Rest Day :): Today we have another rest day. We've been pushing our limits for several days in a row now. So today we are going to internalize what we've learned so far and rest a bit. For today, I'll ask you to go back to the lessons that you might feel my needs, some revisiting and look at any questions that you might have. We learn best through action. So make sure to do any exercises we might've missed so far. Once again, I'll take a second to remind you about the key to learning we've seen. For questions or the unsere, when you become radically open-minded, you start to ask a lot of questions. Questions are the answer if you go there, they're always enriching. We overcome limiting beliefs by constantly asking questions and stress testing them to the real-world through action for consistency. It's hard to see progress right away on a daily basis. Remember that it's easy to fall into the illusion that you're not improving when in reality you improve me extremely fast. If you keep coming back, you'd be surprised at what you achieve. And finally, for space repetition, we can crush the forgetting curve by not just familiarizing ourselves with the concepts, but also in guided by engaging in what is active recall and spacing those through time. That is it for today. So have a good rest day and I'll see you back here tomorrow. 14. Day 11 - Functions (2/2): Welcome to Day 11. Let's look into today's objectives. First. What else can we learn from knowing that questions are the answer? Then we're going to look at the DRI concept. Don't repeat yourself. Also, functions are function keyword arguments and then function default values and returning objects from functions. And finally, we're going to look into arguments and keyword arguments as the arguments as a function. So let's jump right into learning section. For the learning section, we have that questions are powerful. Remember that they're alive, they're enriching and there forever in the present moment. The same question, plus a beginner's mind equals new knowledge. Remember always a sense saying that the biggest obstacle to learning is the belief that you already know it. So let's stay curious nets keep an open mind. As we saw before, functions allow us to use the same block of code multiple times throughout our code. This is handy whenever we need to perform the same action multiple times. We don't want it to be repeating ourselves. This is important, we don't want to repeat ourselves. And in programming, the idea of don't repeat yourself is called what dry, what's called the dry coding. So we want to stay dry when coding. For this lesson, we're going to start using VS Code, visual Studio Code. To open this, just look into your applications and looking to Visual Studio Code. I founded like this and how did open like this? And I'll just open up a file, dot py file. We had seen before. We can define a function the following way. Right? So we can define my function and use it as pass. And then you simply call this function by saying my function and calling it using the round brackets. We also saw how we could use optional arguments, are optional parameters to the function. Then use these inside the function. We could have done this instead of using the pass. Then run my function and then we would have to input here are some arguments that other. Then we could run this and we would see this, that and other. But look at what happens if I've certainly don't input one of the arguments, I hit Save and then run this, I will get an error. Would say a type error. My function missing one required, missing one required positional argument, argument three. This is because we had stated above that we needed this argument to a 100% once we will stay like this. Another way we could write this is to say argument three equals false value. This will be a way to say like if, if the argument is not passed into the function, then assign this default value to it. So whenever we'd run this, would see this that and then default value. You could also call the function using what it's called keyword arguments. You could specify down here. For example, you could say Argh to equal to that. Then are, let's say three equal to other. Finally, won equal to this. Then you could run this. You can say this, that and other, even though you did, but other than this, but since we use keyword arguments, which is specifying the keywords and the arguments. We could see that we get the order that we wanted to. Another useful thing about functions is that you can return values using from a function. For example, let's say nums, and then you say num one. Num two. We could return a value from this function. And we could say, let's say num one. Let us actually say results equal to num1 plus num2. And then we can just return the result. This is a way to use a function to return a value for us. So if we said, Adnan, said 510, then if we run this, we'll see that we don't get anything printed to the screen because the When we run the function, it doesn't contain anything. It doesn't print anything to the screen. It only runs this and then return this value to the screen. But if we said, if we said print, what is returned from that function, then whenever we run this, we should get the number 15, which is what we expected. Return statement returns an object or a series of objects from a function. You can also create functions that take in arbitrary arguments or arbitrary keyword arguments by using the following notation. So use a star and then args, double star and a keyword args this way. And what this would do is that whenever you, whenever you call that function, Let's say my function. You could say whatever, whatever amount of arguments we want to pass in, it'll take in as arguments, as you can see here. Then if we say keyword ours or whatever, Let's say var 11, this would be a keyword argument. And then Val two, this would be another keyword argument. Then whenever we pass in these arbitrary amounts, that can be arbitrary number of arguments in this arbitrary number of keyword arguments, we ran that function. The function what it would take us to Tuple for the arguments and the dictionary for the keyword arguments. And I want you to keep this question in mind of, okay, what is a tuple and once a dictionary, because we'll look into those soon. But for now it's the only thing important thing to know is that you can provide an arbitrary number of arguments. Well now we'll try number of keyword arguments using the following. One star notation and a two-star notation. Also keep in mind that you can say this random mating, you can call this random. It'll still work. But it'll still work. But it's convention, say args and keyword hashtags like this. Awesome. So let's do a recap. Questions are alive and always enriching forever in the present moment. We need to say curious in with an open-mind, with the beginner's mind. And that way we'll keep learning. Functions allow us to stay dry. What coding? Don't repeat yourself. Functions can take no arguments required. Positional arguments are optional arguments. By adding a keyword with a default value. Functions can return any type of object. Even though their functions. We can use the star args and this double star keyword args. Notation 12 functions except in arbitrary number of arguments and keyword arguments respectively. Finally, let's take a look at the understand section for today. What is the biggest obstacle to learning? Wire questions the answering? Then define a function that accepts a default argument and prints it to the screen called the function, providing the argument and not providing it as well. Define a function that takes an arbitrary number of arguments, args, and an arbitrary number of keyword arguments, keyword argument, and print the number. Prints the two resulting objects to the screen. And then don't worry if you don't know what the optic star, we'll learn about those soon. And finally, create a function that returns an object, assign the returned object to a variable, and print the object to the screen. But awesome, That's it for today, guys. These are the questions and then if you have any questions on these, so don't hesitate to ask in the chat and the community will be active. They're so good luck and I'll see you again tomorrow. 15. Day 12 - Lists, Ranges, Sorting: Welcome to Day 12. So today's objectives, we have that what else can we learn from consistency and pushing our limits each day? Then we're going to look into list, two list methods into this slices and finally into ranges. Today the main theme will be lists. So let's jump right into the learning section. First, I wanted to take a second to imagine where you wouldn't be one year from now if you make bite-size suffered each day, the media liquid 1% better in Python, it turns out that you can make these bite-size efforts of habit and then ended up actually enjoying them. That's exactly what we're aiming to Amy to do with this course, to hopefully show you that learning can be fun and that we can grow each day where we truly enjoying the day to day process. Next, we have that list at a datatype that is used to store ordered items in one variable. Lists are mutable, meaning that you can update them by adding or removing individual items to the list. The items of the list can be mixed end of any data-type, including other lists. Let's look into what we're talking about here. To create a list, we simply use the following notation. We use square brackets. My list would be this. And then to add items to this, we simply add items and separate them, uh, using commas, item two, etcetera would be a list definition. If I said print my list the screen and then hit Run, we see that the list is printed into a screen. We can see that by the square brackets and that this would be actually be a list. If we wanted to define an empty list, we simply create a list and assign it to square brackets with nothing inside of them. When we run this, we would run this and we would see it returns an empty list. Lists have indexes. And the same way that when we've talked about indexes with strings that we referred to them with square brackets and the index number. We do the same with lists. And the same way a list, the first item would be the zeros index. They are zero-based. What if we said this statement? What do you think it'll print to the screen? Let's run this. And we get item one exactly because we're referencing index 0 or to list the same way that with strings we could say negative indexes. And we will get the same as we expected from the strings that we would get the last number. Next, we're going to look into a couple of list methods. First, let's, let's look at the append method. If we ran my list, append a new item and the item, then print my list. Let's see what happens when we run this. We get the same list with the appended item. What the append method does is that it adds the item that you input into the append method to the end of the list. We can also have a, we also have a an insert, insert method. We first tell the index, then insert, inserted item, then the item, and then we print the list again. Let's see what happens. We see that it gets inserted as the first, as the item Number One of the list. The item with the index number One of the list. So we get the item then the uncertain item, the item two, etcetera, and then the new item. Next, we can also see that we can, we can delete items from a list by using the DDL statement, that delete statement. We can say delete my list. Again, we would have to reference some item with an index. Then when we print it, my list, we would see item one and then etc. Without item two, there's also the remove, the remove method, my list, remove. Then you could search an item by what it is. You can see remove, print my list. Then run this. Then you could see it removed the items from that list. We also have the prob method. And what this one does is that it deletes or that it removes the last item of the list. It returns it. Whenever I do my list pop, I do print my list. What it would do is you'd see that it wouldn't have the etc. Dod last time up to this, it has item one and item two, but not the last item. If I said print, my list pop, I would see the etc. printed and then the list, because the first thing that I'm painting right here is a command of my list pop. And we know that this method removes and returns it. And since, since it returns the last item of the list, and it returns that as well. When we try to print it, we see that the item gets printed to the screen. And then when we print the list, we see that the list has, has been modified and it doesn't have the etc. in it. We also have what are called lists slices. So let's run the following command. My list, and we have its due from 0 to 22. What this does is that it starts at 0, at the index 0 and it ends the index two. And that's from that. We can see that it gets starts and includes a 0. But then it adds also also with the index of one. And then when he gets to the element with the index of two, it doesn't included. So it includes the first one, but it doesn't include the, the higher number, the upper number. Let's do another example. Let's see what if we print it this, put then set three for example, and then one. When we ran this, we would get okay, we started at one and then ended at three without including the three. The three would be the etc. that's how it's Lexus work. Then we could also say if we don't specify a number, it just says that go all the way to the end. When we run that, we see that it started at 0 and it simply goes all the way to the end. We could do this the other way around. So we could say, start all the way from the beginning and go all the way to the number three, let's say. Then this would mean that starts from 0, starts all the way from the beginning. And then it goes all the way up until three with thumb including three because remember three would be the etc. because 012 and then three and it wouldn't include the etc.. That's what string slices are. You can also use these. Let's say for example, if you went to get the last two numbers, so of our list, you could run the following. You can think of clever ways of using this different ways. And then even if you didn't assign any single number, we would get the entire list. Because it's all the way from the beginning, going all the way to the end. We're seeing how lists are mutable objects so we can change our object. Let's take a look at the idea of my list for a second. We would use the ID of my list. Then we run this and we would get what we need to print it. Of course, print the idea of my list. We would get a number for the idea of this, my list. What if we wanted to create a copy of my list and make a change to the copy of my list. Let's do. We can intuitively think like if we wanted to create a my list, copy, we could intuitively say, okay, just copy my list and make it equal to my list. Then what if you print it? My list, copy my list. Copy. Perfect. Okay. I'm getting item 1203, item three, and etc. So we're getting the list, the copy of my list, it work as expected. But now let's say that we want to do a change. We, instead of printing my this copy, Let's say that there were going to print my list copy and then we're going to pump from my list of copy. We're making a change to my list copy. Then let's say when, when we, when we run this, we get et cetera, which is as expected. But then let's print my list. The original my list. We finish off with by printing the original my list. We see that my list had been modified as well. Minus the original mylist has been modified as well in the etc. has been popped from that list as well. So how do we create a copy without, without altering both lists? Because what happening in here is that the imagine whatever ID we have in my list, it assigns this variable, it just assigns a label to the same object. So we only have one object, which is this list. And when we tried to create a copy, we simply added a label to the same object. When we created the pop action here, we popped to whatever this level was pointing at. It pointed out the original object, which was this one. The correct way to do this would be, there's a couple of wishes, two ways we can use a list slice here. We slice it like this. That way whenever we run, we run this, we get the entire list as expected. We would puppet puff from the copy, but keep it in the original. Or we could use the copy. Copy this method. The copy, this method. There you go. Then that's how you copy a list to another list. And then that's where you make changes to a copy without making changes to your original object. Remember that we could use the dir method to get all of the methods are all the methods of an object or an optic type. In this case, when we run it, at least we can see all the methods of the list datatype. Here we have like we've seen a couple of these already. We've seen the pump, we saw append, we saw the insert. Now let's look at one more. Let's look at the, let's see. Let's look at the index one index method. If we run my list, let's say print my list index, then what do we input here would be a value. Let's say I, the item to what it returns is the index where that value lives. If we add Apple, Apple, car, elephant, etc. If we wanted to look at where the elephant was, we would simply run this and it'll tell you the index where the elephant will have value is. And if there's nothing, you have input value that is not in there, you would get a value error. Nothing is not in the list. We would get a value error for that one. Then what if we look at, let's say the sort method for example. What if we did sort? We wouldn't put nothing. Then it prints none because this sort method doesn't return anything, so we don't need the print function for them. Let's do a printf function of what the mylist, what does my list look like? It before doing an action on my list? So let's fund this. And when we say Okay, we're getting Apple car, elephant, etc. Because actually this one was already sorted, a, B, C, D, E, F, G. Yeah, it's already sorted. So let's say, let's switch these two. We add that example, then we get the same top prokaryotes and etc. Because that sort method actually sorts it. This one is worth noting that is different from the sorted function because you could print my list sorted. You could print the sorted my list without sorting and with the method. And this one would print the sorted list. And then when you print out this by itself, you can see it's not sorted. Sorted method is different. The sort method is different from the sorted function. We can also see that we can use the Len function to see what the length of the list is. We can see that the length is four. And finally, let's look at ranges. Range. You will simply use the range function to create a range and then arranging simply, let's say we do range five. It's arranged I would go from the number 0 to the number five without including the number five. So our range is a type by itself. Well, we could use the list function to turn arrange into a list. This would give us a list of the range 01234, excluding the five. Orange. If we input one, only one value, it would be the upper bound. If we put a two values, let's say 15, it would be the lower and the upper bound. Let's do a list. This range from one to two to five. So what do you think this would come out to be? If we're doing one, it will it'll be different than this one, right? Yes. Where would we want 234 excluding the five. And we also have one last way of using a range which is inputting three values. One, let's take five. And then let's say a third value, which is the Which is how many increments the value goes by. So it would be from one to five incrementing by two. So it goes from one to numbers later is three and then to five with five. What if we said all the way to 20? We would get 135, all the numbers like incrementing by two all the way to 20 without excluding, without including the number 20. There are also three more useful functions that we can look at that aren't related to lists as well. We have the Min function, the max function, the sum function. So these are pretty intuitive. What if, like if we said, let's say my list equal to list of range 120, incrementing by two. Then my list would be a similar we did above. But then what if we said minimum of my list would get one as expected? If we didn't max from my list, we would get we get 19. And then if we did the some of my list, we would get a 100 because I would be the sum of all the numbers in that list. Awesome, so let's do a recap. Bite-size efforts each day lead 2% improvements that compound over time. Percent improvements are exactly what lead to long-term exponential growth. Next, we saw that a list is a datatype. Use the stored ordered items in a variable. Lists are mutable, meaning that their contents may change for their ID stays the same. We define a list using the following syntax. And they can contain a combination of any datatype, reference list index using the square bracket notation. And then negative indexes reference items going backwards from the last item. We also saw this slices. The following syntax would be used wherever you wanted to create a new object with a copy of my list. Then we also saw a bunch of new list methods, including the following. Remember that we could use the built-in function to see a full list of all the methods in the datatype. We also saw the built-in functions used for this, such as land sorted, min-max, and some. We also created ranges using the range built-in function. And we saw how we can, could turn ranges into this using the list built-in function as well. Sweden, finally, here we have the understand section. Remember the importance of the Understanding section. I think the most critical part of the courses. If you can do every single day of the understand section, you pretty much understand what we're completing throughout each day. So here you have today's section. You have any questions for these. Feel free to leave them in the community section or in the chat and we'll be active there. Otherwise, good luck with this and hope to see you back tomorrow. 16. Day 13 - Loops: So welcome to day 13. For today's objectives we have what are the benefits of learning and pushing our limits, and how do we avoid burning out? Then we're going to look into for-loops as well as while loops. And then the continuum, the break statement, and finally the statement. Let's jump right into the learning section. We know that learning involves novelty. Novelty is pretty much like exercise to our brains. Because the more we use our brain, the stronger it gets as long as we're calibrated. And by calibrate, I mean that because if we push our limits and we push ourselves too much, we could potentially burn out. That's why we have pressed states every five days so we can recover and review what we're learning. And we avoid burning out. To look into for-loops, we know that the syntax to create a for-loop is the following. Four items in terrible then run the code block. Within this. In this case, the eye terrible can be any type of object that has, that can be iterated through. In this example. If, for example, if we had a variable with a string in it, and we can say for item in the player variable, print, let's say print item just to see what this would do. What if we did I iterated through every single item in a string variable. Let's see what happens. We see that it goes through every single letter, which is pretty much where we would've I would've expected the most for every single letter and it prints it to the screen. We also have another type of loop that's called a while loop. And the syntax is as follows. While condition pass. This is the simplest way of saying while some condition that evaluates to a Boolean value, either true or false. While true. This is going to run while true, and then the code block is going to run. So let's do an example and say, let's create a count variable. Let's say counter equal to 0. And let's say while count less than or equal to five, print. Now when we run this, we would also need to add count equals to count plus one. In Python, there's a simpler way to syntax to write this. A simpler syntax like this, which is count plus equal to one. It simply adds one to count. And it represents the same, that the same thing that I type a psychedelic, that same thing they typed a second ago. Let's run this and see what happens. Awesome, That makes sense. So you go count 0 and then counts one. Then it, while this condition is true again, one count is equal to one. Then it runs again, it runs it again, and it will run a total of six times until count is equal to six. And then that's when it'll stop running. This is how we will run a wild loop. But now let's see an example of if we forgot to add the alteration of the count variable. If we did this and we run it, we see that the code is running infinitely. Never stick. It will now stop running because you condition will always evaluate to true. If this is the case in this happens to you, just simply run control C. It will do a keyboard interrupt and it will interrupt the running of your code. If you ever create an infinite loop or if you want to interrupt your code from running, you can simply run the keyboard interrupt and the code will start from running. There are also two commands that we can use to within the while and for loops. These commands are going to write them in a comment up here. Continue and continue and break. What these do is that, for example, if the count plus equal to one, Let's add, for example, in here, that's sad, a continue statement. And then let's add print, print, count. You can already see how how this is grayed out. It no longer has colors is because the continue statement, what it does is that it skips everything. That's softer it, and it simply run to the, the, the while, the while or the for-loop again from the next iteration. Simply it does this next iteration right away. If I were to write this down and then run it, run an infinite loop with just Hayes because it never gets to the print count and he never gets to the count plus one statement. So I'm gonna keyboard interrupt this. Yeah, that's what the continue continuous statement does. It goes to the next iteration. If I did this on the other hand, are removed the continuum from there. It'll run 0, hey one, or the other way around. Hey 0, A1, A2, A3, A4, A5. And then when it's hate six, doesn't, this no longer evaluates as true and it simply stops running and continuous running the rest of them. The code. Then let's look at the break statement. That's simply add statement down here that says if count equal to three, then break. What was this to? What the break statement, what it'll do is it'll simply stop running the wild code or the wild loop or the for-loop altogether. If I ran this, we would expect it to run whenever it gets to three, wherever it counts and inconsistent gets to three, the code run, the code block bootstrap running and it will break and the while loop will stop running altogether. That is what the continue and break statements do. Let's say that we had a list defined with three values or three items in the list. Since this is also an iterable, we can use a for-loop twice iterate through every single item in that list. What we did for item in my list, print item, that's what we would expect. Every single item or no luminous and name are printed to the screen. That's awesome. There's also another way we could use a for-loop to print items, right? Terrible item is analysed, which would be to say for item in range. So if we wanted to create a list of numbers, for example, range from 0, or we can omit the zeros, tend to ten. Then say item in range. We can say this and then this would print all the way 0 to nine, as you can see down here, 0123456789029. What if we wanted to print? Let me go back to when we had on this. What if we wanted to print every odd the odds items in this list? Let me add other. Whereas we wanted to print every other item in this list, we could do. We could use the following syntax for item in range 0. Then my list too. Print item, print my list item. That way we could print every other item we could pick for now low and name this every other item in the list using a range function. We can also use the insert statement for other Boolean expressions. For example, if we ran this, if, let's say now though, in my list. Yes. What do you expect this to run? Exactly, yes, Because if the item is in the list, we can print yes. So the n statement can also be used this way. And also if we can say the opposite, if you will. Now though, not in my list. It will print. Yes. Else print. Let's say not in my list. No, not in the list. Then if not, we can say yes. What do you expect to happen here for an aldose and list or if not, we can see that it is in this because it is said another player. If we said something else, another player, it'll say not in the list because L is not in the list. Now what if we wanted to create another this we can create an empty list. Can create an empty list. And we want to add to this list every single item of the first list has the meets a certain condition, right? So we can say for item in my list, we're going to do a certain action. Then first of all, we're gonna say, if the conditional we're gonna try to meat. Meat is if the item has the letter e in it. If item, let's say if in item, then we're going to do, we want to add it to this list? Then my other list append item, because the item is the one that we're getting from this list. Then finally, we want to print the result of my other lists. Let's see how this works. We get messy, we get Neymar and we get other, we get every single item of this desk that has an e in it. This is an example that you can see. I'm using a for-loop for item in this list using a conditional statement. And then I'm using a list method, which is the append method, passing in the item that I'm looping through the for loop. This is a good example of something that you might need to happen. A combination of, of commands and of, of functions that you wouldn't need to use throughout your coding. Excellent, So let's do a recap now. The more we use our brain for stronger it gets as long as we're well-calibrated because if we push our limits too much, we could burn out. That is what we have rest days. We saw how for loops are used to loop through I travel objects. There are several October object types in Python, and some we've seen so far are strings, lists, and ranges. While loops will loop as long as the condition stated evaluates as true. Then we saw that the continuous statement holds the current iteration of the loop and then continuing student the next one. And then the break statement exits the loop altogether. The index operator returns a Boolean value, true or false if the first object is in the other. Finally, let's look at the understand section. This is the most important section of the day. Remember, because it involves active recall and you actually getting involved into what word learning. Check these out and do these for tomorrow. And if you need any help, feel free to ask in the chat in the community will be helpful there. And otherwise, good luck and I'll see you tomorrow. 17. Day 14 - Dictionaries: Welcome to day 14. Today's objectives we have mainly to focus on dictionaries. They ought to look into dictionaries, how to find those, how to work with those, and then dictionary methods. So let's jump right into the learning session. The main point here is that a dictionary is the datatype that consists of an unordered collection of key value pairs, also generally known as an associative array. That's what a dictionary is. Now let's look at how we would define a dictionary. To create a dictionary, we use the following syntax. So my dict Gennari, this would be a name of a variable which could be whatever you want, and then use curly brackets. This would define an empty dictionary. We can call this my empty dictionary. Then my dictionary could be something like this. First name. Let's say John. Last name, let's say Smith. This would be an example of a dictionary with key value pairs. And this would be an example of an empty dictionary. Dictionaries contain items which are composed of a key and a value. So this would be one item over the dictionary, and then this would be another item of the dictionary. There are separated by a comma. Then the key would have, would have a value assigned to it. And then these would be separated by a colon. And we would reference each, each item of a dictionary by referencing the key in the following way. So my dict, similar to how we would use it for list, firstname, could use my dict firstName. And if we printed this and run it, we could see OK, and it's John. You can think about it similarly to how we reference indexes in a list. But in here we reference the key of one of the items of the dictionary. If we were to run this with a key that doesn't exist in the dictionary. And let's say, for example, age, we would get a, get an error, key error. It says age. Basically goes, it doesn't exist. But there's a dictionary method that we could use that It's called the get method. We can provide the key to that GET method. And the good thing about this is that if it doesn't find, it doesn't find the key. Instead of returning an error, it returns none. If we give it a method or if we give it a key, sorry that does exist. It will return the key. So the GET method is a way to get around DR. And we could get none if it doesn't exist. Also, you can pass in a second argument, which would be the value returned as a default if it doesn't exist. We can say this will have age. And if we ran this, we would see, okay, it returns, does not have age because it doesn't find the first key that test or it's prompt to, to add a new item to a dictionary. Simply reference as if you were referencing the key. So let's say h in this case, then assign it a value. Let's say 27. Then let's print this again. After assigning the values, see what happens. It's clear terminal and run it again. We see at the beginning and doesn't have an age, but then we assign a value to the H key. And then we can see, okay, it does have an age and it's actually print the entire dictionary. Just to see how that looks. We can see firstName John, lastName Smith, age 27. To reassign a value to a dictionary key. Simply reassign it by referencing the key. As you did, too, we assign or assign a new value. If we wanted to change the name, for example, we could say my dictionary dict. First would be square brackets, firstName, and I would simply use the new name. So we can say Mike. Then when we print this, we would see them in this dictionary. Firstname Mike, last name is Smith, age 27. Then if we wanted to delete an item. From the list, let's say let's delete lastname. So we've simply use a delete statement, delete, and then reference the value as he would reference to, to reassign it to create a new one. Then when we run this, we would see the final, the final dictionary being firstname mic, age 27. As with lists, dictionaries can contain different types of objects within the keys. So this could reference a string. We referenced pretty much any type of object, as you can imagine within the dictionary. Even dictionaries within dictionaries as well. Now let's look into a couple of dictionary methods. There are three methods that are useful. That are my dictionary keys, the keys method, then the values method, then the items method. The items method. Let's see what these provide. Screen again and run it again. We can see that the key is okay, we get the keys which are first name, last name, and age. We see that the values are john Smith in 27. And then we can see that the items are pretty much the entire dictionary, which is a list of the key-value pairs in a tuple. So we can see again, again a tuple. We'll see soon what that datatype looks like. But it'll pretty much return the key value pairs, the items in the item sort of way. So if we wanted to see if there's a certain key within the dictionary, we could use the keys method. So if let's say first name in my dictionary, print, yes. Let's run this and of course, going to print yes, because the FirstName this within the keys. Now we're going to look into looping through a dictionary. The first thing we need to remember is I wouldn't looping through a dictionary. Dictionaries are unordered. So it doesn't guarantee that if we look through this dictionary, it'll go through FirstName, LastName and dense myth. Then h, sorry, in that order, specifically, this important to remember, they're not ordered, so the order is not guaranteed. It looked through them. But let's go through each instance of what we would get if we were to loop through the dictionary. For item in my dictionary, dict. Here, we would get, we would get, each key would be the same as saying for item in my dict, keith, this would be equivalent thing to do. Firstname, lastName and age. Then if we did values, item for its values, we would get John Smith 27. So each value. Then finally, if we did item, my dictionary items, we would get first name John, last name Smith, age 27. It's a tupled way of getting these great way to look into similar, look into this a bit later as well. But it would be to say, since to unpack the tuple, that's what, let's call it tuple unpacking. If we said four key item in my dictionary items and print key, print item or this one that strict better. F strain. Strain is saying key KI equal to KI and then Item value. Value. Because this, sorry, this would be equal to value. Then if we were to save this, we can say, okay, key firstname value john key, lastName value Smith key H value 27. It would be unpacking the tuples that we get from the items method. Great, so let's do a recap now. The syntax to create a dictionary is the following, using curly brackets and assigning, assigning keys to values. To create an empty dictionary, use empty curly brackets. Then to access the value of a dictionary references a key using this square bracket notation. And then to reassign, simply reassign the value by referencing the, the key and assigning a new value to delete an item, reference a key, and use a DDL statement that delete statement to delete that item. We also learned new dictionary methods, the getMethod keys, the values and the items method. Finally, there's login to the understand section. Here you have four questions for today. Always remembering this most important part of the day, making sure we're doing our exercises, and then we're pushing our limits and learning each day. If you have any any trouble with these, are any questions with these, feel free to ask them about shot in the community and will be active there. Otherwise, good luck and I'll see you again tomorrow. See you. 18. Day 15 - Rest Day :): Welcome to another rest day today Let's internalize what we've learned so far and go back to any lessons you fill my need review. Remember that the exercises are the most important part of each day. Then we have the three keys to learning we've seen so far for questions at the end. So we know that keep an open mind, be curious and approach learning with a beginner's mind for consistency, we know that we need to come back to each day and give it everything we have. You'll start to see a resolves and you won't regret giving it your best five for space repetition, it's all about active recall, since it's a great exercise for the brain where learning and it helps us move things from short-term to long-term memory. Repeating the topics after rest and recovery helps us crush the forgetting curve. Always make sure to take a rest and recovery into account. But thanks for coming back and take a great rest day and I'll see you again tomorrow. 19. Day 16 - Tuples and Sets: So welcome to Day 16. Today's objectives we have consistency is key to long-term growth. And we have to look into tuples, want to look into tuple assignment, then sets, and then some methods for this sets. Let's go into the learning section now. Remember that daily increments compound over time and V2 long-term growth. And also remember the growth chart and how we should look out for the value of disappointment, tuples or a datatype for that allow us to store an ordered collection of items in one variable. Tuples are immutable, which means they cannot be changed. The items of a tuple can be mixed of end of any type, including other tuples. To create a tuple, we simply use the round brackets to create my tuple. For example, I could do this. That another, and this would be a tuple with three items within it. If we wanted to create a single value tuple, we would, if we did it like this, this would simply assign my tuple to the string. This. This wouldn't work to create a single value tuple. We would need to add a comma to create it, to emphasize that it would be a tuple and this would create a single value tuple. Tuples are useful whenever you have data that you know will not change and should not change throughout the duration of your program. For example, if you wanted to include a week or month of months of the year, or letters of the alphabet will be used for data that you would not want to change throughout your program. Just as we're doing with lists, we can reference the value of a tuple by using the square bracket notation. For example, if we wanted to print this value, run this and we would get that printed to the screen which has a second value. Remember that this 00 based the indexes reprinted 0, we would print this. We can also loop, loop through the items of a tuple. With a for-loop, we would get what we expect, which is this, that and other after the death that we painted before, to delete a tuple or two altogether, we can use a delete statement. This will delete the entire tuple. Remember that we can't delete. We can't delete items individual lives from the tuple because they are immutable. Just as we have the list function, we also have a tuple function. We could turn my tuple, we could turn it into a list. We could keep it as a tuple, would be redundant to add it here, but you would understand it works the same way as this function would. We see here how it's printed into a list. We can turn the same thing into a tuple. There's also tuple assignment, which is, this would be a tuple assignment. We have the variable name, and then we have the items of the tuples that we want to include in the tuple. This is what is called packing. This was called packing. Then we could also use this syntax to unpack, unpack that tuple. Unpacking. This can come in handy because now we can reference the different variables. The different variables that we assigned simply by unpacking the tuples. You can see this dye another because we assigned this dot and another by unpacking the tuple. Just remember the unpacking because will be useful to look further on into, on packing. We can see that it works for lists as well. So this packing and unpacking is sustained for list as well. Here we have a function that takes in two arguments and simply prints the arguments one after the other, separated by a comma and a space that's literally everything update the function does. Then we defined my list has two values, this and that. It turns out that we could also use the, as I mentioned before, the star and double star to unpack lists and dictionaries respectively. If we wanted to run my function, we could run it like this. Because of the star, would unpack my list into two separate arguments and we pass it into a function as two separate arguments. So if I run this, we would see that it would work. It'll print this comma space. And then because the star works for unpacking, in the same way, we could use the double star notation to unpack a dictionary. If we have a dictionary and everything's set up to return a dictionary. In this case, it wouldn't work for this case, of course, because I didn't have been defined. And the function is instead up correctly for that, we could use a double-strand notation to unpack a dictionary. We could also use tuple assignment with what is returned from a function. Let's say that this function takes in two arguments and simply returns the two arguments. Then I pass it in as before, I assign something to, I run the function. First of all, I run the function. So we run into the function, I pass it in my list on packing my list into two separate arguments. That running this is going to return the two separate arguments simply, and that's everything that is going to do. But the thing is that when it returns them this way in this syntax, which is argument one, argument two separated by a comma, this would return a tuple of the two arguments. So I could say here my tuple. Then I could print my tuple to a screen. And then when I run this, we could see this and that as a tuple. The same way as we are running this function that returns two separate arguments. We could run it like this, val value one and value two. Then we can say, okay, let us try to print value one and value two to see what we get. Then we can see, okay, we're getting yes, we are getting this and we're getting that as well. We're seeing that we can return from a function separate the different objects separated by commas. And this would create a tuple with the separate objects. And then with these, we could either use tuple unpacking or we can simply keep it packed as a tuple and then we can print those values separately. Finally, let's look into sets as well. So sets to a datatype that allow you to store multiple items in a single variable. They are one of four built-in data types in Python use for store collections of data. The other three being lists, tuples, and dictionaries. Then sets don't allow duplicate values are immutable on ordered and on indexed. The relevant part here is that sets don't allow duplicate values. To create a set. We use curly brackets. You can say my set equals to value one, value two value, and then print my set. We can see that it prints to screen value one to w. And you can see that it's unordered. So it can be at a random order book value met and fell into. The important thing is that they cannot accept duplicate values. We can always turn a set into set into a list. Using the list function. We can always use the set function as well to do the opposite, to turn a listen to a set. One example of this would be, let's say we had a list with value to value n, and let's repeat value to. What if we printed list. Then created my set and did set of my list, then printed my set. Let's see what happens here. Clear the screen down below and run it. We see that we're getting my list. Of course we know we're getting a set because we defined it as a set because there were curly brackets. Right now we're financing list. So now it should work. Okay, we're missing a comma here. Right now it works. We have the list which has value one way to value two and value n separated by commas and then having done a list. But then when we turn that listening to a set, we actually see that value too, which is a duplicate, gets removed because it's a duplicated set, has no duplicates. So whenever we turn that into a set, we see that we get it in the single values. No repeated values. To look into a couple of methods, we were gonna look at the add method. So we could see that we could add just another value set when we run it, we would see, okay, we added value to the set from above. We can also see that we can use the remove method value to, let's say, for example, remove. Then we say, okay, we're going to evaluate m value one in the set. There's also a union method. So this would be if we had another set, my set to let's say value of three. Okay, let's see value, value, one. Value for an example. Then we did our union. My set to think this would return exactly. I think this would return comment at this one out. Screen for more clarity. This would return the union of both of those. Okay, So exactly. So if we have two different sets, then we have one of the sets and then do a union. The second of the sentence, it would return value 1234 and value n. Notice how the repeated values within the two, the two sets, which are value one, are not repeated even in the union. The union is pretty much all of the items were all at the values that are in both sets. And the one that you created using the union and the one that you added as an input for the union method. But then it wouldn't include the repeated values. There's another one, another set called intersection that runs something similar to a union, but it looks at the ones that are the common values and then it returns a common values. So we can see here that the common evaluating intersection between the two sets is value one, which is correct because that's a value one and value, the value coincides into the two sets. Awesome, So let's now do a recap. We saw that daily improvements lead to long-term exponential growth. You can think of tuples are immutable lists. They are not meant to change once they're created. Create a tuple using the following syntax, using round brackets. And it can contain any combination of object types. Create a single value tuple using the following syntax. Nodding a comma at the end of the first value. Reference tuple items the same way as this using a zero-based indexes. For example, my tuple, we're back at three. The tuple statement returns an empty tuple, or returns a tuple out of another terrible object. The same way that list function does for this tuple assignment works as the following way. If you wanted to pack a tuple, you first write the variable name and then run the values separated by commas and within round brackets. And if you want to do unpacking, you write down the variable names separated by commas and then reference the value or reference a variable that points to that tuple. Object. Sets are similar tuples and lists the main differences that said, don't align, allow duplicate values and our unordered and unending index date on indexed, like tuples, sets are immutable. The set function statement works similarly to this list function and the tuple function. Then the new set methods be learned or the add method, union and intersection methods. Finally, let's look at the understand section. We have a couple of questions for today, six questions. Again, remember that this is the most important part, just to see that we're learning and to make sure that we're internalizing what we're learning. Good luck with these post any questions that you have in the chat section, in the community section will be active there. And good luck and I'll see you again tomorrow. 20. Day 17 - OOP - Classes Definition: Welcome to date 17. And let's look at today's objectives. We're going to look into how questions are the answer. We're going to look into Python's documentation. We're going to look into Object Oriented Programming. Oop, and how everything in 500 is an object. The most important question when you're looking to today's, what is a class in Python? Let's jump right into learning section. I want to remind you to keep asking questions throughout the course. Since questions point your attention toward answers and answers may change the time. Remember the elephant and how answering the question once and then keeping that uncertain throughout time might be dangerous in sensors might change through time. So we want to keep asking questions constantly. Great place to get questions answered is Python's documentation. Programming languages tend to have a great documentation with all the correct information. And even experienced programmers who've been coding for years, my constantly use the documentation to refresh on their knowledge. But reading documentation can sometimes be intimidating because of how many details it has. That is why I would generally go to the documentation with very specific questions I wanted to answers to. To learn what object-oriented programming is, we need to answer one very specific question, which is what our classes in Python. So the question that we're going to look up is what our classes in Python. We're going to say documentation. We tried to get the documentation specifically. We're going to look up the python.org link as the official documentation. Now you can see here that it's really heavy, text-heavy, because it has a lot of details in a lot of information. And that's why I'm saying it's such a great resource. But when you have such a specific question, just like we do, we only need to know what if classes are. So for this specific example, we're just going to look at the first paragraph in the documentation. Let's copy this paragraph over here. What we're going to do is we're going to see each specific topic dice reference in here. We're going to look into what those are. So let's say classes provide a means to building data and functionality. Functionality together. Creating a new class. New class creates a new type of object. New type of object, allowing new instances, instances of the type to be made of that type to be made. Each class instance can have an attribute, can have an attribute attached to it for maintaining its States. Glass this instance there's can also have methods defined by its class for modifying its state. Right now, I'm doing this to show you how when, when we break things down into manageable, bite-sized steps, it becomes easier to understand. So now we're going to look into these topics specifically and we're going to start understanding what these mean. Because I truly think that this paragraph might sound like a foreign language to you and that would be, make complete sense right now because of the stage of where we are learning in Python. But this is meant to show you that we can turn something that sounds like a complete foreign language into something completely understandable by breaking it down into bite-size chunks. That's what we're going to start understanding what each of these mean. And that will make us understand this paragraph completely. It turns out that there's a lot of programmers out there and people who write Python out there that don't even understand what these concepts are. And that's why they are going to be such an advantage for you to understand them well. It also turns out that once you understand what a class is, everything else, all the other subject of the other topics will be a brief because they are, they are very interrelated into what a class is. And it turns out that to understand what object oriented programming is, what we need to do is to understand these concepts, which I'll show you how to be hard to do. Let's start with an example. You can think of yourself as an architect and you have a blueprint of a house. You can go on and build that house using the blueprint in as many different cities around the world as you want. You can go to Paris and build a house. You can go to New Zealand and build a house. You can go to. Barcelona can go to Hawaii or as many houses that you want. In the end, every house would be it's own house. But they would all have a lot of similarities since they were built using the same blueprint. In this example, the Blueprint be the class and the houses would be the instances of that class. So the blueprint would be the class and the houses would be the instances of that class. You can think of a class as a blueprint for a specific type of object. Also the term class and type are used interchangeably in Python. You can use this blueprint to create individual instances that will have similarities in both their respective data and functionality. It turns out that we've been working with classes all along. List are an example. If I have my list, one equal to C, we can see that when we print the type my list, we see it's a class, class called list. If we create a different list, let's say list two. The NF printed type, my list two, we get the same class of type, class of type of name or the name of the classes list, which is also the type. So you can use type in class interchangeably. We can see that there are two instances to separate in a separate instances of the same class. So the class is the same. Blueprints are the same, but the houses are different. Instances are different. On remember when we talked about the list function, we call it the tuple function, that function, all of those functions. It turns out that they're not actually functions, but they are actually classes. When we try to print type of list, for example, we get a class type. Remember the type in classroom interchangeable switch actually got class. When we compare that against, for example, print the type of the print function we see it's a built-in function or method. So we can see that the print is actually a function or method and the list is not a function method, but instead it's actually a class of itself. We can create our own classes by using the following syntax. We stayed class. Then the name of the class. The name of the classes are, by convention, are capitalized. Then we can say pass down here. Then let's do print type of my class to see what we get. Let me see. Okay, here we are getting a class of class type, which had been done that because it's saying it's a class of itself. Awesome. So then when we do print type of this, which was the example that we did before. Class of class type. Awesome, That makes sense. That tells us that we created our own class and it's an equivalent to what the list is. To create our own instance of a class. On the other hand, we would run something like this. My class, say my class one instance, one, my class, my class, and then call it a fifth. Similarly to how you would call a function. We'll call it like this. And then when we print it, if we were to print the type of my class, my class one, we could see that it is a class of Maine. My class main simply references that it's different script that is running as the main script. And then my class is a class that is defined in the script that is the main script rounding. This is similar as doing us as if we were to do my list. We would create a list. And then we will print type of my list. We would get as expected class list. Now we've made a lot of progress here. We have, for example, that classes or are the equivalent of type. So we can say classes or type of objects. Type of objects which are equal to the blueprints to create new instances. Instances. So now we have new instances in new class, so we can move these. Then that is to click create a new class. We already showed that as well. So now we're kept the following. We have in our classes or type of objects or equal to the blueprints are used to create the new instances. And then we're still need to understand what data functionality attributes, dating methods is. But we were already familiar with a bunch of these and you'll see once we go into these, but for now, this is what we have and we've made good among good amount of progress in to understanding what this means, which initially started as they pretty much like a foreign language, we're making good progress. And that'll be it for today's learning section. Awesome. So let's do a recap now. We saw that questions are, are the questions prime your attention to receive and absorb answered more effectively? We saw that Python is a great place to find detailed explanations. And the best way to use documentation is to go with very specific questions with your mind ready to absorb the answers. Everything in Python is an object and thus what Python is. That's why Python is an object oriented program programming language. Every object has its type or class. The term class and type are used interchangeably in Python. Examples we've, we've been working with all along the string type, list, tuple, dictionary, and etc. Think of a class is a blueprint of a house. And individual houses built from that to paint as the instances of that class. For example, a class would be list. But when you create an actual list, that would be an instance of that class. Next, and we'll, we'll see tomorrow, we'll see how classes can handle data and functionality, and you'll see how we've been working with that all along. Finally, into the understand section. I have a couple of questions for you today at five questions. So good luck with these and make sure to ask any questions that you might have. And if you're blocked with any of these, don't hesitate to ask in the chat and the community section will be active there. But I'll see you. Good luck with this and I'll see you tomorrow. 21. Day 18 - OOP - Class Attributes and Methods: This is day 18. For today's objectives, we have crushing the forgetting curve with space repetition and active recall. You have user-defined classes, class, data, class functionality, and thunder or magic methods. Let's jump right into learning section. Remember that we crush the forgetting curve with space repetition and active recall. Over time, you'll notice how your brain becomes stronger and you can do other things in your day-to-day life with more ease and focus. Coming back to where we left off, remember that this used to be a paragraph that sounded like a foreign language to us. And now we're beginning to understand it better. We have the classes or type of objects are equal to blueprints to create new instances, we have that classes can contain beta as well as functionality and attributes which create a state and then also methods as well. And we'll see how all of this combined to the intertwines together. Now that we know what a class is and how to create our own, let's talk about how classes can store their own data. We're storing this data similarly to what we've seen so far with variables. We call this class variables attributes. We can have both class attributes and instance attributes. The differences that a class attribute is the same for all instances. And an instance to attribute is unique to each instance. When you declare a mutable object as a class attribute and change it in one instance. It will change for all other instances as well. But when you create a mutable object as a class attribute, NS reassign the class attribute on an instance. That instance will now point to the new object assigned to it, but all other instances will keep the original class attribute. Let's do an example here and say that we're going to create a class that's going to represent a house. That's also assign a dot doc string, that's going to say class to represent house. Now here is where we create the class attributes within the class definition itself. Let's say that the first attribute we want to assign as the city, we're going to say that the city where the house is in Barcelona, we're gonna say bedroom. We're gonna say it's gonna be a three-bedroom. And then in a two bathrooms apartment. Then we can say something like floor. Say it has you can have tile, hardwood, carpet. It's a list with the different types of floors of a floors that it has. And you can see even have a boolean attribute that says has pool and say equal to true, it has to pool. This can be a definition of our robot class. Then later on we can say, Okay, Let's assign, create two instances of this class house. How would we do that? Well, we can say how s1 equal to house, then house to equal to house. This would create two separate instances from the same class, the same house blueprint, right? So it's one blueprint that has created now two separate instances. Then, for example, right now we can say, we can start making some changes. We can say that two house to city, we're gonna change it to sydney. Then house two bedrooms has decrease that by one minus equal to one. House two bathrooms. Let's say the same thing minus a equal to one, just decreasing it by one. We're changing, we're changing the second instance of the house or we created so we can change the attributes and see what happens right? Then Let's say house, two floors. Force remove. Well, let me see it for exactly. Floors. Remove. We're going to remove the hardwood hardwood floor. It awesome. Now, let's do the following. I'm going to skip this part, but pretty much what I'm gonna do is I'm going to print the every single aspect of every single attribute of each instance so we can see and compare it against the two. Here we go. We printed one blending blank line, and then we print it a description saying print house one instance attributes. The next simply did. Print city, one, city of house1, all with f strings. And then they did a title with the city's would capitalize it. Then we have bedrooms, bathrooms, floors, which should be equal to floor. Has a pool true or true or false. And then the same exact thing but for the house to house to instance. So let's see what happens when we run this. We get the first one, Barcelona three, bedroom to bathroom, tile and carpet. That's strange already because we should have tile carpet in the hardwood. Then we have the house house too, when we have where we expect would have Sidney two bedroom, one by two bedroom, one bathroom, tile carpet, and has a pool. True. What happens here is that when we do this, when we did this to the second, to the second instance, we're actually doing this to the same object that is contained up here, and it's assigned to class saturated. That is why changes to every single instance created with that, with that class attribute. Where we have to prevent this from happening is actually the following. We would have to say house to house two floors, floor equal to house, house to floor. Copy. We would have to create a copy of this. Then we can say house to floor, remove hardwood. That's how we would do. We would run this perfect house, one we can see it style hard wooden carpet and then how suis tile carpet only based on no, We saw that data is actually through attributes. Attributes. Functionality. Turns out that to add functionality to our classes, we do that through message method, simply the methods. How do we do that? Well, remember how we talked about methods for lists, strings, and other data types like, like so. Well, it turns out that it's really similar to the type of objects that we're creating right now with classes. Because whenever we want to create a new list, let's say my list, run the list, type, then print my list. We get an empty list because we were creating one instance through the type or the class list, we're creating one instance and then we have print my list. Then we can also get directory of my list, which would return to print it to the screen, would return every single method that we have. We have a copy method, we have to append index of pop method, the remove method. We have methods already. These types of lists that we have, this list type in this instance that we create an instance, we print the n since we saw that it's an empty, empty list. But then when we try to do the direct method or the dir function, we see all of the methods that are within that instance. Well, the same happens for our classes. We can simply create methods within our classes that will add functionality to our classes. The simplest way to define a method within class that we defined as the following. If we have our class called my house in a class to represent a house, we would simply define it as a function inside a method. My method, let's just say Grant method ran. Then if we create an instance, let's say let's say Well, we created an instance of my house, my house and then ran my house one, my method. Let's see what happens here. It says it gives us an error. It says type error. My method takes 0 positional arguments, but one was given. In this instance. It turns out that for a class and I **** class methods, we always need to pass in the self argument. When we run this. On the other hand, we'd see OK, method ran. Keep in mind that we need to pass in the self argument because of a special thing about methods is that the instance object is passed in as the first argument of the function every single time it runs. Think of the self argument simply as the instance itself. So it is passing in the instance itself to the function is, it's exactly as if I were to say down here, my house equal my method and then pass in my house one. We see that the method bronze again because I'm calling my house, which is an object, which is a class in this state, in this instance. Then we're calling my method, which is a method within that class. And then I'm passing in the instance, which is the instance itself. This is equivalent to saying this where we simply just want to do this because we went to, we just want to call it the house itself for the instance itself, called the function itself, and then have the the instance itself passed into the function automatically by Python. That's what Python loss and that's where we got the error before. And that's where it worked after we included the self argument within the method itself. Python also has what are called magic or dunder methods. Thunder for a double underscore, which are simply methods that have some sort of special functionality to them. And each has a very specific purpose. We only need to deal with thunder methods whenever we have a very specific goal in mind. And we know that we want to use that dunder method in to deal with it. Let's take this example for a second. We used the class variables or class attributes to assign all these attributes to a single class. And we use a class attribute for this. But what if we wanted to do something like this? My house, one equal to my house, and then say Barcelona, three to four bedrooms and bathrooms. And then for the tile would pass in the list here, the floors. Then true. What if we wanted to pass in this as it looks more like a function, but it's simply a way to start an instance of a class with the attributes passed into these because we don't want all of them to have Barcelona or have the same type of floors. We want to define those uniquely in every single time, every single time that we declare a class instance. What do you think we could do for this situation? Well, it turns out that there's a very specific dunder method called the method for initialization. Let's say initialize instance what this dunder method does or what the specific behavior that this thunder method has. The init method is that it will run every single time that a new variable or a new class instances declared, or whenever a new instance runs, then this would, would run. For example, if I did class initialized, I did in here, I'm going to comment this out because we don't want to use that yet. We want to say my house. What if we did this? We can say, Okay, class initialized. We see that whenever we initialize the class, we create an instance of a class, it gets initialized. And then this codon there on the init method of bronze, there is also called the constructor method. Constructor. What we would do for this specific example, for this to work, we would simply use the following. The following syntax would do self, self city equal to, equal to city. Then pass it in. City out here. Self rooms equal to bed rooms, rooms, bath rooms, floors, and bathrooms, and then define them down here. Flores flourish. Then self has. Pool equal to has pool. Now when we run this, we would initialize that class and then we would have every single attribute assigned to that class because of the very specific way the init method works. Another example of another method, or we could create a regular method, could be a print description method. And here's an example. We define the instance, a description method, and then we simply print description of everything from the instance. So whenever we wanted to run that method, my house one instances description, save that. We could see it prints city of epsilon and bedrooms, three bathrooms to force titled hardwood carpet hospital equal to true. We can see that's an example of another type of method that we could create. This where we're at right now. We saw that functionality also. What it means is that it means that through methods, functionality through methods. And these could also be what are called magic dunder methods for double underscore. Then we've saw that state, state pretty much as just like a snapshot of your class. So state we can think of status being a subset of data and the attributes. If you were to take a picture of your class or what we're up to your object at any given time, that would be the state of your object. We can say in here snapshot of your object. So now we can see with more clarity that the paragraph that initially started as a foreign language now makes a lot more sense. If we were to go to the back, read back, I didn't. Right now we would understand concepts that it has. That's pretty impressive just to turn foreign language into something comprehensible. So congratulations for that. Sweet. So now let's do a recap. We saw we cross a forgetting curve with space repetition and active recall. Our brain strengthens over time and will become sharper and more focused in a day-to-day lives. Now let's see what, where we are. We can see that we know our classes or types of sub objects are equal to the blueprints. And then new instances are equal to the houses. The equivalent of blueprints and houses for classes are blueprints and instances are individual houses. Then we saw that data through attributes gives us the state through the snapshot of the object. Then the functionality hits through methods, which cannot be both magic or dunder methods. Dunder for double underscore methods. We saw that classes have data through attributes and functionality methods. We can think of attributes as variables that belong to an object and methods as function that belongs. Mesh admit that as functions that belong to an object. Dunder methods for double underscore, also called magic methods, are methods that have special functionality and we should only manipulate them when we want to work with that specific functionality. The init method is add dunder method of a class that will run every single time we create an instance of set class. Then we know that self refers to an instance itself. We pass it as the first argument to all methods within a class. You could use another variable, name instead of self, but you could use any name you want it, but it's what we use for convention and to make your code more readable by other programmers. And finally, let's look at the understand section for today. We have for questions for today. Again, read through them, pause the video right now and then go through these. If you need any help, feel free to post any questions in the chat and the community will be active there. And if not, you can feel free to reach out and we'll be helpful through, through there as well. Good luck with these and I'll see you again tomorrow. 22. Day 19 - OOP - Inheritance: Welcome to Day 19, the circuit today's objectives. The first one is to look into another advantage of having an open mind. And the second is to look into class inheritance. We're going to look into what parent and child classes are. With that, let's jump right into learning section. Having an open mind allows us to look at things objectively and wherever a better way to do something arises, will be able to quickly adopt it and improve. An open-mind prevents us from staying with our old way simply because it may have been the way we've done in our entire lives. With an open-mind, we can look at all options and choose the one that works best. This approach quickly makes you stand out over all the people who lead subjective opinions get in the way of the decision-making. There are situations in which we want to create a class based off of another class. One class inherits from another. The higher level class is called the parent class. The one that inherits from it is called the child class. Let's look at this example of a class that we have as a parent class. My parent class. We're going to document. It will be a deadlock string. Then let's define an init method to add the self initializes an instance of my parent class. Then we're going to say self equal to. We're going to add in as a parameter into this method. Then we're going to say print. We're gonna say f string of and say you just initialized, Misha, initialized an instance. My parent class. Then we're going to say print c equal to up here. We don't really need the upstream put down here. We do argument equal to argument. Awesome. Now we're going to add in one more method, which is simply gonna be my parent method. We pass in self. Simply, we're just this is simply a method, a method of my parent class. The only thing we're gonna do is we're going to print parent method ran. That's why we're gonna do now we have our parent class, we have the inner method and we have my parent method. Then we're going to define another class, which is going to be my child. My child class. Then when we want to for inheritance, when we want to inherit from another class, we want to pass in my parent class to the children class. Again, this would be a doc string. Then we would define the init method. Say we want to say self. Then children argument children argument child. And then down here we simply say equal to child to child. Then we're gonna print simply something to log in. You say, just initialized, initialized. New instance of my class, my child class. We're going to say the F string with then child Lord. Finally, we're going to have child method. My child method that is going to take in self and it's simply going to print. But I'm going to add a doc string method. My child. Simply going to print child method ran up here you can see that I called in a super, super function, which is simply calls and it references the parent instance. So it's going to reference the parent class, is going to initialize it passing in the argument. When we see down here that we have this argument, would pass it into the function called in from the parent class. And that would initialize the parent class. If we had other arguments in here. For example, are R2 or something that we have had more arguments. We would add those additional arguments here as well, R2, and then we would pass it in R2, we would simply replicate everything that is in the parent class, and we would pass it in to the child class as well. But in this case we only have one argument, so we only do one would call the super function will cause the parent class. We initialize it, pass in the argument and then we simply run it as any other initialized any other constructor method. And it's also add some documentation to this instance of my child class. Awesome. Now when we do, when we do my child, let's say my child equal to my child class. They'll pass it in argument one. Let's say value one, value two. Then we're gonna say My child my, and then run the methods, my child method. Then we're going to see them. My child also has my parent method. When we run this, we're gonna say, okay, you just initialize an instance of my parent class because they're super, again the super function called sin, the parent class, and then initializes it. When you call the init method from the super, super references, the parent class, and then it initializes it with the argument that you pass in. That's why you say we're printing here. We just initialize the instance of my parent class. Then you get argument value one. And then it says you just initialized in incidence of my, my child class, are you argument value one and value two? Then you see that nothing else happened, that the methods didn't run. And it speaks simply because we didn't call them the right way. We need to point that would went through reference them by using the, the round brackets. When we do it this way we can see, okay, child method ran, parent method ran. And they both ran by using the child class, which inherited from the parent class. A couple of examples in which we might want to use inheritance can be. One isn't. For example, if we wanted to create an app for a school, we have a person class. And then as the parent class, the person class would be the parent class. And then we could have a couple of children classes, which can be student, the class and the teacher class. We can have the person which can have many attributes for a person which could apply to both the students and the teachers. But then we can have some more specific applications for the students and the teachers separately. That can be an example. Another example it can be you can have a parent class if you're trying to do a NOP for something related to dogs or pets. You can have a parent class called dog. And then children classes for the different breeds are the different types of dogs that you use in future. You can have erased dog, where you can have a show dog or you can have a pet dog, does deter a different applications that you could use. Inheritance, inheritance that might come in handy. Grid. So let's do a recap. Now, being open-minded allows us to adopt the objectively better options regardless of any prejudice we may have. Initially. We can create child classes that inherit from parent classes by adding the parent class in the definition like Blackstone, following syntax as in class, child class, and within the round brackets, the parent class. Class inheritance works when we want to create a subclass and not repeat ourselves by having to rewrite all the transferable data and functionality. We use a super built-in function to reference the parent class within the child class. Whenever we use a child class, and the child class takes precedence for any data or functionality before Python searches through the parent class. And finally, we have the understand section. You have five questions for today. Again, if you have any questions on these, feel free to ask and in the community because we'll be active. They're not that it's great and then good luck with this and we'll see you again tomorrow. 23. Day 20 - Rest Day :): Welcome to another rest day. Wow, congratulations for making it this far into the course unless they incredibly excited to have you here, because it means that you were able to overcome the hardest part, which is the first couple of days, you managed to stay consistent up to this point? It's like a train when it's at full stop, getting at in motion is the hardest part. But then it gets easier and easier over time if you're consistent before you know it, the train's moving at top speed and the effort you need to make is to keep it there. Because an object that's already in motion stays in motion unless there's a force that works to stop it. Make sure to review any lessons or anything that might be helpful. And I'll take a second to remind you about the three keys to effective learning for consistency. Just come back each day and give it everything you have. Congratulations for putting the training motion. Now I encourage you to take advantage of this momentum you're carrying and to finish a final strategy strong and to keep it on learning after spaced repetition. Active recall is an excellent bringing exercise. Combine this with rationally recovery and you'll crush the forgetting curve. Finally, for questions or the answer, keep an open mind. Be curious and approach learning with a beginner's mind. There's always a new path we haven't walked through. So awesome. Enjoy your rest day. Make sure to tackle any questions that you have from previous days. And I'll see you back here tomorrow. 24. Day 21 - Files: Welcome to Day 21, the circuit today's objectives. First, we want to look into the importance of being consistent. We're going to revisit that. Next, we're going to look into files. We're going to look into everything about files. So let's jump right into learning section. As you keep coming back, you keep reinforcing the habit of learning and novelty and you're making it easier for yourself to come back to each day. If you're here. That means you've already done a great job at this. So congratulations. Why files? Well, so it turns out that there are a great way to use already saved data or to save new data created by your program. To open a file, we use the open function. And the open function returns a file object. So we're going to create a variable called file. And we're going to pass it in what is returned from the file, the open function. The open function receives the filename, filename dot TXT for example. This would be what's called a relative file path because it assumes that the file is already in the same folder that we're currently at right now. But an absolute file path would be something like this. This would be an example of an absolute file path. Will you pass it in every single folder from the root directory? This is an example of what a Mac OS system would use. And if you had Windows, you would add a C colon before the dots would file path. But in here we're only, we're only gonna be using relative file paths. In this example, we already have a file created a text file, which is this one that says This is the first line, the second line, and finally left third line dot TXT file, and it's already in the same folder I'm currently at. It's called sample.txt. And since it, since it's not sustained folder, we could use a relative file path. So I could say example TXT. This would open that file into that file object. The first thing we need to know about file objects is that they have what's called the current position. And to look at what the current position is, we simply do file object or that file object and then do the tail function, the tail method for that object. And we can tell that it's at the 0 current position because it starts at the zeros third current position. That means that the current position is currently here. At the very beginning of the file. There's another method called, called the reading method. And that method returns something that we want to print to the screen. If we do file object, read, this method where it's going to do is it's going to start at the current position, which we can tell right now from looking at the tilt telling method. It's just 0 position is going to start at the current position and it's going to go all the way to the end. If we don't specify another character here, if we tell the file object to read it, it'll start at 0, and it will finish at the very, very end of the file. So we can see that there's a first line, second line, and finally the third line. This is exactly the same that we're getting from our text file that we created beforehand. Right now if we were to say the file object duck tail method, we could see that it's at position 58, V0, say $1 away from 0 all the way to the end, which turned out to be positioned 58. How do we go about going to the first position again? Well, how do we change the position going back to the very beginning or to another place within the file. Well, there's another method for that, which is called the Seek method. If we seek 0, then we go back to the, the position 0 again, the very beginning of the file. Because if we were to read the file, for example, free to read it and then try to read it again. Every time it reads it in here and read it, and it went all the way to the end. The current position went all the way to 58. That's why whenever I run file object read again, it didn't print anything because they need to run the Seek method first to take the current position all the way back to 0. And then I can read it again from the very beginning. Whenever we open a file object in Python, we can see that it has the file object, the attribute closed equal to false. So when you look at the file object, Closed equal to false right now. And we could use the close function or the close, the close method file object, close to close the file. That way, whenever we run the close file, we can see there's equal true and we want to close our files after using them. Afterwards, we're done using them. In order to reduce the usage of memory off our script. There isn't even more straightforward way to use files in Python, which is by using the width, the width statement or the width block. In this case, we use with open. And then run the filename, which in this case is example locks dxdy. As file object. Then in here we run the functions or we run the code that we want to be using our file file for. In this example, we're going to use a for-loop line. In file object. We're going to print the line. We're gonna see that it prints every single line in the file object. Now because the file already contained new lines in here, whenever I do this, I'm adding a new line, a new character, since it already has a new line. And the print function every time it runs, it adds a new line as well. That's why it's adding two new lines at the same time. So to remove that, we can use the strip method. And that way we get the file without the additional newlines. The good thing about the width statement is that whenever you use a width block, every time that the width block finishes or ends, it'll close the file automatically. It'll open the file as a file object. Then you can use the file object. You can use a for loop to loop through every single line in the file object. You can print each line. And when this block of code finishes running the file, we'll get, we'll get close to automatically without us needing to state that explicitly. Turns out that the open function we can pass it in the file path as well as the mode. So far we haven't passed in the mode yet, since it uses the R has a default. R is for reading open a file for reading only. So, so far we've been implicitly stating that we're opening the file for reading. But there are other types of modes that we could add and we could use, for example, W is to open a file for writing only, and this will delete the file if it already exists, or create one with that name. If it doesn't exist already, then the x is four open for exclusive creation, failing if the file already exists, then a is for opening for writing, appending the very end of the file. So a is for appending. B is for binary mode, using this along reading and writing. And T is for text mode, which is the default using that along the reading we're writing mode. So B and T, T is the default and B would be, wouldn't, we wouldn't want it too bright for a binary, a binary file. Then plus is for opening for updating, reading and writing. Some examples are plus, which would mean open a file both for reading and writing without truncating first. And then w1 plus which are opening the file to both read and write. Truncating the file first. To open the file for reading in binary mode, we can use RB, which has reading and then binary to append to a binary file used AB. Text files contains strings file binary files contained series of bytes. Said another way, the text files are human readable and binary files are not. An examples of binary files include images, videos, and compress files. And finally, we could use the mode file object attribute to get them mode in which the file was open. So as an example of how we would create a new file, we could do something like this example, dot TXT. Then we're gonna say right as file object. Then in here we can use the file object, object, right, method to write new text. In this case, what will happen whenever I go back to my file, this was my text file. Whenever I go back to this example dot TXT file, it wouldn't include all of this. If I went back and try to open that file. This is the file that I would get if I went back to find her and tried to open that file. Because the w what it does is that it truncates the file first and then it writes to it. And the write method is used to write enough to append to the end of the file. With direct method, there are certain things that you might want to consider. For example, the carriers return the new line or the line endings characters for, for the texts that you'll be appending. Since it depends to the end of the line, you can use these characters for each one as a carriage return the new line in line endings for both Windows and the units for Mac operating systems. Sweet, so let's do a recap now. Files are a great way to save data outside of the current execution of your program. The open built-in function accepts a file path, which can be relative or absolute paths, and it returns a file object. You can use the open function and then file object methods such as read, tell, seek and close methods. But the more convenient way of working with files is but the width statement, using the width open file.txt as file object statement has the advantage that the file is automatically closed after the block or the code block executes, even if an error happens to print all lines in the file you can use for line in the file object and within the width block, and then print each one within the for-loop. Then there are different, different modes. You cannot reopen function. The default is RT, which is reading and text. And a common one that you can use as the r pluss, which opens a file mode. In text mode for both updating and reading. A common mode can be R plus, which opens in text mode for updating, reading and writing. And finally a set over to the understand section. Today we have three questions with that have to do with handling files. So good luck with these and let us know if you have any questions in the community section, it will be active there. If not, good luck with these and I'll see you tomorrow. 25. Day 22 - Exception Handling: Welcome back to day 22. Good. Today's objectives, we have errors and exceptions in handling exceptions. It's about exceptions today. Let's jump right into learning section. There are at least two types of errors. We have syntax errors and then we have exceptions. If we were to run this code, we would see that we would get a syntax error, invalid syntax because this syntax isn't valid. So that would be the first type of error. And then if we try to run something like this, like a 0 division, we would get a 0 division error and this would be an exception. The same if we ran the code below, we would get a name error because Pam is an undefined variable is not defined. Then finally, if we tried to add a string as an, as an, as an integer, we would get a type error can only concatenate strings to strings. We would get a type error, which is another type of exception. We can see here how exceptions can come in different types. So the, the examples that we showed before, we're ZeroDivisionError, name error and type pair, we can use a try and except except block to handle possible exceptions that may arise. What this does is that it will try running the code block under the try statement. And if an exception is raised, it will stop running the try-block and go check the except block. If the exception raised matches any of the exceptions in the except block, then that block will run. What does this mean? We have a try and except block. Let's look at an example of an actual use case. We have here a while loop, while true. So this will go on infinitely unless something happens on this break happens where we're going to try this, we're gonna try to userInput. And we're going to ask the user to please enter a number. And then we're gonna say number. We're going to transform that into an integer. And then we're going to break, except if we get a value error. If we get a value error somewhere around this try block, then this except block will run and then we would print to the screen invalid number. Please try again. When would we get a value error? Well, whenever we get something like if we got a letter as an input, whenever we try to int a letter, we would get a value error or something like that. Let's try running this as an example. Please enter a number. So if I did W, it'll tell me invalid number. Please try again and see how the while, the while loop, it runs again. Because we handle the exception and then the while is equal to true, and then the code block runs again until I try again, I'm gonna keep getting something the same iteration of the same iteration until I enter a valid number, for example, three. And that would mean that the code would run successfully. It will break, it'll get out of the while loop and the code would run successfully. If we wanted to, we could add more types to be caught by the except block. We would add this by using the tuple notation. For example, in here, anything that would be raised as a value error, a type error or a Neymar would be caught by this except block and then this code would run after that. This is how we would enter different or several types of exception, exceptions to be copying except block. There's another way that we could use the except block. And in this way without entering anything or anything, any type of exception, this would work as a wildcard and this would catch every single type of exception that were to be raised by this try block. This is not recommended necessarily because if an unforeseen exception, where do we raced in here, it would be caught by this except block. And if this would, the code to handle that would run even if we weren't expecting that exception. Using a wildcard is not recommended. Using a single, a single value or a single type of exception is the use case. I will see the most often because that's what we will try to predict a single type of error and we will handle a single type of error in the exception. Exceptions don't just stand all exceptions when they raised or they happen in immediately. And the try-block, if we were to reference our function here, would raise that assumption still, then that would be called, that would be handled by the exception as well. For example, if we had this as a function, just simply return int of the argument, then in here we would use num equal num equal turn in function. Then user input. If we were to run this and then say a would stay involved number, please try again until we inputted a number and then it would run successfully. But here is meant to see that if you had a function reference somewhere, somewhere else at the error happened in the function instead of in the actual code directly. The air, since it happened in the same code block, it would be raised and would be handled less expected. You can define your own exceptions by inheriting from the base exception class. Here we're creating our own class or own exception, which is called air. And it's inheriting from the base exception from here. So we inherent the exception that would be the parent class and this would be a child class. And in this case it would be an exception. Most are defined with names that end an error. That's convention. You can also chain multiple exceptions. So if I were to create a couple of errors there, this one would inherit from from this air, from the parent there. And I'm going to say class. Second. This one would inherit from the first error. So you can see how there's, there's kind of like a tree of inheritance happening here. Now I would say for class in, I'm gonna say error. First, their second there. Want to try. I want to try and use the raise statement. Run a race each class. Except, except the secondary. Print. Second. Most except you can chain except blocks. First, they're going to say print. First. Finally, accept air. And I'm gonna say print. What happens if I run this? We would get OK error, then first and then second. Because for the first error, the first one, we could see that when it tries, when embraces the air. So it goes from four class in narrow, it starts in there, the try-block and racist de air. Then it will follow each except block. When it goes except secondary, it falls into not the secondary. And if false follows the next except error, then it falls the next except block. And it says, if this areas the first area, since it's not, it falls through third except block and then it finally ends up printing the air because it falls through this final error except block. Then the first hop is the same, The same. The first will fall into first and then the second follows him to the second. But if the except blocks were reversed, for example, if this one would have been in here, then this one would have been in here. We would get every single time the air era, an era because every single error falls into the air class since of the errors. And all the classes inherit from the same base exception from the same root error. That's why we get air, air, air. We print every single time the first except block. That happens as we saw in the previous example, the race statement allows the programmer to race a type of exception, The sole argument race indicates the exception to be raised and this possibly be either an exception instance, throw an exception class. An exception class being a class that derives from the exception, the base exception, as we saw up here, if an exception classes passed implicitly instantiated by calling its constructor with no arguments. So this means that for example, this error class has passed. It would initially instantiate this air class. And if we had our constructor in this class with a constructor in this class, then that constructor would run because it would be instantiated. Looking back at this previous example, we were also going to look at what the L statement is. Really simple, it's really deal statement simply happens whenever the try-block runs successfully. So for example, if we wanted to add this break part, we could add it into the else statement. We could print success, success as well. This way, this allows us to make sure that we're isolating lines. So in this way, we're isolating these two lines, two for the try-block and we're not including the print and the break statement into the try-block. This is a good way to isolate the exception handling to a couple of fewer lines. Instead of generally stick to something that might not be what we're trying to aim for. In this case, when we run this code, would get the same behavior as the other code. We're trying to input letters, it doesn't work. Numbers would let us. It doesn't work until we put an actual number. And then it says success, the code finishes running. Awesome, So that's where we kept now. There are two types of errors, syntax errors and exceptions. Exceptions come in different types. Some common ones are ZeroDivisionError Neymar and type there. We can see the Python documentation for it to be exhaustive list. We can use a try and except block to handle exceptions. Python, we'll try running the code block within the try statement. And if an exception is raised, able to check the except statement and run that code if there's a match. Like everything else in Python, exceptions are simply objects of a certain class. They are all a subclass of the base exception built-in class. If you want to create your own exception, simply creative class that inherits from exception, which already inherits from base exception. And by convention exceptions and in error. The race statement can be used to explicitly raise an exception. Finally, let's look at the understand section. We have five questions for today. Remember that these are, this section is pretty much the most important section because it's where we actually get to learn what we're seeing in the learning section when we take action and actually do these questions. So good luck with these. And if you have any questions, feel free to post them in the community section in the chat, and we'll be active there. But either way, I'll see you again tomorrow. 26. Day 23 - Modules and Python Standard Library: Welcome to Day 23. And let's look at today's objectives. First, we're gonna start by looking into breaking limiting beliefs. Then we're going to start looking to modules, the Python standard library, apologists like comics Python. And then to look into mainly just not reinventing the wheel. Let's jump right into learning section. I want to take a second to let you know that you're coding now, today is the last lesson of actual concepts. And after this, you'll be ready to give a project to go and use that to connect the dots of what we've been learning so far. Congratulations for coming this far. I truly admire the commitment to coming back and getting to this point. If you used to think to yourself, I can't learn how to code. That was one of your limiting beliefs. Then you've officially proven yourself from, I find it to be very exciting to prove ourselves wrong when it comes to limiting beliefs. So the question starts to turn into, what other limiting beliefs do you want to break next? For now, let's sit into our last conceptual lesson where we're talking about modules. Module is simply a file that contains Python objects all the way from variables to classes and functions. You can import a certain module into your Python script and then be able to use everything in that module on your script without the need to rewrite any code or to have to reinvent the wheel. To start, let's look into how to import our own main.py file sass modules. Let's look at this example. We have this scratch to not pi, and then we have one function. And we have some random class right here. And then we have some code that bronze whenever a script runs, and instead of running scratch dot py. So if we were to run this code would see running scratched up Pi. And then that would be the entire code. It turns out that we can import this is the contents of this file to the objects from this file to a separate file by using the input statement, simply calling the scratch the other name of a file. If it's in the same folder, we can import scratch two. And now in here we can simply call the contents of Scratch to, for example, yet to function. We could call this and then say, for example, print scratch two at T2. And then we're going to add two to the number five, because we can see that the U2 function simply returns the argument plus two. We were saying we print the item that is returned from that at two function that is called from this import, imported file. Let's see what happens here. When we run this. We see running scratch to dot py and we see the number seven. So we basically expected just a number seven because if we're just running this code, this crash two, we only expect to have the number seven come out. Why did this running scratch dot t2 or scratch to dot py come up when we run this code, only this code. The thing is that whenever we import a file, that file would actually run. This file would actually run wherever it's imported. So that's why it brand and it printed sprint. So it printed this phrase that we had on the Scratch to dot py file. So how do we handle this? It turns out that by convention there's a way to handle it and among type it out. And then I'm going to explain how it works, but it's pretty much the following way. So if name equals to main, then, then we want to run main. The main function. Main. He's going to be equal to whatever code we're running in this file. What does this mean? We're basically creating an additional function called the main function. And we're adding the main contents of the file. Then we're saying if name equal to main, then run main. What is this name, name thing? What is it? It turns out that it's an attribute of the file itself whenever. And that's just one of those, an example. I'm gonna run this file and I'm going to print print name. When we run it, we see okay, print name, we see that its main. So the name is equal to main, so that is why it prints the name sprints main and then it runs the deaf, the domain function as well. But it turns out that when we run the function from a separate file, in this example, when you bring in from here, when we run scratch D2, we see that we don't get the function printed to the screen, but instead we get scratched off to print it to the screen because that's what this print statement did. This print statement costs to this scratch dot t2 to print because the name attribute will be different if we run this script directly or if we run it from an input statement. So now if I remove this statement from here. And I leave that statement as this as a def main function. And then if main name equal to main, run main, then whenever I run this we would see expected result, which is just the number seven. But just to keep the convention up-to-date and to make sure that we're keeping the convention of what we're running. We're going to run the name equal to main again here because we also want then run main. Then up here we're going to define main. And what we're going to do, the actual script that we're trying to run in here. Okay, so now if I save this and I run it, it runs successfully because whenever I run it directly, if name will be equal to main and then it will run the main function. And then it'll call the imported script, which is scratched too. But it won't run the main code of Scratch to because we've wrapped it in the right convention. Now let's take a look at Python standard library. Python standard library. So library of modules that comes with Python installation. The library has modules with very helpful code. For example, there's a module to parse CSV files, to logging for us URL requests, JSON parsing in many other more. Let's start with an example of a module called time. Once we import the module, then we have everything available to us through that import. We can see through this shorthand auto-fill that we get a bunch of things, facilitate it to us. Let's look at the example of the sleep function. We're going to pass it in the number three. Then we have a print hay and then print there. Then we run this. We'll see that it prints, hey, it waits for three seconds and they print stamp the sleep function as an example function that we import the time module and then use the sleep function to have a code sleep for three seconds or however many we input into the function. And then another example is a local time function, which when we run, when we print what we get back from it, when we run it, we get some information about the local time, for example, in the year 2021. And then we get some more information about the time locally. This statement, the import time, would import the entire module. To import a specific function from the module we did use from time import sleep, for example. Then in here, the advantage of this inputting snip is that in here we wouldn't, we wouldn't need to add the time specification. So we could just say sleep straightaway because we have it available to us. Now when we run this, we're gonna see what we get an error. We get a time not defined because time is not defined. So we would need to remove the time from here, but then local time is not defined either. If we went to import local time as well, several different functions that we could use it like this separated by a comma. Now we would get the same result as before. Another example from a module is the random module. And then we're going to use, which wouldn't be from nanomolar, would be import random. And then we can also do Alia sets for what we import. We can say input random as Rand if we wanted to. So now we have that random shorthand. Instead of having to provide random. For example, we can have my list through an example and say a, B, C. And then there's a function in the random module that's called shuffle. So we could do random or rand shuffle and then pass it in my list. And then we're going to print my list and see what we get. We get a cdb. The shuffle function from the random module is going to shuffle all the items in the variable that we pass it. In this case, we pass it in a list. When it takes in that list, shuffles the items and then it changes or updates to this, but the new shuffled items. So it's HTTP instead of ABC. We could also use the LES in the following way we could do from Random import, import, shuffle. This a shot. Then in here we don't have random defined. We don't even have sharp, the shuffle defined. We're going to use sharp defined. And then run this again and see what we get. We get a, b, c because it turned out that that was a random output, but then we get a CB, then BCA, you can see how we're shuffling list that we passed in the meeting. There's another way that we can import everything from the random file. We can say from Random import, import all, which is a star from randomly important of all. And that would mean that we can reference every single item in Random module. We could reference it straightaway without having to reference anything else. You can save shuffled because it's already imported, then we could run this and this would run fine. The problem with the import all statement is that we don't want to use, we don't really want to use this and it's dangerous, dangerous to use it because we might have conflicts with what we have defined already in our functions that we have already in our code. One last thing to mention about modules or packages is that they're even packages that you can download online. Actually, one of the greatest advantages of learning Python, that since it is still popular and powerful at the same time, a lot of developers around the world have written amazing libraries with modules that you can download to do amazing things without having to write the heavyweight code on your own or having to reinvent the wheel. So you can actually look up online for packages, for modules that have a lot of functions and functionality that you could use without rehabbing to reinvent the wheel. Some examples or some machine learning packages are some statistics packages that you could use. The really interesting things out there, get access to the public libraries. It's as easy as using a package manager to download those libraries and then using them in your scripts. This example, I'm gonna be using pip, which should come with your Python installation. So in my case, you can try pip in my face is PIP3, so you can trip it through us as well. I'm gonna say pip3 install pandas, which is a very famous the dataframe module. I downloaded pandas and now they've downloaded it means I can reference it in my script. I can save pandas. And right now I have all of the, all of the usually used as kind as SPS. I can say PS. And now I have everything from that module available for my script. So there's an example of how you would download a public module from using the Package Manager and then using it in one of your scripts. But suite for now, let's do a recap. Today was the last conceptual lesson to course you're coding now, you've made, you've made it this far, so congratulations. Modules are used in Python to take advantage of code that is already been written and avoid reinventing the wheel or rewriting code or staying dry with a coding so we do not repeat yourself. You can one input your own dot py files as modules to import any modulus when Python standard library, which were installed when you install Python or three, you can install modules written by other developers around the world and then import them using using them on your scripts. Every script has a name attribute. When you run a script directly, this attribute will be equal to the string main. And when you import a module, that module file will be running with the name attribute equal to the script's name. Since every time we import a dot py file has a module, the file runs. We use the if name equal to main syntax as written in the main code of the script under the function we call main by convention, there are several ways to import depending on the purpose of what's being imported, you can do import the module name or from module name input module object, or from module name import all which that last one is not recommended. You can use aliases by using as my LDS, or you can use pip three to download install modules all around the world. This is what I mentioned before. So you get run pip in your command line and say pip install the module that you want to install, to install from the library. And finally us look at the understand section. We asked three questions for today. Feel free to ask any questions that you might have on these in the community section or the chat section, because we'll be active there. And if not, good luck with these either way. And I'll see you again tomorrow to start with the project. 27. Day 24 - Project - Python Learning App (1/5): Welcome back my friend into day 24. Let's look at today's objectives. So today's wanted to be the first day of the project. So we're gonna start by downloading the project from GitHub. Then we're going to look into some more contexts from the projects files. And then we're going to see some techniques, some useful techniques from concept that we already know, but something or some new ways that we can leverage that knowledge that we already have into some useful techniques for the project specifically. So our final project is going to be a Python application, which is going to be a quiz app, which we will be running through our command line interface, which we've also been calling our terminal. It is an app that will quiz you on the knowledge that you have on whatever you want. And in this case, we're going to do in our Python knowledge, you will be able to practice our active recall techniques. We'll be able to practice our space repetition and all of that with the purpose of remembering everything we've learned, the concept of the structure of the application will let you quiz yourself with any topic on any questions that you link, and it'll keep a score so you know what topics need more attention and what you need to look into more in depth. So let's look into the application for now to download the files that we'll need for the project. Let's go into GitHub.com. Here. Here you're going to search. You look at the search GitHub, you're going to search for magnetic. Python Learning. Github is simply a place where people can share the code or you can think of it as a patriot. People could share their code around the globe. So here you can see that if you go to cognitive ease, my repository and then the Python learning repo, which stands for repository. Here you can see there's a README which with a description of how the project or how the Python script works. Then what we're gonna, we're gonna be doing is we are going to be downloading the file as a zip file. So you're going to click on here, that's gonna download the zip. And then you're going to open that SIP. Soil opens up the Python folder. And now you'll see that you have three different JSON files. One dot p-y, the main file, the main scripts, and then a read me, the README simpler file that you're, that you're seeing down here. This is the read me file, just a welcome page and an explanation of what the script does. Then you have the main file, which is the main project that we're gonna be working with. And then we have these three JSON files, which are the data that we're gonna be using to store the questions, the topics, and the past scores file. So when we open up this file, the main file is gonna look something like this. When we run this Python three main, we're gonna see that our application is running. So you're gonna see welcome to your new Python learning app. Select a topic to review and you will be asked to Mexico ten questions per run. So good luck. And this is the main application. Now how this works is that simply you select a number of the topic that you want to be reviewing. Let's do one for now. So you would want, would be selecting the strings topic that has two questions, will be due one and Enter. We're going to be asked, we're gonna be prompt, okay, one of two questions and what doesn't learn function? Do I know for now that the Len function returns the length of an object passed into it. We're going to see, we're going to say C or C. That is correct. Good job. And then press any key to continue. I'm going to press Enter and then continue to the next question. Then I quick question too of to explain the following statement. Print. Okay, it's self format. It's a format function. I know that it's going to be, let's say a was gonna save that is correct. Good job. Press any key to continue. And then it tells me unbelievable you scored a 100% and then enter yes, to run the app again, enter any other q to quit. I'm going to say yes to run the app again. And I'm gonna see that the previous score for the string, strings topic is populated now it's 100% now because I did it the last time in Xcode up a 100%. That's how the script is running. And now you can see that you can run and you can play around with this however you want to. Let's say, for example, right now six, I want to the all section. This gathers questions from all topics and it gathers a random number of ten questions. So you can see, let's see in here we want to save the last item of a string of the list that would be B. That is correct. Good job. I'm just going to be there's going to be a again, that's correct. Good job. Um, there's gonna be randomly doing some letters. You almost got it. The correct answer was, and it tells me the correct answer when I do it wrong. You're almost guarded by trick question the correct answer. What is the immutable? Okay. I'm just doing it randomly here. I'm getting all wrong because I'm doing them randomly. And let's see, you scored 40% and then if I do yes again, I want to try it again, then exceeded 40% in here. And if I tried it again on 100, that will repopulate this into a 100 and as the previous chord. But now you can see more or less how the app branch, and that's pretty much what we're aiming for to do. What you're gonna do right now is that you're gonna do, you're gonna look into the main Python script, select everything and delete it. Because this is a probably doubled gonna be working with. Then the question is file, you're gonna be using this, we're gonna be using this as well as the topics file and as well as the past scores file, which in the beginning was empty, an empty JSON string. What I've asked you to do right now is to play around with the scripts before actually before deleting the contents, play around with the script. So you know what the, what the functionality of it is. Because, for example, one other functionality that we have is that every time that you ask the question, for example, if I do topic one against strings, this order of ABC is randomized. It's always like a different order. That's a good example of something that it doesn't functionality. And then another functionality that it has is that a maximum of ten questions. For, for example, a section has more than ten questions such as the all section. And I did all I said I did before, it would only ask a maximum of ten questions. That's another thing to take into account, always randomly as well, that it selects always randomly questions and always in a random order of a, B, C, and D. So take some time to familiarize yourself with the script. Now you know how it works. And also go through the README, goes through the README file or through in the repo, you can see it more readable. Go through the readable Read Me file and then you'll understand more about the functionality of the code and where we're trying to aim for. So first of all, how do we read a file? Well, we talked about reading files already and now I'll show you how we can work with a very common file type in programming called JSON. Json stands for JavaScript Object Notation. And we can think of these files as if we're looking at a Python dictionary. So let's look at the questions JSON file for example. We can see how it's very similar to a Python dictionary. We can see right now that the key would be this number one. Then the value for that key would be all of this within the curly brackets. Then within these curly brackets, which is a dictionary of itself, we would get different keys. So topics, question options, answer as different keys, and then each key with a different value. So this value would be list. For example, this value would be string. This value would be another dictionary. So we can see we have a dictionary within a dictionary, within a main dictionary. So a JSON strings that starts here and ends all the way down here as a curly bracket. So it's pretty much, we can think about it as a Python dictionary. In this question is file, we can see that question one has the topics, strings, lists, dictionaries, and then question, the actual question which is one doesn't lend function do, and then the different options we have, the ABC different options. And then of course we need the answer. We need the right option for the right answer, which is the letter a. But in the actual program when it runs, it actually shuffles these answers and understands intelligence, which is the correct answer. Well, how do we actually improve? How do we actually load the contents of this file into our main script? What we do here, what we do, or what we use here is the import, the JSON library, which is in the Python standard library. So we don't need to download it, which simply import it into our file. So to use the Import the JSON library, we use it as follows. If I were, for example, in the folder width my, my files I want to read through. I would go to this folder and then I would use in the import JSON statement. And then I would do with open as we saw in the other section. Let's do topics, for example, the topics file. Let's take a look at topics file. It's simply a dictionary width, five keys and phi values. Very simple dictionary. Let's look at the topics JSON, JSON file as file object. Then we simply use, let's do the print statements and we use the JSON library. We use the load function and we pass it in the file object. Let's actually call this. Instead of printing it right away, we're going to call this file load JSON. Dot load file object. Now when we print, when we print the file load, we see that it has the contents of the file as a dictionary. Because when we print type file load, we see it's a dictionary. Then another example that will be useful for us to use today would be the JSON dump function. How this one works is that we'll use, for example, with open. We're gonna be using the past scores in this course, and then we're going to pass it in the W, the W option, which lets us write to the file. And then I want to say file object. And then we're gonna say k JSON dump. Then we're gonna say file load, which references the previous file load that we had, we had stated. Then we're going to say file object. Then when we read we read past scores for line in. Actually I still need to close it up in here. And as file object for line in file object, print line. And unexpected this I think it's gonna be missing parenthesis. Of course, print file object that's not defined. Keep making object. We can see that it has the contents that we expected because we inputted into the file. We're also going to be using a function called shuffle from the import from the shuffle from the random, sorry, the random library. What does this function do? And we've seen this in the past in one pass section. But what this function does is that if we have a list, we have B, C, and D. Let's say. Then we said, we said random, shuffle my list or pass it in my list. Then when we print our list is going to be shuffled. So BAC d, it takes in an argument as a terrible argument and it returns a shuffled version of that object. Another useful function to know is one from the OS library. We import the OS library. And then when we do OS system, this is as if we were inputting or sending to the command line or statement. If we did clear up here, the screen would clear this one. What would this statement does is that if we do input system, it'll pass in whatever string you pass it into the system function. It'll pass it into the screen as if it were, as if we were calling it ourselves. If we said the clear function, it'll clear the screen for us. So we'll do the equivalent to this one. See if we were doing clear. But that would be, that would work for the Mac OS system. If you had a Windows operating system, you would use OS system. Instead of clear, you would use CLS. In our case, command not found because that doesn't work in an opera and our operating system. But if you have a Windows operating systems, TLS would work for that option. The last one that we're going to look into, the last technique that we're going to look into. That if we wanted to quit our program, if we wanted to quit, if we're running a code and we want to quit or exit code, we would race An exception of very specific exception which is called system exit. In this case, it won't work. It won't work in the iPython environment as we expect it to. But when you raise a system, exit your code. For example, let's find it. Then. Exit. When you raise it in your code, it'll, it'll quit the program. So whenever you see in here, let's run it again. Whenever you see Q enter, that's actually calling the system the race, the system exit exception, and it's quitting the program. So that's how that's working. That was it for today's techniques. And that should be enough to get us going and to get us in control of what we're trying to get to for our final project. Awesome, so let's do a recap now. First we saw we've downloaded the zip file from GitHub and looking at the Python learning repo, repo stands for repository. Then we saw the README file. How did useful info on the functionality of the project? And the project has three dot JSON files, but the data relevant to the project and one dot py, which is the main file with the actual script. We also saw that JSON stands for JavaScript Object Notation, and we can think of it as the equivalent to a Python dictionary. Then we saw the questions dot JSON file that has a sample questions to be asked by for learning application. We could even add more questions to this file and they would be included into the Python broaden or the Python script. And finally, we saw some useful techniques. We saw the import JSON statement to import the json library. We saw the load function to load a file object, and we solved the dump function from the JSON library as well to dump a dictionary into a file object. We also saw that important random or the random library and we saw the function from the random bilirubin that we could pass in a list to get shuffled. Then we saw that the OS library and how we could use the system function to clear the screen both for Mac and for Windows. And finally, we saw how we could raise a system exit exception to exit the program and to have it quit from running. And now let's take a look at the understand section. For today. I wanted to download the project from GitHub and run the project and play around with how the project bronze and think about how the data files or the bud dot JSON files a useful to run the script. Also delete the contents of the main.py file and start asking yourself questions on how you would go about programming that yourself. And we'll start coding together tomorrow. So good luck with these posts. Any questions that you might have in the chat. Again, we'll start coding the program will start coding the final project tomorrow. See you tomorrow. 28. Day 25 - Rest Day :): Welcome to another day. Okay, you definitely keep killing it. I want to congratulate you for coming this far into the course. I'm being serious when I say that most people don't even come close to this point. And this very different, what makes you stand out from the great majority of people who simply decide to quit early on. Consistency is a skill that you improve on over time. And that's exactly what we've done here. I want to tell you that I appreciate you for being here. As you know, today's all about resting and revisiting any previous lessons on topics we think we could internalize a bit more. I'll also take this time to remind you of some of the keys to learning. For consistency. It's exactly what we're doing. Coming back to each day. Each day you build more momentum. Think of stuff as trained that might be hard to start, but once it's moving, the hard thing becomes stopping it. For space repetition. Review what you've learned space through time, through active recall, an excellent exercise for your brain. Combine this with some quality rest and recovery and you'll be crushing the forgetting curve in no time. Finally, for questions or the answer, be open-minded, curious and approach learning and daily exercises with the beginner's mind. There is always a new path we haven't walked through. If you think you've covered all of them, think again, I hope you have a good rest thing and I'll see you back here tomorrow. 29. Day 26 - Project - Python Learning App (2/5): Welcome back into day 26, and this is going to be the first day of coding into the actual project, the final project. Let's give it a go. Once you downloaded the files from GitHub, you should be looking at something like this. You have the questions file, topics file, the past core file, and then the main main.py file should be empty because should delete everything in it. And that's what we're going to be doing for the final project. So to start, let's start by writing the defining the main function in writing that setup, it'll look something like this. And then inside the main function is where we will start writing our code. The first part of the code that we're going to be writing Is a function to load the files, the load the data from the question Jake JSON, topic states on the past cortex, that is going to look something like this. I added the doc string to the main function that says run it runs the main code. Then I added a function, a function that is going to load the JSON files. And then I pass in the three files with the three strings of the name files, three strings with the filenames. Then it returns the questions, topics, and pass course in dictionaries into these variables. What would be the load? The definition of the load JSON files function. Well, the function is gonna look something like this. We define the JSON file. So the load JSON files function. Then we have a, an arbitrary input of filenames. So we can put input any number of names that we wanted to, and it would get turned into a list into the filename. That's what we do down here. We create an empty list with the resulting loads and then we loop through the list of filenames. And we open each file as a file object and then we do a current load is a json load from the load JSON load function from the file object. Then we append the current load into the resulting loads list and return that. Listen the end. Notice here how we imported the JSON library. We could use a json load function. Again, when we return a list, we can see down here in the main function that we unpack that list too. If we input three files, we expect three outputs in that list. And that's why how that works. Then down here, after we load the files into these new variables, we want to have all the data compiled. We're gonna see this compiled data new variable. And we're going to create a function called create compiled data that uses the questions, topics, and pass course dictionaries as inputs. And then it outputs they compiled data dictionary. What is this function going to look like? So we go up here and we create a new function called called compiled. Create compiled data is passed in the questions, topics, and pass course. So let's look at what this function does. It takes him questions, topics, and pass course all the dictionaries. And this function, what it does is that it creates a compiled data from the content's loaded from the question topics and password files. The first step we do is we create an empty dictionary. Then literally the first step we do is that we go through this dictionary, that the topics dictionary go through number and the topic and just append the compiled data, the number, and then add in a dictionary as the value with the topic, with the topic name. That's the first step that we do. Then we create this additional, additional. So we'd look at the length of the compiled data and we add one and we create a string out of it. And we add this additional field that's called, that has the topic as the Oldfield. This is a field that is going to have all the questions and will not be constrained by the individual topics. But we'll have of a comprehensive list of questions. When we look at the output screen that the project has, we can see that it has the list of topics and then it has a null category. We thought the questions inputted into it. That's pretty much what the data that we're trying to get into the compiled data, we're trying to get the, the number of the idea of the topic. We're trying to get the topic, the number of questions, previous scores, and then the list of question IDs that are appended to each topic. So that's what we're getting down here. We get, we create a data value with the question IDs as an empty list. We're looking at the individual data key and data value in the compiled data items. And this was a compiled data again, remember it was the first dictionary we created. What we're trying to get here is we've tried to populate the question Id is 40 for each topic. In the beginning, what we do is we do an if statement that it goes if the topic is not equal to o, it does something and if it is equal to o would go running to this else statement and it will run something else. So let's look at what it does in, up here. If it's not equal to all, what it will do is it'll look at the question items. We will look at all these questions, these questions as dictionary and key and value pairs. And then it's going to look at if the data value, if the topic is seeing the value topics. The topic that we're looking into right now is in the question topics. Then it'll append, it will append the data to your question Id list, which started as an empty list. It will append the key of that question. What we're getting here pretty much as a list of the topic with a list of question ID setup related to that topic. So for example, strings would have the question I D number one because it is included into that topic. Finally, if it is an L statement, so if it's not in the O section, it's simply doesn't filter any, any topic at all since it includes all the questions. So it goes through the question items and it's simply appends all of the keys to that question ID key into that data value. That's what happens in this for-loop. And then finally, we looked at the data value, the questions count, and we add the length of the question ids count to get the total questions in that, in that category. And finally, we add the past course. We get the pass score from the data from this one. When it's empty or simply inputting into that past score field. Then it finally returns the compiled data. That is what we get down here. A compiled theta. If I did down here, if I ran print compiled data, I've saved this, then I run this. Let's look at how that looks. It's kind of messy right now. But you can see that it has, for example, a key, which is number one is the key. And you can see the topic. Topic is strings and then question ID user ID number one in question ID number eight. Because if we were to go to the questions, we would see that the, the question number one has strings in it and then none of them has string in it until number eight, which also has the topics Scoring Strings in it. That would be the list of question I guess related to that topic. Finally, you have the actual question IDs. So again, you have strings, the question ID is 18, and then question count would be equal to two because that's the number of questions it has in the past score is equal to non. Then number two. So the key number two is the topics. It will have the list topic than question ID is 10041011. And you can see how it goes around. Now we have a dictionary with the compiled data. So that was the goal of today. The main goals getting this compiled data dictionary in place. That was it for today's main part of the project. So make sure that you take a look into these loops to make sure that you understand what's going on here. How you import the data, how you load the data, and then how the compiled data dictionary is created. So good luck and post any questions that you might have in the community section. I will be active there. And either way, I'll see you again tomorrow. 30. Day 27 - Project - Python Learning App (3/5): Welcome to Day 27. So today's going to be the second day or the 31. Day 28 - Project - Python Learning App (4/5): Welcome back In today 28. And where we left off with the project was that we prompt the user to input the topic ID. The next step right now is to create an instance of a new class that we're going to create a new class that's going to be called the quiz class. We're going to create the chosen quiz, and it's going to be the quiz class with the inputs of the topic ID, the compiled data, and the questions. We're going to go up here and we're going to create a class called quiz. And we're going to add the doc string that's going to stay represent a quiz based on the compiled data on the specified topic. Now we're going to build the constructor. The constructor is going to have the self topic ID compiled data and questions as inputs. And then it's going to initialize the quiz Instance. And simply down here we'll select self topic ID equal to topic ID in this how we set the instance attributes. Finally, right here, right down here, we randomize the shuffled the question, two questions to ask. And down here we can see itself questions to ask. It's a compiled data topic ID to question ID. So we have the question to ask, and then we simply randomize or shuffle the questions to ask. So we have a random order for this. Here. We can see that it's not defined simply because we haven't imported it yet. So now you just need to import random. And the side from the init method, we're going to have a method that is going to run the quiz. It is going to be called run quiz and it's going to be a class method to run the quiz instance and return the score and the range size or number of questions asked. So down here we create our method. So we're gonna start off with a score of 0. So we start off with that. Then we create the range size, which is going to be a minimum of ten. The length of the questions to ask, because we don't want to be asking more than ten questions. Then we create an index for a for-loop for the index between the range of that range size, which again is going to be a maximum of ten. Then it's going to say, okay, current question is going to be from the questions we're going to get the question to ask index with that index. Then we're going to clear the screen to ask a question. And then we're going to run the asked question function runs. It, will run it and we'll return true or false for an for a correct or incorrect answer. If correct, increase the score by one. So if questions asked question function, correct, if it's correct, It's going to increase the score by one. And if it's incorrect, it'll simply keep the squared of cities and then it's going to say input any key to continue. Finally, we will have the score and the range size returned by the, by the end of this method. So the next thing we have to create a DSP question which is going to be a function. So we'll say down here, define asked question function and it'll have the following inputs. So question, question number and total questions. So the first step is to create an empty list that will be populated with the questions, options and then shuffled. So here's what it'll do. It'll create an empty list popular with the questions, options and then shuffled. Then we'll create a tuple with his first seven letters of the alphabet. And then the shuffled options dictionary will have the options in the random order. Next we print the question prompt. Then we print shuffle options for the user to choose from. And then we define a correct answer for the question object by saying the correct answer. And then we prompt the user by using the validated input function. And then we define a user answer from the shuffled options. And finally, we compare answers to determinate correct or incorrect, and return true or false respectively. Finally, we're going to go all the way down to the end of our main function. And we're going to this line of code just to run the run quiz method from the chosen quiz instance. And it will return the score and the range size. Now if we run our code, we could see we get to the main screen. Let's say, let's say two for lists, enter two. And now we can see, okay, how do we make a copy of the list? We can say that C is going to say yes, correct. Good job. And notice how it's saying to question two of a total of four questions, what is a way to remove? Should be B, the pop method, that's correct, Good job any key to continue. And then what is the length function do brings the length or returns the length. It's going to be B. That is correct. Good job. Finally, what is the lift selecting the last item on the list that should be better, be that extra good job. Perfect. So it ran the quiz successfully. That should be it for today, guys. Thanks so much for watching. If we're still missing a couple of steps, but we'll review those tomorrow. And then if you have any questions, feel free to post them in the community section and make sure to review the steps that we've done to make sure that we understand what we're doing. And I'll see you again tomorrow. 32. Day 29 - Project - Python Learning App (5/5): Hello my friends and welcome to day 29. Today we pretty much all set with the project. We have created all the functions that we needed. We created the class and the method, and the methods that we needed. And we're pretty much all set with all of that. The final steps are to handle the scores. To pretty much get everything ready for the user to be ready to finish off the learning section. We're going to start it off by adding a clear call so we can clear the screen. And then by, we're going to compute the final score. So if underscore is going to be the inversion of the introversion of 100 times a score over the range size. We can get a percent, percent number. Then we do the past course topic and we do a string of the final score plus that percent sign because this is what's going to go into the final or the past core topic ID. That's what's going to go into. Then we use a width block to open the past courts JSON file in write mode. And this would truncate the entire file. And it will open it as a file object as this file object. And then we're going to use the JSON dump function. We're going to pass it in the dictionary, the past course dictionary. And we're going to pass a file object. It's going to pretty much overwrite the entire file. But since we had the past course dictionary already from before, from the loading, before, we should get every single version of the other past course as well into the file. And we should overwrite only with the updated version, with the new topic ID updated into it. Then we're also going to add an if statement with else-if statements and an L statement that is going to say, okay, if the final score was 100, you're gonna say unbelievable. You scored 100%. If a final score was above 90%, excellent job, you scored 90% or above 90%. If the final scores above 80, awesome, You scored whatever score use coordinate and if not, if it's below that, you're going to say, no enthusiasm is just going to say you scored whatever score you scored. The last step is going to be to add this. Another try input. And it's going to say yes if you want to run the app again and no if not. And it's going to say if another try not equal to yes, you're going to break. So what is it going to break? It is going to break a while statement, a while loop that we're going to say while loop, while true, loop through everything. We need to put in the appropriate indentation down here. So everything is within the main function. Then, now we have everything on a while-loop. And if the user inputs anything that's different from a YES is going to break the loop and it's going to finish the code. So let's try running this again and let's see what we get. Let's do tuples. So let's do number four. How do you remove the last thing I have a tuple or trick question. Tuples are immutable, so be correct, Good job. Whereas the correct example of creating a tuple, it is with round, round brackets, so it's a correct Good job. Awesome. You scored 100. Enter yesterday on the app again and you'll locate a continuum, I'm gonna say yes, awesome. So we can see that right now. We just go to a 100 and we have 100 and tuples. What if we did modules, for example, let's do number five. I'm going to try to get an incorrect on purpose. So which of the following statements can be used to import the JSON module from the library. I'm gonna say that are going to say you almost got it. The right answer was all other options. Press any key to continue, and it's going to tell me you 0%. So whenever I do yes and go back and see that it's 0%. But if we did it again, then said All other options. We see That is correct, Good job. And then we see you score a 100%. And we see that we get a 100% to pass the course. So we see that our code is running smoothly. We are running our learning app successfully and everything is working as we expect it to. So great job from getting this far and congratulations for completing the project. And they should be helpful to any other concepts that you wanted to add, waning other ways that you wanted to leverage. This way of quizzing yourself. It can be helpful for other topics as well in a way that you can leverage the topics and the questions for your personal use and doesn't, doesn't have to be for Python only. And you can add questions to this question file and ask questions for it for whatever. You might find a use for this too. 33. Day 30 - Endings Are New Beginnings: Amazing. You finish the course and I want to congratulate you for coming this far. You are an outlier. Most people don't finish what they start, but a few here, that means you're not one of them. So congratulations. You've learned that it's all about coming back and giving it everything you've got. And that delayed gratification is what brings the best rewards. And now we can see that endings are simply new beginnings because there will always be a lot more to learn in Python in any other skill that you learned, even the best performers and masters of their skills are constantly learning and pushing themselves. I wanted to thank you for coming along and embarking on this journey with me. And I hope you enjoyed and learned a lot. And I also want to invite you to stay on this learning path because you'll see that you're capable of doing things that you've never imagined. Thanks again, and I'll see you around very soon.