YTread Logo
YTread Logo

Learn Python with Jupyter Notebook from scratch

Feb 23, 2020
Hello and welcome to the introduction of this course. What you should know before taking the course. Must have basic working knowledge of using a computer. You should also have basic working knowledge of using the Internet. Who should take this course. The course is designed. for beginners in Python and Jupiter

notebook

also designed for beginners in coding and programming in general. What will you

learn

in the course? We will start by installing Jupiter Notebook. Then we will

learn

how to run the typical

notebook

server. We will learn about some of the most common ones. Jupiter Commands we will learn about the components that make up the Jupiter notebook we will learn how to explore the notebook dashboard we will explore the user interface within the Jupiter notebook who creates the notebooks we will look at Python expressions Python declarations we will take a look at variables and how to create variables in Python, we will take a look at data types in Python, we will learn how to convert data types, that is, how to change from one data type to another, we will learn about Python operators, we will learn: about conditional statements. learn about loops you will also learn about

python

functions the course format is video based and the duration is 2.5 hours thanks for watching bye for now hello and welcome to this video what is jupiter notebook jupiter notebook is an environment interactive computing that allows users to experiment with the code and also allows them to share the code.
learn python with jupyter notebook from scratch
Jupiter is an informal acronym that stands for Julia Python and these programming languages ​​were the first target languages ​​of the Jupiter application, but today laptop technology supports many other languages ​​as well. a document that can consist of live code, rich text, interactive widgets, equations, video images, etc. These documents basically provide a complete and independent record of a calculation that can be converted to various formats and then shared with others. Hello and welcome to this video. In this video, I will show you how to install anaconda and also how to set up Jupiter laptop. To start, open the Google search bar and inside the search bar just type anaconda distribution, press enter and select the first one in list, so I'm going to click on this one here that says anaconda Python slush or distribution, do Click on that and it will detect the operating system you have.
learn python with jupyter notebook from scratch

More Interesting Facts About,

learn python with jupyter notebook from scratch...

If you're running a Mac, it's going to detect that you're running a Mac, so I'm just going to scroll down to the bottom here and right at the bottom it's going to detect my operating system, so it's detected that I'm running a Windows-based operating system and it's going to detect me. presents the Windows installer at the time I'm recording this video. the current version is 3.7 when you visit to do your own download the version may change just download the latest version you see so to download I have under Windows there are two links one for 64 bit and one for 32-bit I have a 64-bit system, so I'm going to click on this 64-bit graphical installer so you can see here it's downloading in the bottom left corner of my screen.
learn python with jupyter notebook from scratch
I wait for the download to complete and then I will Run the installer, the Anaconda installer has completed the download so that's it so to run it I just double click to start the installation so its trying to start just do Click Next and then click to accept. There are two ways to install it. You can install it only for your user profile, which is a recommended one, or you can use it or install it for all users. If you are going to use all users, you need to have administrator privileges. I only want to install it in one profile so I'm going to click on the top option which will install it just for me so I click next and then it tells you the destination folder where I'm going to install it, it tells you the space required 2.9 gigabytes and tells me how much space I have. is available, so make sure you have enough disk space in your designated installation directory, so I'll click Next and accept this option here that has been checked and leave this one that has not been checked. it says not recommended so I will click on install to install so we will just wait for the installation to complete so I will just give you a few minutes to run the installation once the installation is complete you will get this as completed and just do click next button and click next and then if you want to know more about anaconda cloud you can leave it checked.
learn python with jupyter notebook from scratch
I'm going to uncheck it. If you want to know more information about anaconda, you can leave it bookmarked. I'm going to leave this unchecked and click finish. Another way to configure Jupiter Notebook is through the Python package manager, known as pip. This is recommended for experienced Python users only, so before setting up Jupiter Notebook with people, you should make sure you have Python. installed and then you need to make sure you have the most recent and updated version of the Python package manager, which is known as pip and the way you can do it if you are using a Mac if you have a MacBook. installed with Python version 2.7, so if you want to update personas on a Mac you will have to type P 3, which means it refers to personas three and not version 2.7, so you need to do the space install of P 3 on a Mac. - update pip and that will ruin people if you are on a Windows computer you don't need to type pip three just type pip install - - update pip and it will work with the latest version of pip and then if you want to install TripIt on a laptop using the Python package manager type pip three if you are on a Mac installation on Jupiter, if you are running a Windows computer type pip space install Jupiter, so if you are doing this on a Mac, obviously you have to do it in your terminal.
If you are installing on a Windows computer, you must do so at the command prompt. For new users, it is highly recommended that you install Jupiter notebook using the Anaconda way because if you install Kondeh, Anaconda will also install Python and Jupiter notebook, so let's take a look at what Anaconda has installed, let's go to our programs menu and we look for the Anaconda folder, so this is my Anaconda 3 folder, if I expand it. we can see what you have installed, install the anaconda browser, the anaconda PowerShell prompt and a condom message, the Jupiter notebook, which is what we're really interested in here and then we have these spider reset settings so we can see it here installing anaconda too. install jupiter notebook so that's all for this video in this video we install anaconda and anaconda we also install jupiter notebook for us thanks for watching bye for now hello and welcome to this video in this video i will show you ways to start jupiter notebook, you can start the jupiter notebook server from the command line if you are using a windows computer that will be the command prompt if you are using a mac or linux computer that will be the terminal so once you have opened your command line command, type this command Jupiter Space Notebook and that will start the Jupiter server.
The other way to start the Jupiter notebook server is from the all programs menu on your Windows computer if you go to the anaconda folder within the In all programs there should be an icon for the Jupiter notebook. You can also run it from there. Once the Jupiter Laptop server starts, it opens the Jupiter Laptop in your default web browser and it does so on localhost and the port it uses is dual. eight double eight let's start the Jupiter notebook from the all programs menu on our Windows computer, so if we click on our programs, we're going to start all the programs and there should be the Anaconda folder three, so if you expand it and inside you will see the Jupiter laptop so just click on this and it will launch, it will launch a console screen like this and then it will also launch the Jupiter laptop in your web browser, this is what the Jupiter laptop panel looks like once you have started the Jupiter laptop. and within this area of ​​the panel here it gives you a list that shows a list of notebook files and subdirectories in the directory where the notebook server was started, so if you start the Jupiter notebook from the all programs menu, it will It will boot from the root directory. where Jupiter Notebook was installed and also lists some directories and subdirectories of that root directory, so your directory listing will be different than mine depending on what you have in your specific directory where Jupiter Notebook started within the root of your directory.
Most of the time you can start a notebook server in the highest level directory that contains notebooks. Basically this will be the root directory and can also be the home directory if you are on a Mac or Space computer, you can also specify the directory you want the laptop to start from and it does this by starting the Jupiter laptop server from the command prompt while the Jupiter laptop is running inside the console area here, so if you look at the terminal interface, here they come online gives you a lot of information here, it tells you where the laptop starts from, so which is serving the laptop from the local directory which is on my C drive, in the users directory and then in the profile manager, okay and then you tell it where the Jupiter laptop is running in the web browser, which is localhost colon double 8 double 8 to shut down or exit the Jupiter laptop server, you are going to control the dash C on your keyboard and that should close the Jupiter laptop server once you close If I shut down the server Jupiter nobu, you will not be able to access Jupiter laptop in the web browser.
You can see it here because I brought down the server. You can see here. I can't contact the server. I have shown you how to start the server. Jupiter Local Server from the programs menu on a Windows computer that opened the console and also opened the laptop in your web browser at localhost colon 8080 8 8 I'm not going to show you how to start the Jupiter laptop from the command line, which is the command prompt on a Windows computer, but the process is the same in the terminal. Please note that when you start Jupiter Notebook from the Anaconda folder within the All Programs menu, it will start from the root directory of your profile. where Jupiter notebook was installed When you start from the command line, you can specify where you want it to start.
I have a project directory here, it is an empty directory. I'm going to make the Jupiter notebook start from this project directory. so to do that I go to all programs and inside the anaconda folder we have the anaconda prompt so this is what I'm going to use so I click on the anaconda prompt and we wait for it to start so that you can see the directions. I, the base, which is so this is the default where the Jupiter notebook will start, okay, unless you change it. I want to change that to my desktop, so I make desktop CDs.
I press enter and make CD. There is a folder called projects on my desktop. I'm just going to use CLS to clear the screen, so now I've navigated to this folder here called project, that's why I want to start the Jupiter notebook, so I just type Jupiter Space Notebook, press ENTER and it will start the Jupiter notebook in the cities that try. to start it, you can see it here because there is nothing in that root directory, so you can't see any subdirectory here because the actual directory is empty. Now you can see here. He told me where Jupiter's notebook is served from. you the path the directory path it's always a good idea to pay attention to what's going on in the console in case there's something you're not sure about or it's not working the way you expect, so run the Jupiter laptop from A specific directory is also useful for project based things, so if there are certain things you want to keep in a specific directory, then you can serve the Jupiter Laptop server from that directory.
In this video, I showed you a couple of ways to start Jupiter. notebook was born from the command line where you could specify a directory from which the i

python

notebook would be served and I also showed you how to start it from the anaconda folder within the programs menu or from your Windows computer when you start it from the anaconda folder There is a Jupiter Notebook icon that you can run and by default it serves Jupiter Notebook from the root directory of your profile and when you open the Notebook interpreter it opens in your default web browser on localhost colon 8080 8:8 port. number double eight double eight so that's it for this video on how to run Jupiter portable server thanks for watching bye for now hello and welcome to this videoin this video i will show you some common and useful jupiter commands, all jupiter commands are prefixed with jupiter keyword before subcommands are issued, jupiter keyword basically is the main namespace for all subcommands .
Let's take a look at a table that shows some common Jupiter commands. This is a table here and we have some useful and commonly used Jupiter commands. The first one here in the table is the command to start the Jupiter notebook. Just type Jupiter space notebook and that will start the Jupiter notebook app. If you want to see all the available commands that Jupiter has and also want information, just type Jupiter space dash dash help and that will show you the available commands that Jupiter has if you want to see the location of the configuration directory, type Jupiter space dash dash calm - dir if you want to see the location of the data directory write in jupiter space - - data - dir if you want to see the location of the runtime directory write in jupiter space - - runtime - i/o if you want to show all jupiter directories and the search paths that type Jupiter Space - - path if you want to print the directories and search paths in JSON format, type in Jupiter Space - - JSON, so let's open the command prompt in anaconda and show you how these work commands.
I am going to illustrate how these commands work on my Windows. computer I'm going to go to all programs and I'm going to look for the anaconda 3 folder, which is this folder here. I'm going to expand it and select the anaconda message. I'll click on that. and it should open this console, this Seminole. If you are doing this on a Mac or Linux computer, you can do it in your terminal so you can see the staging base, which is the base directory where the Jupiter notebook application will be launched. thereafter if I want to start the Jupiter notebook application and I don't want the web interface to show this is the command I will type or I will type the Jupiter space notebook and they make a space - - no - browser, that means it will start the Jupiter Notebook but it doesn't show me the browser interface or press ENTER and that should start Jupiter Notebook in this base directory but even though it gives me the location of the web browser interface it won't start it because I said no I don't want it the browser shows to shut down the server, just type control - C and that will stop the server, so let's stop it now that we have issued these commands.
I just control C and that will stop the server, okay? You can see I did a C control and shut down the server, so I'm going to clear my screen by typing CLS so I can type more commands. The next command I want to type is help. command, so if I want to see the available commands about some information, I just type in Jupiter space - - help, if you don't want to type help, you can type - H which will also do the same and press ENTER. see here, it gives you information about Jupiter Laptops, it tells you to say here Jupiter Interactive Computing and it gives you some optional arguments, all very useful information and to clear the screen again, type CLS so you can type more commands, the next command.
Start typing is to show the location of the configuration directory, so I just type in the Jupiter space and it will be - - config - d.o.a press ENTER and that shows me my configuration, direct the following command. I want to show the location of the data directory. so type Jupiter space - - data - dir and press Enter. You will see that it shows me the location of my data directory. If I want to show the location of the runtime directory, we type Jupiter space - - wrong time - dir, press ENTER and that gives me the location of the runtime directory if I want to show all the Jupiter directories and the search path , I type in the Jupiter space - - path with an S and press Enter and that will show me all the paths, okay, it shows me the location of all the Jupiter directories and their search path, you can see quite a few are listed.
The final command I'm going to type is going to be a command that will print the directories and search path in machine-readable JSON format, so type that. in Jupiter again space - - J Sun and press Enter, you can see here you are giving me the way, so in this video I showed you some commonly used commands of Jupiter, thanks for watching, bye for now, hello and welcome to this video in this video. We will take a look at the components of Jupiter Notebook. The Jupiter Notebook application is a client-server application. A client-server application is basically a distributed application structure that divides tasks or workloads between peer resource providers or a service which are generally called servers and service requesters which are generally called clients, so the server represented by this box here is the resource provider and then we have the client in terms of Jupiter Notebook, which could be your web browser because Jupiter Notebook also has a web page. component which is a web browser that will act as a client to the server, so the client will request services from the server, which is the provider of the resource in a client-server application, it can also provide resources to other clients and the clients can include other computers They can be remote and you can access the server which can be remote over the Internet using different types of clients like your mobile phone, your laptop or your computing device.
The main components of the Jupiter laptop include the laptop web application. We also have the kernel and then we have the notebook documents, so let me give you a brief overview of each of the components of the Jupiter notebook. The first is the notebook web application. This is basically an interactive web application that you can use to write and run your code interactively. You can also use it for all four notebook documents. ii The component of the Jupiter notebook is called nuclei. Kernels are basically separate processes started by the notebook web application and usually run in the user's code and run in a given language.
The default language is Python. but it can run in other languages ​​and what it does is return the output of the laptop web application to the laptop web application and the kernel basically handles things like full calculations for tab completion introspection of interactive widgets and other fragments, for what the kernel basically interacts with the notebook web application the third component is called the notebook document the notebook document is basically a self-contained document that contains a representation of all the content that is visible within the notebook web application this includes the inputs that it has and also the outputs that are produced from the kernel, okay, it also includes narrative text, images of equations, it can also include videos, rich multimedia representation of objects and each of the notebook documents has its own kernel, so there is a kernel for Python, there is also a kernel for other programming languages. so that's it for this video in this video I have just given you a brief introduction to the various components of the Jupiter laptop thanks for watching bye for now hello and welcome to this video in this video we are going to take a quick look at To to start, we have to start the laptop server, so I'm going to do this on a Windows 10 machine, so in the all programs menu I have to look for the Anaconda three folder, which is this folder here and there.
There is an icon here for Jupiter Notebook. If I click to run this icon, it will start the Jupiter Notebook server from the root directory where it was installed. If I don't want to start it from the directory it was installed in, I can use it. this anaconda prompt command and then specify a directory where it should be launched from, but for this video I'm going to launch it from the default, which is where it was installed, so I'm going to click on the Jupiter Notebook icon and it will launch. In this Jupiter Notebook interface, you will see that it launches the web browser and also launches it here, so from here you can see where Jupiter Notebook is running.
It tells you to serve the notebook from this local directory, which is to see the user manager and it will list everything. in that directory inside the dashboard, so let's take a look at the dashboard, this is what the Jupiter dashboard looks like when you first start the laptop server, your web browser will open in this laptop dashboard, the Dashboard will basically serve as a home page for the notebook. The main purpose of the notebook is to display the notebooks and files in the current directory, for example, the current directory is shown here. This directory sees large users like the administrator and will list what is in that directory, which is listed here. will be different from mine because what you have in your directory will obviously be different from my directory, okay, and then we have the breadcrumbs at the top here, at the top of the notebook list, breadcrumbs will be displayed here that are clickable, all of them are clickable. current directory breadcrumbs by clicking on these breadcrumbs or these subdirectories in the notebook list, you can browse your file system, so if you want to see any of these yet, yes, you can see they are all clickable links to their respective directories, that's fine if you want.
To see what is running in the panel, click run and it will show you what is running right now. You can see that there is no terminal running, there is no laptop running, and if you want to upload, you can click here to upload files, etc. you here when these subdirectories were last modified, they still need to name the arrow here is basically used to sort the list of the subdirectories of the directory in this list here you can see that the arrow is pointing down, which means it is sorting them in alphabetical order if you want to sort it another way, let's say from Z to a.
You can see the arrows went up and flipped it and arranged it from z to e, so I'm going to put it back and then you can see here, this is just a reference. to the file size, if you want to exit the panel, you can click exit or you can click log out. I'm going to log out and that successfully logged me out of the panel, okay, and then if I want to log out of the server, just type this command here Ctrl C and that will close the Jupiter server, so that's it for this video.
Thanks for watching, bye for now. Hello and welcome to this video. In this video we are going to take a look at the user interface of the laptop. When you create a new notebook or when you open an existing notebook, you will be presented with the notebook user interface. This user interface allows you to run your code, although your notebook documents it interactively. The notebook user interface has three main areas. We have a menu. In the toolbar we have the notebook area and the cells. I have my dashboard open and I have a notebook inside my dashboard.
Right now the notebook is not running, so to run it I will simply double click on it and it will run. the notebook, so you can see here the notebook is running. Now you've introduced me to the UI, so I'll start with the menu bar. This area here is known as the menu bar and the menu bar has menus for actions in the notebooks. The notebook cells and the core communicate with the file here, basically, you can use this file option inside the menu, you can use it to rename the notebook file and then you have the Edition that you want to edit and go see. you have insert allows you to insert cells a bowl or cells below this here is called cell ok this border area here is called the cell where the code is and then you have the kernel that is running right now we have widgets so it can save the notebook, the status of the widget, you can clear the notebook, you can download the widget, etc., and then you have the help menu, okay, but this area here is known as the menu bar. and then we have here this line here is called notebook toolbar point.
Well, the toolbar has several buttons for the most common actions, so if you want to see what each of the buttons does, just hover your mouse over each button to learn more. For example, if I overlay tells it it's a safe and control point and it tells it it's inserting a cell, this is cut selected cell, copy selected cell, paste and this says move selected cells up, move select one cell down, this allows you to run the cell this way. interrupts the kernel this restarts the kernel with a dialog and this basically restarts the kernel the notebook has mood indicators the mood indicators basically tell what mode the cells are in if they are in edit mode or if they are in edit mode command, you can know that in command modeif you have a blue stripe around the cell, then if you click here if I click on this now, if you have a green stripe around the cell, it's in edit mode, so you can see here this icon here tells you that it's in edit mode if I click out of edit mode and you can see that it is now displayed as command mode, so it is very important to know that there are two indicators so that you can identify by the colors around the cell, for what if you have a blue color around the cell, a command mode which means you can issue a command if you have a green stripe around it you are in edit mode which means you can edit the previous code you have in the cell, also here within the toolbar area that we have.
This icon here is a command palette, so if I click on it, I get the command group, so if you want to use shortcuts to configure things, you can do that from here, all the navigation and actions in the interface of the notebook are available using the mouse. through the menu bar and the toolbar that are inside the notebook area, so that is the menu bar and this is the toolbar so you can use the mouse to navigate through the various actions that you want to perform to select a cell with your mount just click on the cell and that selects it and if you want to change the mode for example the mode right now is edit mode just click outside the cell and change mode to command mode, so that's it for this video in this video.
We take a look at the laptop's user interface. Thanks so much for looking. Goodbye for now. Hello and welcome to this video. In this video we are going to create a new laptop before creating the uniboob. I just want to point out a few things about a laptop. will have the file extension dot ipy and will also be a notebook that consists of three basic types of cells: they are code cells that will include the input and output of Tyrone's live code in the kernel and then we have the markdown cells which are text narrative containing embedded latex equations.
We also have plain cells that include formatted text. Notebooks can also be exported to different static formats including HTML and PDF. Before we can create a new workbook, we need to start the server so that the Jupiter notebook server is ready. I'm going to start it from a specific directory. I have a directory on my desktop called My Notebooks. It's an empty directory right now, but this is where I want the Jupiter notebook server to start. Any notebook I create will be inserted inside this directory, so to start, I go to my terminal, find my anaconda folder, and then click in this that says anaconda prompt, this will give me the message that will give me the default location for anaconda and I'm going to change that to start from my desktop and on my desktop I'm going to change the directory to a folder called my notebooks, nice and simple I'll clear the screen, so now I'm in the directory to start. the Jupiter laptop server.
I just type Jupiter Space Notebook and that will start the Jupiter Laptop server in that directory that I have specified, so I'm trying to start the Jupiter Laptop, so this is the dashboard and you can see the dashboard here, this is the root. The directory for this directly on my desktop here is what the Jupiter laptop panel points to. It's empty right now because there's no list of laptops, there's nothing in that territory, so to create a new laptop there's a new option that's new to you. click this new button at the top here and these are all called cores, so the colors you see here depend on what's installed on the server.
These are my available cores and I'm going to click on Python 3 because I want to create it. in Python 3, a new cell will open, this is what it's called and if you see here, the default cell is a code, okay and if I click on the dropdown, you can see the other time there's a tick down and there's a row and it's going to convert, but we're going to leave the default, which is code, so I'm going to click on it and this is where you can type some live code, so I'm just going to type print and just say hello. wall, so I just wrote a simple print statement that will say hello world and to run this cell, you can click the Run button here or you can Shift and enter, okay, so I'm going to click run. and that will run the cell, you can see here, it has given me the output of that cell, so we notice here that the notebook has no title at the moment, so I need to give it a name to do that.
Double click on it and I'm. I'm going to call it Hello World and then I'm going to click this rename button. You can see that the name of the notebook has changed. If you want to see the notebooks that are currently running, you can click on your home screen here and you will be able to see this. is running, you can tell it's running because it has this green icon next to it. I only have one laptop at the moment, but it is possible to have multiple laptops running at the same time and while the laptop is running there is a box. here you can check if you check it, it gives you some options, you can duplicate the notebook, you can close it, you can view it, you can edit it and you can also delete it, so I'm going to uncheck that box, but you will see those options. when you have the box checked, if you have it checked, check that the options disappear if I look at my project directory on my desktop, you can see here that you have saved the notebook, this is the notebook here with the extension IP Y and B. has saved in my projects directory, if you have other notebook files you can also upload them using this upload button or you can simply drag them to the notebook area here in the panel, the notebook shows the green icon when the notebook is currently running and the notebooks stay running until you explicitly turn them off.
Closing the notebooks page is not enough to turn off the notebook, so if you want to turn it off, click this check mark there and then there is an option to turn off the notebook. Notice: I have closed it. down and the icon is now no longer green so that's it for this video in this video we create a new notebook thanks for watching bye for now hello and welcome to this video about what is Python Python is a purpose programming language Generally this means that it can be used to write computer programs for various things, such as games, data science websites, etc.
Python is also a high-level programming language. High-level programming languages ​​mean that languages ​​for writing computer instructions in a way that is easily understandable and close to human language Python is portable, which means that we can run Python programs on different operating systems like Windows Mac OS Linux without no change Python is an interpreted language Python is called an interpreted language because it goes through an interpreter that converts the code correctly into the language understood by your computer's processor Python is strongly typed strongly typed languages ​​do not convert data from one type to another type automatically Python has a huge set of libraries a python library is a collection of programs that you can incorporate into your own program without writing code for them, let's look at a list of types of applications you can create with python web applications these are applications to which which you can access using a web browser android apps these are apps that run on android devices like android phones and tablets games you can create various types of games with python scientific applications you can create various types of scientific applications with data management applications Python systems so you can use Python to create applications to monitor various types of systems you can also create console applications a console application is basically a computer program designed to be used by a text-only computer interface, let's take a look at one list of software applications that have been created using Python, so some of them are quite famous and popular.
The first on the list is YouTube and then we have Google, we have Dropbox. The program allows you to save files to a cloud-based service that you can then access from anywhere in the world. We also have reddit. Reddit is one of the largest open communities on the web. You have a question that you want to talk about something specific. or if you want to find tons of information on a particular topic, for example, gardening or anything, you can search Reddit and find related information. Next, we have Spotify. Spotify allows you to listen to and add free music of your choice.
This is a streaming service that allows you can stream music without ads finally we have Instagram Instagram is very popular it has an app and also a website these are just a few items in the list of software that were created using Python there are many others, but These are just a few fields that you may have come across, so that's it for this video on what is Python. Thanks for watching, bye for now. Hello, welcome to this video. I will introduce you to high-level and low-level programming languages. What are high level programming languages? These are languages ​​that only humans understand, so computers cannot understand them unless they are forced or interpreted.
They need an interpreter or a compiler so that the computer or machine understands what the programming is trying to do so that it makes high-level examples. Programming languages ​​include Python Java C Sharp C++ PHP Ruby and there are many others What are the low level programming languages? These are languages ​​that only machines can understand. They don't need an interpreter or a compiler. They are closer to the computer hardware. Examples include machine and assembly language: This is a brief illustration of high- and low-level languages ​​so you can see that the closer the language is to the machine hardware, the far away it is and does not need to be interpreted because it is very close to the computer hardware, whereas the further away it is like we have these basses here, the further away they are in the hard way, so they need to be easier for programmers to understand because they contain words related to English, but they are not understood by the machine, so the machine understands what this block says to be converted to machine code using a compiler or interpreter.
Differences between high and low level programming languages. High-level languages ​​are easier to learn. Low-level languages ​​are more difficult to learn. They are languages ​​close to humans, as easy to read as basic English, while low-level languages ​​come from peer languages, so only machines know what they are talking about. You need a translator like a compiler and interpreter to convert a high-level language into a machine language. We know that a translator is needed for low-level languages, called the machine hardware, knows what they are talking about. Programs written in high-level languages ​​run slowly because they obviously have to be compiled or interpreted.
Our programs developed in low-level languages ​​are much faster. running because there is no compilation or interpretation in the hardware understands the language so it is easy or easier to execute the instructions. These are the key differences between high-level and low-level programming languages. Thanks for watching and goodbye for now. Hello and welcome to In this video, I will introduce you to compilers and interpreters. What is a compiler? A compiler is used to translate all source code into machine language before the code is executed. Basically what that means is the computer stops the computer. To understand what you're trying to do, you have to use a compiler to compile or translate, convert your code into machine-readable code.
Okay, examples of languages ​​that compile with languages ​​that you should compile before the code. it runs ropa cyc plus plus so let me illustrate how the compiler works so let's say you have your source code and your source code is basically your computer code you're right so let's say inside the source file you have this. You have x equals 7 y equals 8 and then the sum equals X plus y and then you want to print the value of the sum using the print function. Now the computer won't understand this, so what should happen? You have to use the compiler to convert that code into machine code, machine code is something like this, computers only understand zeros over one, so the compiler compiles it into machine code and then runs the code, then it goes to the computer memory and the computer memory then generates the result in this case it is 15, this is basically how aNext, let's make a boolean data type, so I'm going to make a type and inside this type function I'm going to say 7 is greater than 6 and this should return a bool value, which means it's true.
I'll click run. You can see that it returned a value if I do it another way. I do it and say that 7 is less than 6. It will do that too. it returns a bullish value because 7 is not less than 6, so it would be a false value which would be a bullish value, so if I click run, you can see here that it has returned a bullish value. Data types are a very important concept in Python, so when having to store in variables it is good to know the type of data you are storing, so that's it for this video on basic Python data types.
Thanks for watching, goodbye for now. Hello and welcome to this video. What is casting? Casting is basically the process. To convert from one data type to another data type, there are several functions that you can use in the conversion, for example, if you want to convert a value that is in a different data type to an integer, use the int function if you want converting to a floating point number uses a float function and if you want to convert it to a string you use the STR function, let's create a new notebook so I'm going to click on the drop down menu, click on Python 3 and I'm going to give this a name , I'm going to call it cost data types and I'm going to click on the rename button, so we're going to convert a value that is a float to an integer, to do that we're going to use the int function, so type int int. and inside that int function I'm going to pass in a value that is floating point, so I do 2.8 and I'm going to run this cell.
You can see here that it has returned two which is an integer and an integer is converted from value of 2.8 which was a floating point data type to an integer data type so let's try to convert an integer into a floating point number, so we're going to have to use the float function and inside the fluid function I'm going to pass in an integer that's an integer, so let's pass in 40 and then I'm going to run what you can see here, it converts to 40 point 0, which now it is a floating point number. Next, let's convert an integer to a string to do that.
I'm going to use the STR function and we're going to pass in a value that is an integer, so let's pass in the value 3. Now if I run this, it will convert it to a string data type, so I click run. You can see here that it becomes a string because it has quotes on either side. Anything with quotes on either side is treated as a string, which is basically how casting works. That's all for this video. Thanks for watching, goodbye for now. Hello and welcome to this. video What are variables? Variables are named containers for storing data values, unlike other programming languages.
Python does not have a specific command to declare a variable in Python. A variable is created the moment you assign a value to a named container. There are some rules you must follow. I need to know before creating variables in Python a variable name must start with a letter or the underscore character the variable name can contain alphanumeric characters and the underscore character so it can contain from A to Z numeric characters 0 to 9 and being in the punctuation character a variable name cannot start with a number, also variable names are case sensitive, so for example if you declare a variable named name with a capital n and you are trying to access that variable with lowercase n you will get an error, another important rule is that you cannot name your variable names after Python keywords.
There are certain keywords that are reserved for the Python programming language that you cannot use as variable names on the screen. Here we have a list of some reserved words in Python. They are called keywords. These are keywords that the programming language actually uses, so when you create a variable you cannot use any of these words listed in this table. Let's create some variables, so the first thing I need to do is create a new notebook, so I'll click on the dropdown button. down and click on Python 3 will name the notebook and I'll call it Python variables.
Now I'm going to click on change name and that will change it to Python variables so let's create a simple variable the first thing you need to do is have a named container so I'm going to create a variable so the name will be the container , so the moment you assign a value to the name container is when it becomes a variable, so the name container in this case calls it name and you use the equal sign to assign values ​​to the variables, like this which I will do because this will be a chain. I'm going to enclose the value in quotes, so I just created a new variable and assigned it. a blue line value so if I click run nothing will happen because the value is stored inside this name so if I want to retrieve the value inside this variable what can I do I can come here and say print and I will pass the name, remember that variable names are case sensitive, so I have to reference them in lower case because I created the name in lower case, so now if I run the cell, you can see that the value is returned here.
You can also change the value of a variable container by simply referencing the name of the variable, so if I can come here, I will call the variable again and I can change the value let's say for example, I want to call the variable. I change the name from blue lime to Jack and tried to do a print statement again and pass the name of the variable which is name it will now return Jack so even though I have assigned a value to a variable you can always change what the variable stores simply reassigning the value.
Let's create a couple more variables here, so I'm going to create another one. I'll call her greetings and I'll go. to assign a greeting, so I will include the value in text. I'm going to say hello world, okay, that's going to be the value that this variable called greetings is going to store, so I'm going to run it, nothing is going to do it. happens so whenever I want to reference this variable I can just call it by name if I call it greetings and come back and click run you can see here that it has returned the name that is said okay if we want to return it without the quotes we can include them in a print function and inside the print function we simply call the name of the variable which is greetings and run, you can see it printed without the quotes around it.
I've noticed that the spelling is very wrong, so if I want to fix that, all I need to do is call the variable by its name, which is greetings, and I'm going to fix that by changing it, so say hello world and just run it, so now if I call this variable inside a print function, then it will print hello world, let's create one more, so I'm going to call this variable new underscore, yeah, and I'm going to give it a value of 20 20 because this is a numeric value , it is not necessary to lock it up. in quotes I'll click run, so now if I want to access the value of this variable, I just call the variable by its name, which is new in punctuation, yeah, and I click run, you can see it gives me the value stored in that. variable container with some programming languages, you have to specify the data type for a particular variable before assigning it Python doesn't do that Python, you can just create something and just assign a value to it in this video.
I introduced you to variables in Python and We also created some examples of variables thanks for watching bye for now hello and welcome to this video What is a Python list? A Python list is a collection of data that can be of mixed data types, unlike variables that can only store a value in a container. A Python list can store multiple values ​​inside Tayna, each list element is separated by a comma and you can create a list using square brackets, for example you can create a list called fruits and assign the values ​​or elements for that list inside square brackets and separate each element with a comma, you can access individual elements in a list by index position, so that the first element is always index zero, the second element in a list is index one, and so on, you can also change the order in which an element is placed in a list by changing the index position, let's create a new notebook, so I come here, enter the new Python three and I'll double click and give it a name.
I'll call it Python list. Now I will do it. click rename so you can see here we have an internal workbook called Python lists, so let's go ahead and create some lists in this cell. I have created a new list called animals and assigned some values ​​or elements to the list if I want to access any. element or elements of the list. I will have to do it using the index number so that the first element of the list always has an index of 0, the second has an index of 1 and so on to access an individual element of a list you do that using the position of the index so you can see here in this cell.
I am using the print statement to print the index of element one, so it will be dog because the first elements will be zero, so if I run this The cell that you can see here is printed that dog has the first index. Okay, the first index is zero, but the element with index one is dog. You can also have negative indexing. Negative indexing means that you can access an element from the end of the list using a negative, so if you're doing a negative, that means you're accessing the last element in a list. If you're doing a negative two, you're accessing the second to last item in the list.
You can see here how to access two negatives. which means I expect it to return penguin, so if I run this now, you can see that it returned penguin. I'm creating another list here in this cell called fruits and there are three items in this list so I'm just going to run the cell to create it to access one item in the list it just references the index for example here I want to access the fruit called cherry, I just call the list name and pass the index by clicking run, you can see here it has returned cherry If you don't want the quotes to close just a print statement and wrap them around a print statement like I did here in this cell number two that will return the element without quotes, another thing you can do is change the value of an element in a list, for example the list called fruits.
I want to replace the value of apple with orange, all I need to do is reference the list name by passing the index of everything I want to change, which is zero, zero is Apple and then assign a new value which is orange, like this that if I run that it will change, if I now call the list name Apple should no longer appear in the list, you can see that Apple's position has been replaced with orange, you can also add items to a list by using the append method, like this which in this cell here I'm going to add Apple to this list, so you do it using append metal so you call the name of the list, which is fruit dot append and inside the parentheses for that method you pass. the name of the item you want to insert and normally that will add it to the end of the list so if I run it it will add it to the list so if I now call the list name we should have Apple in the list . end here.
I am creating another list here with mixed data types so I can create a list that has a mix of data types and you can also include a list in the order list so in this list here it is called mixed in the data of internal scores. the elements I have a string I have an integer I have a float I have a boolean and I have a list look at this list here I created your call fruits I'm adding it to this new list so let me run that and that creates it so if I want to access an element, for example, if I want to access the integer of that list, I reference the name of the list, which is mixed data, and pass the name, the value or the index of the integer is 47, so if I run it now that gives me the value, you can also remove items from a list.
Now there are a few ways you can do it, you can use the popup function to call the name. from the list in this case fruit dot pop and inside the parentheses you pass the index of the item you want to remove from the list, so in this fruit here in deck number three it will be Apple if you don't provide the index it will automatically remove the last item from the list. This is the second way you can use the delete method. I've commented out both because I only want the first method to run, so you can do that.
Fruits to eliminate. I'm passing the value. of the item you want to remove you can also use the delete key which you do with fruits and then you pass the index of the item and that will also remove it from the list but in this example I'm just going to use the pop method so I'm going to run this cell and you can see here it tells me that it has removed Apple from that list, so if I type fruits I run the cell, you can see that Apple is no longer in the list, another thing you can do is look at a list and you cando it using a for loop, so in this example here I'm saying that for I wanted to print X to print all items, if I click run you can see that it has printed all items in the list.
Another thing you can do is check the length of the lists if you want to know how many elements are in the list. This is the function there is. a function called Len, so since I want to print it, I'm wrapping it inside this print function and inside the Len function you pass the name of the list, so if I run this now it gives me 8 and tells me that this list is called animals has 8 items another thing you can do is delete or empty a list to do that there is a special function called delete so this is a list that I want to empty called fruit so delete the fruit store you have the parentheses you execute that and that it should clear the list so if i type fruits now it should return an empty list you can see it has returned an empty list so that's it for this video in this video we will learn about a python list thanks for watching bye . for now hello and welcome to this video, what is a Python tuple?
A tuple is a collection of data that can be of mixed data types in Python. A tuple can store multiple values ​​compared to a variable which can only store one value in each element of a tuple is separated by a comma, you can also create a tuple using parentheses, for example you can create a tuple called fruits and then use equals two to assign values ​​to the tuple that are placed inside parentheses to access the individual elements in a tuple. that by its index, so the first element will have an index of 0, the second element will have an index of 1 and so on.
Also a very important distinction between a tuple and list is that a tuple cannot be changed once you have created it. you can't add elements to the tuple and you can't remove elements from the tuple, it's immutable, let's go ahead and create a tuple, so in this cell here I'm creating a tuple called animals. I am using equal to 2 to assign values. The teachables and values ​​are put in parentheses so I'm just going to run the cell to create the tuple so to access an element of the tuple use the index of that element for example if I want to access this element called goat. this will have an index of three because the first element has an index of zero one two three, so all I need to do is come here and call the name of the tuple which is called animals, my square bracket passing the index of the element, like this What if I execute that thing that makes me crazy?
You can also use negative indexing to access the values ​​of a triple negative index, basically you will access the element from the end of the list, so here I will access the negative which means I am accessing the last element in the list. which is tiger, so if I run this, you can see that it has given me the value of tiger. You can also specify a range of indices to be returned from a tuple by specifying where to start and where to end the range so in this example here I am using a print function to print list elements so I am using a range so all I'm saying is that I want to print index two through five, so what I'm going to do is start the search from index number two. which is giraffe and it will end it before index number five it will not include index five so it will give me index number two which is giraffe and index number three which is good index number four real part but it will not give me index number five which It's a lion, so if I run that, you can see that it's given me good old Hanley's cure.
Additionally, you can also use negative indexing on a range once you create a tuple that you cannot change or that means you cannot add to or change it. the values ​​in this cell here, if I try to change the value of this tuple by trying to reassign the index of 0, which is this bear, if I try to replace that kangaroo, I'll get an arrow, so if I run that, you can see here it tells me that The tuple object does not support element assignment because once you create a tuple you can't add it, you can't change it.
Another thing you can do is iterate through a tuple and it basically means that it will iterate through the tuple and print. each element so I say here I am using a for loop so I say for X in animals print You want to know how many elements are in a tuple, there is a special function called Len that allows you to return the length of the tuple, so here I am wrapping the Len function inside the print function and passing the name. of the tuple inside the Len function, so if I run that which returns the length of the tuple that represents the element in the tuple, you can also join tuples, so in this example I'm going to create three tuples so the first one is called letters and I am assigning three values ​​ABC the second tuple is called numbers assigning three values ​​1 2 3 the third tuple is called letters in the punctuation numbers and the values ​​for this I am joining them using the plus operator to add the tuple code letters - DG posts numbers called so let me run this cell so now if I reference a tuple called letters in the punctuation numbers, if I run that you can see it gives me ABC 1 2 3 the key to remember about a tuple is that once a tuple has been created, you cannot change the value nor can you add anything to the tuple, so the tuple cannot be changed or is immutable once it has been created, so that's it for this video .
In this video we will learn about Python tuples. Hello and welcome to this video, what is a Python dictionary? A Python dictionary is a collection that is ordered, that can be changed, and that is also indexed. A Python dictionary is created using curly braces. Additionally, a populated Python dictionary will have keys and corresponding values ​​so the data within a populated dictionary is paired in the sense that it has keys and the keys have corresponding values. You can access the elements of a dictionary by looking up its key name in square brackets. The values ​​of elements in a dictionary can also be changed. be nested, that means you can have dictionaries inside other dictionaries.
I have created a new notebook and inside the notebook I have the code here to create a new dictionary, so I am creating a dictionary called countries underline cities, you use the equal sign to assign values ​​to the dictionary and you enclose the values ​​in braces, which are the braces of opening and this here is the closing. keys, so these here on the left are the keys and then these here on the right are the corresponding values, so each element in a dictionary must have a key and the key must have a value, the key is always on the left and the value is always on the right and then they are separated by: so you can see here, these are all the keys and these are the corresponding values, so I'm going to run the cell and try to run this cell.
I found an error because he is telling me here the key that is called Croatia, he told me where the error occurred. I left out the closing quotes, so I need to go back here where the cursor is flashing and add the closing quotes, so if I run it again, it shouldn't work. I can access the elements in a dictionary by referencing the key, all by referencing the values, or by referencing both in this example. Here I'm accessing the element additionally using the key so you can see that it's the name of the dictionary in the square brackets that you pass in. the value of the key which is Italy, if I run this I expect Rome to return as a value, so let me run, you can see here it has returned Rome as a value.
You can also use a special function called get to return the value of the specified key, so this is a dictionary name and I'm using the get function and inside the get function and passing the key in this case Egypt and if I run the cell will return Cairo so if I run that you can Look it has returned to Cairo you can also change the value in a dictionary so in this cell here I am changing the value of the key which is called United States currently the key is New York, I'm going to change it to Atlanta, so if I run this cell now, I should have changed that to Atlanta before I ran the dictionary and just passed in the United States key.
If you change it, you should see the change we just made, which is issued by Atlanta, it doesn't show that Atlanta has a value. from New York, so let me run, you can see that Atlanta has now been returned. You can also add items to a dictionary within this cell. Here I'm adding a new key which is Japan and I'm setting the value to Tokyo inside this dictionary called countries. in City score, so I'm going to run this cell. You may notice here that I have an indentation error because I accidentally put indentation so you can see where the cursor is flashing.
I need to roll back so I can get the indentation right if I run it again, you can see it has worked, so if I print the dictionary it shouldn't include the new key that I just added, which is Japan, so I click to run. I can see that Japan was added here as well. therefore, Japan is the key and Tokyo is the value. You can also delete items from a dictionary. There are several ways to do it. The first is to use the pop method, so you call the pop method on the dictionary and pass in the key. what you want to delete, then I passed the key Japan and this will delete the item from the specified key.
Another way to do this is to use the Delete key to type DL, then the name of the dictionary and pass the key inside. square brackets and this will remove the element from the specified key. Another way to do it is to use the popup method and inside the popup, a loop that will remove the last inserted element. Well, I've commented out both because I don't want that to run. The only thing I want is to run the pop method, so let me run it and that will have run it and also this print function here prints the modified after deleting Tokyo.
You can see that Tokyo is no longer listed in the dictionary afterwards. we have removed it using pop method. You can also search the dictionary keys. To do this, you use the for loop which is used to iterate over the dictionary keys, so we say for X in the dictionary called countries, underline cities, print X X basically. will represent each of the keys, so if I run that, you can see here everything is done, only the keys are printed, if you want to print only the values, there is a special function called values, so you add that function to the name from the dictionary and you print text and that will return only the value, so if I run the cell you can see that it only returns the values ​​for the dictionary.
If you want to get both the keys and the values, there is a special function called elements that you can call. in the dictionary so here in this cell I am saying for X comma Y comma in countries underline cities or elements so this will print the keys and the value see Here the key and the corresponding values ​​are printed. Do you want to check the length of a dictionary? There is a special function called Len. You can use it to print the length, so I wrap it inside this print function and then pass the name of the dictionary inside the parentheses to the Len function if I run the cell you can see that 6 is returned telling me the length of my dictionary is 6 which means I have 6 keys and their corresponding values ​​you can also have nested dictionaries which means you can have a dictionary inside another dictionary so in this cell here I am creating a dictionary which has another nested dictionary so you can see the name of the dictionary family that contains another dictionary.
This is the first dictionary called first child, second dictionary called second child and third dictionary. It's called third child, so if I click to run the cell that should create the dictionary, if you want to access a nested dictionary, you can do that by referencing the name of the parent dictionary and then in square brackets passing the name of the nested dictionary. you want to access so in this cell here I want to access the dictionary called second child if I run the cell you can see that it is giving me the keys and the corresponding values ​​for the dictionary called second child you can also delete or empty a dictionary using the clear method so I am calling the clear method on the dictionary called family if I run that; you delete it, so if I now call the dictionary you should return an empty dictionary if I run it, you can see here that it has returned an empty dictionary. dictionary so that's it for this video in this video we will learn about python dictionaries thanks for watching bye for now hello and welcome to this video what are our python operators python operators are used to perform operations with variables and values, There are different types of operators in Python, so I am going to cover some of the operators in Python, the first arethe arithmetic operators, so they are basically used with numerical values ​​to perform common mathematical operations, so they include more things like subtraction, multiplication, division and this here is called the modulo operator, the next type of operator is the modulo operators. assignment and these types of operators are basically used to assign values ​​to variables, this is what the symbols look like, you have equal to plus equals minus equal multiplication equal division equal and modulo equal we also have comparison operators that are used to compare values ​​and include double equals two if you want to compare whether two values ​​are strictly equal to each other, use double equals to sign if you want to check if one value is not equal to another, use this if a value is greater than it is that we value is less than the value is greater than or equal to where the value is less than or equal to then these are all comparison operators, the final type of operator I am What we are going to cover in this video are called logical operators which are used to combine conditional statements, they include things like and or not.
I've created a new notebook, so inside this cell here I'm going to add some operators and I'm going to Run the code to explain what the operators do. I have added some code in this notebook cell to illustrate how arithmetic operators work, so I will start with the addition operator, so here I am creating two variables, variable X and variable Y. X I have given a value of 7 variables Y I am giving a value of 5 so I am using the print function to print the value of x plus y so this is the addition operator so I will run the cell later.
I am not executing the cell now I am just showing you the examples of the operators inside the arithmetic operator here we have two values ​​value x value y I am using the print statement to print the value of x subtract the value of y So this is the operator subtraction. Next we have multiplication. Multiplication in Python is represented by Asterix again. We have two x and y values. We are using the print function to multiply the value of x by the value of y. and then here we have two variables X is equal to 12 and is equal to 4 and we are using the print function to divide we have two values ​​values ​​X is equal to seven value y is equal to five we are using the print function to print module 7 times 5, basically 5 can go to 7 once there is 2 left, so the modulo operator will return the remainder, which is 2, so let me run the cell and you can see the result.
You can see here the first value is 12, which is the third value here says 35 which is multiplication if you multiply 7 by 5 you will get 35. it is division if you divide 12 by 4 that will return 3 and for modulo operator modulo will always return the remainder so 5 can go to 7 a remainder once the remainder 2, so it returns the remainder which is 2, that's how the arithmetic operator works. I have added some code in my second cell of my notebook. This is the second cell and this code here is going to illustrate how the assignment operator works. Assignment operators are basically used to assign values ​​to variables which we already used in the previous example. for the erect arithmetic operator, you can see that all of this is equal to the sign.
Here we are using it to assign values ​​to variables so there are different types of assignment operators so here I have a variable called City and I have given it a value of London using equals 2 which is the assignment operator so Here I tell you in the print function to print the value of the city. Here I have two values ​​for the variables x equals 7 and then x equals 2 plus equals 2 when you have a plus equals then you're basically saying you add these three to the value of will print 10 because X is 7 and we're saying we call the value we call axiom and we're adding more. equals 4 means adding 3 and then using equals 2 to map the 3 to 7, making it 10, so the same process with - if we do a negative equals 2, that means you're removing 3 from the value of 3 will return to the same example with the loss of the module here we have the variable x is equal to 7, then x is equal to 2, the percentage is equal to o, which is the module equal to 3, what that means is that for the modulo operator you are going to divide 3 by 7 and return whatever is left, so this print see, so you can see here, these are all the values, let's go to the top of the value, it says that here it prints X, which is the value of the city and you can see here it prints London and then the next one here we have the same variable here we are multiplying 3 by 7 it gives us 21 and here for division we are dividing 3 by 6 it gives us 2 and here for module 3 goes into 7 2 times the remainder 1 so the module will return 1.
I have added more code to a new cell here to illustrate how comparison operators work. works, the operators you understand are basically used to compare two values, so let me go over the examples here. I have a variable x equals 2 seven variables y equals 2 3. I am using the print function to check the comparison where you have a double equals 2 means you are comparing so you are saying print equals 2 is used to assign a value where you have a double equals to is used to compare a value so know the difference here x is equal to 7 is a single equals to is used to assign values ​​to the variables here in the function of impression.
I'm checking the comparison here so I'm checking if print x or you have the question mark means print X is not equal to Y this will return true because X which is 7 is not equal to 3 and then we have again. I'm going to use the same variables for the examples. The variable X is 7. The variable Y is 3. I am using the print function to print. X is greater than Y. This will return true because 7 is greater than 3. Same. here we are checking if X is less than Y, this returns false because 7 is not less than 3 again.
The same as we are checking that X is less than or equal to Y, this will return true because 7 is greater than or equal to 3 in this example, the same thing checks if less than or equal to 3, so let me run the code and you can see the result with a comparison operator, you always get a true or false value because you are checking things, this is equal to what, etc., so you always get a boolean result. Basically, it is a true or false result. I entered a code in another cell and this cell here. I am going to illustrate how logical operators work.
Logical operators are used to combine conditional statements. Well, here what is a variable x is equal to 7 and I am using the print function to check some conditions, so I say that X is greater than 3 and this and here is a logical operator and X is less than 10 this is going to return true because 7 is greater than 3 and 7 is less than 10, so if we look at this example here x is equal to 7 we are going to use a print function to check the comparison, we are saying that X is greater than 3 or If TRUE. You can see that X is greater than three is one condition and then and that will return true, so in this case which this part of the expression is false but it will evaluate to true because one of the conditions in the comparison is true when you use the o operator here we send X is seven, we are using the print function to use the not part of the logical operator, We say that no X is greater than 3 and X is less than 10, this will return false because nothing is used to reverse the result. so let me run the cell and you can see the result which you can see here.
The first result is true, the second is true, and the last is false. In this video we learned about some of the operators in Python, thanks for watching, bye for now, hello. and welcome to this video in this video we are going to learn about Python conditional statements, what are conditional statements. Conditional statements are statements that perform certain types of calculations or actions based on certain conditions that will evaluate to true or false. These conditions are known as boolean. conditions There are three main types of conditional statements: if statements, if L statements and else statements, what are if statements?
If statements are used to check conditions before executing a certain block of code, they help your programs make smarter decisions and will. only execute or execute the code inside the if block only when the condition for evaluates to true if the statements use logical and comparison operators to check whether the conditions are true or false. I have created a new notebook and inside this cell I have some code here to illustrate how if statements work, so write an if statement using the if keyword, so I have a couple of variables here. Variable a has a value of 40.
Variable B has a value of 80, so I am using the if statement here to check if. the variable B is greater than a now that is the condition so the greater sign which is what we use to check the condition so B is 80 and a is 40 so B is definitely greater than a, so the condition will evaluate to true, so the code inside the if block, so when you write an if statement you have the colon and then below the colon is the block of code that will be executed when the condition is true so this print function here will run this code which says that B is greater than a because that the condition is true if the condition was false nothing will happen the code will not run so let me run the code by clicking in execute command.
You can see that the code was executed inside the if block, which is this text that says B is greater than a what. are l if statements L if statements are used to check multiple expressions until they find a condition that is true, when they find a condition that is true it will only execute the code block as soon as one of the conditions evaluates to true, for so if you are checking some conditions, it will run the code it finds for the first conditions that evaluate to true. I have a block of code inside my second cell to illustrate how the if statement works, so I have two variables, variable a has a value. of 40 the variable B has a value of 40 C both have the same value so I have an if statement that is checking that B is greater than a so if B is greater than a the code inside the if block , which is a printed statement will be executed on this condition, the condition is false because they both have the same value so the code inside the if block will not be executed and then we have the code in the LF block which is checking so I am using a comparison operator to check if you have a double equal to 2, that means your check is something equal to another, so I am checking that it is equal to B, we know they are because they both have the same value, so the code inside the LD block will be executed because that condition is true, they are both equal to each other, so let me run this Excel and you will see that the code inside the LF block is the one that has been executed, which is this printed statement that says that A and B are the same, what else is there? else statements statements are used to execute a block of code when conditions are evaluated just to force the addition of some block of code here in this new cell to illustrate how the else statement works so I havetwo variables, variable a has a value of 20, variable B has a value of 10 I have an if statement to check if variable B is greater than a if is the code inside the if statement block which is a printed statement , will be executed in this case B is less than 20, so it will be evaluated as force so that the code does not execute, we pass to L if the code in L, if we check that a is equal to B, this will be evaluated as false , so the code block will not be executed, we move on to the else statement which is going to evaluate to true because a is greater than B, so the code will be executed, so let me run the code and you will see that it says that a is greater than B, that's what it's called, well, that's the only condition that is true, we also have what's called nested. -if statement which is basically an if statement embedded inside another if statement.
I've added a block of code in this cell to illustrate how the nested if statement works, so I have a variable will evaluate to true, so the statement that is the printed statement above 10 will be printed and then we have the second if statement that is embedded inside the first one. one that checks if have two prints, the first says above 10, which is for this and the second says above 20, which is for that, that's basically how the nested if statement works. In this video we have learned about Python conditional statements, thanks for watching, bye for now, what are they?
Python loops are basically a sequence of code that you want to repeat or want to run continuously until certain conditions are met, so if you have a block of code that you want to run multiple times based on certain conditions, you can use a loop and that code will continue running until the configuration conditions are reached. There are two basic types of loops in Python, we have the while loop which is basically used to execute a set of code continuously until a condition evaluates to false, as long as the condition within the code is true, that block of code will continue to execute. .
The next type of loop is called a for loop, which is basically used to iterate over a list of elements, so for loops are particularly useful when using a list of one tuple. or a dictionary, it can even be used to search a string, so the for loop if you want to iterate and say print certain elements or all the elements in a list, you can use a for loop to iterate over that sequence that I created. a new notebook inside the notebook cell here. I added some code to illustrate how the while loop works, so with a while loop you have to have an initial starting point, so I'm doing it with this variable called I and I've set the variable to a value of one, so Now that we have a starting point, we can now start the while loop.
To implement a while loop, type the while keyword and then specify the conditions you are trying to check, so I'm saying this variable is the highest as long as this variable I is less than 7. I want this function to print keep printing the value of I. So what this will do will continue printing I until it reaches 7, so once it passes 7, that condition becomes false and the loop will stop as well when you have a while loop. It's very, very important to add an increment counter because the variable has a value of 1, so here you can see I have this counter here plus equals 2, which means 1 will be added to the value of that variable every time. , so the first loop will run, it will print the value of 1 and then this statement will add plus equals 2 means adding 1 to the value of variable I, so it will keep adding 1 until it reaches we exceed that level, so that the moment it reaches 7, the loop will stop because it would have evaluated to false because I will no longer be less than seven, but it is very important that you add this increment counter, if not, the loop will continue forever. it will never be forced, so the counter is very important so that at some point it will be evaluated as forced, so let me run this and then you can see what I mean, you can see here, it will print, it prints 206, it does not print . 7 because that's basically where the condition becomes false.
To continue printing as long as this condition is true, once it is greater than 7 it becomes false and then the loop stops, but it is very important that you always add the increment to the original. value which is 1, if not the loop will continue forever meaning this condition will always be less than 7 if you don't add this increment to add 1 every time the loop runs up to the original value I have. I added some code here in this second cell to illustrate how to use the break statement with a loop, so the break statement is basically used to stop a loop even if the wild condition is true, so here we can see the counter at which is close to the variable. 1 and I'm setting the while loop to say that as long as it is less than 7 I wanted to take the value high and you can see here that the increment counter is very important so that the loop will eventually evaluate to false and stop executing.
So you can see here, I'm adding a break statement, so I'll see if when it's equal to 4 I want there to be a break, so let's see how that works, we'll run it and you can see here it stops. at 4, although the condition is still true because at this stage I am still less than 7, but we are breaking the loop using this break statement. You can also have the continue statement that you can use to continue from when you stopped within the current iteration. of that loop, so the continuation works slightly different from the way the break statement works, so here we have a variable I equals zero.
I was saying that while I is less than seven here, you can see that we are adding the increment here because the initial value is zero, so we are not increasing the value to 1 and here we are saying that if I when is 4 continue and then we tell it to print I, so you'll see here when you run this cell that the number four will be missing from the result report because we only need to continue when it gets to four, so four was skipped and then continue with the loop, so if I click on run, you can see here it does one, two, three and skips. four and then print the rest.
I have some code in this cell here to illustrate how a for loop works, so with a for loop you have to use it to iterate over a list, so I have a list here called fruits and it has different elements in it, so if I can use a for loop to iterate over this list of elements and then print each value to implement a for loop that you write for here all the elements within that list are printed. You can also use a for loop to iterate over a string, so you see here, I have a string called strawberry.
I can use a for loop to iterate over each character within this string called strawberry, so if I run what you can see here is printing all the letters that make up the word strawberry, you can also have a nested for loop which is a loop inside another loop so here I have two lists the first one is called DJ and the second one is called fruits both have three elements so here I am implementing a for loop so I say for X in the first list called DJ X will represent each element and then the second loop also for y Y will render each element in the list called fruits so I am using print statement to print X we should print all the elements in the list X and the elements in the list. called And, so if I run that to make more sense, you can see here it says red, which is this value and then Apple for the other one and so on, that's basically how a nested for loop works: it's a loop inside of another loop in this video we learned about python loops thank you for watching bye bye for now hello and welcome to this video in this video you will learn about python functions you will learn how to create a function and also how to call or activate a function what functions consist of Python functions are code fragments or code blocks that are used to do something, basically they are a group of related statements that are used to perform a specific task.
Functions are useful, they help break down your programs into smaller, more modular chunks so that as your program grows bigger and bigger, functions make the program more organized and easier to use. Aitch functions prevent repetition and allow you to reuse your code, so once you've created a function, you can reuse it as many times as you want once. You have created a function, the function does nothing until you activate or call the function, so the process of activating a function is also known as executing or executing a function and you do it by calling the function with its name, be it whatever the name is. you have called your function if you want to activate it or execute it you need to call it by name when you create functions you can make them have parameters which are variables so you can create a function and then pass variables which are known as parameters and also when you call or execute the functions, you need to call them and provide arguments, arguments are called values, functions can return data, as a result there are various types of functions, they are built-in functions and they also use a defined function an example of a built-in function is print function which you can use to print things or data on the screen and then you have your own custom that our user created custom, which they also refer to as custom functions, the syntax to create a function.
It's pretty simple, you use the def keyword, which means you're trying to define a function followed by the function name and then you have the parentheses and then the color call is very important because that creates an indentation for the function, so that anything below the indentation here that is created by this: anything here is called the body of the function, so when you execute or call the function, this is the part of the code that will be executed. I have created a new notebook and inside the notebook I added a block of code here I am creating a new function called sum so you create a function using space keyword F you give it the function and name and inside the parentheses you can pass parameters if you want the parameters to be like variables, then you can see that you have passed two parameters x and y.
You can also leave the parentheses blank without any parameters, so after defining the function add a colon, the colon creates this level of indentation here and then this is the code that will be executed when this particular function is called, so when you create a function, the function does nothing until you call or activate the function, so here I am calling the function which is called some and inside the parentheses I am passing two values, the first value before the variable and the second value will be for the variable Y, so when you pass values ​​inside when you call a function, they are known as arguments, so four and five here are called arguments Y x and y inside the parentheses are known as parameters. so let me run this function.
I'll click run and you can see here that it has returned a value of nine because I passed two arguments four and five which will then run all of these functions, it says it will print the value of x plus y in the example function that we created we used parameters and also arguments . I just want to explain again the difference between parameter and argument. The parameter is the variable that is defined within the parentheses of the functions, while the argument is the actual value that is passed. or give the function when the function is called what is the value of the default parameter this is a value that a function uses when the function is called without passing any value to the function only parameters at the end of a parameter list can have a default value Since values ​​are assigned by position in the second cell here, I have created a variable called student underscore names and inside the parentheses I have specified a default parameter value, so this is the value that the function will use when I call the function without passing any value to it, so the name inside the parentheses is names, this will be the variable and the value will be a blue line, so when you call the function, this is what will happen. print this text hello plus any value that has the name of this variable, so here I am calling the function with and without arguments.
The first one here I am calling the function without passing any value to it so if I call it now this should print the default parameter value which is lime blueit should say hello blue line here I'm calling it and impersonating a value of John so now the name variable will have the value of John and this I'm calling here him and I'm giving it a different value so let me run it and then you can see it says hello blue line, which is the default because I call the function without giving it any value or argument.
I call the function again, give it a value of John, it says hello John called it again and gave it a value of Jane and it says hello Jane, so it basically runs the code in the body of the function, which is this statement printed here , so whatever value the variable names have, it will greet the value of that. variable names

If you have any copyright issue, please Contact