 Hello and welcome to the introduction for this course what you should know before you take the course you should have a basic working knowledge of using a computer you should also have a basic working knowledge of using the internet who should take this course the course is designed for beginners to python and jupyta notebook also designed for beginners to coding and programming in general what will you learn on the course we'll start off by installing jupyta notebook we'll then learn how to run the jupyta notebook server we will learn about some common jupyta commands we'll learn about the components that make up the jupyta notebook we'll learn about exploring the notebook dashboard we'll explore the user interface within the jupyta notebook we'll create notebooks we'll look at python expressions python statements we'll take a look at variables and how to create variables in python we'll take a look at data types in python we will learn how to cast data types that is how to change from one data type to another we'll learn about python operators we'll learn about conditional statements we'll learn about loops we'll also learn about python functions the format of the course is video base and the duration is 2.5 hours long thanks for watching bye for now hello and welcome to this video what is jupyta notebook the jupyta notebook is an interactive computing environment that enables users to experiment with code and it also allows users to share the code the jupyta is a loose acronym which means julia python and r these programming languages were the first target languages of the jupyta application but nowadays the notebook technology also supports many other languages the notebook is a document that can consist of live code rich text interactive widgets equations video images and so on these documents basically provide a complete and self contained record of a computation that can be converted to various formats and then shared with others hello and welcome to this video in this video i'll be showing you how to install anaconda and also how to set up the jupyta notebook to begin open up your google search bar and inside the search bar just type in anaconda distribution and press enter and just select the first on the list so i'm going to click on this one here that says anaconda python slash r distribution click on that and that will detect the operating system you have if you're running a mac it will detect you have a mac so i'm just going to scroll down to the bottom here and right at the bottom it will detect my operating system so it has detected that i'm running a windows based operating system and it presents me with the windows installer as of the time i am recording this video the current version is 3.7 when you do visit to do your own download the version may change just download the most recent version that you see so to download i have on that the windows there are two links one for a 64 bit and one for a 32 bit i've got a 64 bit so i'm going to click on the 64 bit graphical installer so you can see here is downloading on the bottom left hand corner of my screen i'll wait for that download to complete and then i'll run the installer the anaconda installer has completed downloading so that's it here so to run it i just double click to begin the installation so it's trying to launch just click on next and then click to agree and there are two ways you can install it you can install it just for your user profile which is a recommended one or you can install it for all users if you're going to use the all users you need to have admin privileges i just want to install it on one profile so i'm going to click on the top option which is going to install it just for me so i'll click next and then it tells you the destination folder where it's going to install it tells you the space required 2.9 gigabyte and tells me the space i have got available so make sure you do have enough disk space in your designated installation directory so i'm going to click next and i'm going to accept this option here that's been checked and i'm going to leave this one that is being unchecked it says not recommended so i'll click install to install so we just wait for the installation complete so i'm just going to give it a few minutes to run through the installation once the installation is completed you will get this that says completed and just click on the next button and click next and then if you want to learn more about anaconda in the cloud you can leave that checked i'm going to uncheck that if you want to learn more on anaconda you can leave that checked i'm going to leave this unchecked and click finish another way you can set up the jupyta notebook is by using the python package manager which is known as pip this is recommended only for the experienced python users so before you set up the jupyta notebook using pip you must make sure you already 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 that if you are using a mac if you've got a macbook mac comes pre-installed with python version 2.7 so if you want to upgrade pip on a mac you will you will have to type in pip 3 which means that you are referring to pip version 3 and not version 2.7 so you do pip 3 on a mac space install dash dash upgrade pip and that will create pip if you are on a windows based computer you don't need to type in pip 3 just type in pip install dash dash upgrade pip and that will upgrade to the most recent version of pip and then if you want to install the jupyta notebook using the python package manager you type in pip 3 if you're on a mac install and then jupyta if you're running a windows based computer you type in pip install jupyta so if you are doing this on a mac you obviously have to do that on your terminal if you're doing the installation on a windows based computer you have to do this on the command prompt for new users it is highly recommended that you install the jupyta notebook via the anaconda way because if you install anaconda anaconda will also install python and the jupyta notebook so let's take a look at what anaconda has installed we go to our programs menu and look for the anaconda folder so this is my anaconda 3 folder if i expand that i can see what it has installed it install the anaconda navigator anaconda power shell prompt anaconda prompt the jupyta notebook which is what we are really interested in here and then we've got this reset spider settings so we can see here by installing anaconda it also installs the jupyta notebook so that is it for this video in this video we installed anaconda and anaconda also installed the jupyta notebook for us thank you for watching bye for now hello and welcome to this video in this video i'll be showing you ways to start the jupyta notebook you can start the jupyta notebook server from the command line if you are using a windows-based computer that will be the command prompt if you're using a mac or a linux-based computer that will be the terminal so once you've got your command line opened you type in this command jupyta space notebook and that will start the jupyta server the other way to start the jupyta notebook server is from the all programs menu in your windows-based computer if you go to the anaconda folder within the all programs there should be an icon there for jupyta notebook you can run it from there as well once the jupyta notebook server is started it opens up the jupyta notebook in your default web browser and it does that on localhost and the port it uses is double eight double eight let's launch the jupyta notebook from the all programs menu on our windows-based computer so if you click on all programs go to start all programs and there should be the anaconda three folder so if you just expand it and inside there you see the jupyta notebook so just click on this and that will start you to launch a console screen like this and then it will also launch the jupyta notebook in your web browser so this is what the jupyta notebook dashboard looks like once you have launched the jupyta notebook and inside this dashboard area here it gives you a list that shows a list of notebooks files and sub directories in the directory where the notebook server was started so if you're launching the jupyta notebook from the all programs menu it will start from the root directory where the jupyta notebook was installed and it also lists some directories and sub directories from that root directory so your directory listing will be different from mine depending on what you've got in your specific directory where the jupyta notebook has started inside the root of your directory most of the time you can start a notebook server in the highest level directory that contains notebooks all right this basically is going to be the root directory and can also be the home directory if you are on a mac or a linux based computer you can also specify the directory that you want the notebook to start from and you do that by using by starting the jupyta notebook server from the command prompt while the jupyta notebook is running inside the console area here so if you look at look at the terminal interface here the command line gives you a lot of information here it tells you where the notebook is starting from so it's serving the notebook from the local directory which is on my c drive under the users directory and then under the profile administrator all right and then it tells you where the jupyta notebook is running at in the web browser which is localhost colon double eight double eight to shut down or exit the jupyta notebook server you just do control dash c on your keyboard and that should shut down the jupyta notebook server once you shut down the jupyta notebook server you will not be able to access the jupyta notebook on the web browser you can see here because i've shut the server down you can see here it's not able to contact the server i have shown you how to start the jupyta notebook server from the programs menu on the windows base computer which opened up the console and also opened up the notebook in your web browser on localhost colon eight eight eight eight i'm not going to show you how to start the jupyta notebook from the command line which is the command prompt on the windows base computer but the process is the same on the terminal notice that when you start the jupyta notebook from the anaconda folder within the all programs menu it will start that from the root directory of your profile where the jupyta notebook was installed when you're starting it from the command line you can specify where you want it to start from i've got a project directory here it's an empty directory i'm going to make the jupyta notebook start from this project directory so to do that i go to all programs and inside the anaconda folder we've got the anaconda prompt so this is what i'm going to use so i click on the anaconda prompt and i'll wait for it to launch so you can see tells me the base which is so this is the default where the jupyta notebook will start okay unless you change it i want to change that to my desktop so i do cd desktop i press enter and i do cd that's a folder called projects on my desktop so i just do cls to clear the screen so now i have navigated to this folder here called project that's where i want to start the jupyta notebook so i just type in jupyta space notebook and press enter and it will start the jupyta notebook you can see it's trying to start it you can see here because there's nothing in that root directory that's why you can't see any subdirectories here because the actual directory is empty all right and you can see here it tells me where the jupyta notebook is being served from it tells you the path the directory path always a good idea to pay attention to what's going on in the console in case there's anything that you are not sure with or if it doesn't work the way you expect it all right so running the jupyta notebook from a specified directory is also useful for project based stuff so that if there are certain things you want to keep in a specific directory then you can serve the jupyta notebook server from that directory in this video i showed you a couple of ways of starting the jupyta notebook one from the command line where you could specify a directory for the jupyta notebook to be served from and i also showed you how to start it from the anaconda folder within the all programs menu of your windows based computer when you start it from the anaconda folder there is a jupyta notebook icon that you can run and by default it serves the jupyta notebook from the root directory of your profile and when the jupyta notebook opens up it opens up in your default web browser on localhost colon 8888 the port number 28888 so that's it for this video on running the jupyta notebook server thank you for watching bye for now hello and welcome to this video in this video i'm going to show you some common and useful jupyta commands all jupyta commands are prefixed with the keyword jupyta before the sub commands are issued the jupyta keyword basically is the primary namespace for all sub commands let's take a look at a table showing some common jupyta commands so this is a table here and we have some useful and commonly used jupyta command first one here in the table is the command to start the jupyta notebook you just type in jupyta space notebook and that will start the jupyta notebook application if you want to see all the available commands that jupyta has and you want some information as well you just type in jupyta space dash dash help and that will show you the available commands that jupyta has if you want to see the location of the configuration directory you type in jupyta space dash dash config dash dir if you want to see the location of the data directory you type in jupyta space dash dash data dash dir if you want to see the location of the runtime directory you type in jupyta space dash dash runtime dash dir if you want to show all the jupyta directories and the search path you type in jupyta space dash dash path if you want to print out the directories and search path in a json format you type in jupyta space dash dash json so let's open up the command prompt in anaconda and show you how these commands work i'm going to illustrate how these commands work so in my windows computer i'm going to go to all programs and i'm going to look for the anaconda three folder which is this folder here i'm going to expand that and i'm going to select the anaconda prompt i'll click on that and that should open up this console this terminal if you're doing this on a mac or a linux based computer you can just do this on your terminal so you can see here it says base that is the base directory that's where the jupyta notebook application will start from so if i want to start the jupyta notebook application and i do not want the web interface to show this is the command i would type or typing jupyta space notebook and then you do a space dash dash no dash browser what that means it will start the jupyta notebook but it will not show me the browser interface so i press enter and that should start the jupyta notebook in this base directory but even though it gives me the location of the web browser interface it will not launch it because i've said i don't want the browser to display to shut down the server you just type in control dash c and that will stop the server so let's stop the server now that we have issued this command so i just do control c and that will stop the server okay so you can see i've done a control c it has shut down the server all right so i'm just going to clear my screen by typing in cls so that i can type in more commands the next command i want to type in is the help command so if i want to see the available commands i want some information i just type in jupyta space dash dash help if you don't want to type in help you can type in dash h that will also do the same thing and press enter and you can see here it gives you some information about the jupyta notebooks it tells you usage here jupyta interactive computing and gives you some optional arguments so very useful information and to clear the screen again type in cls so that i can type in more command the next command i'm going to type in is to show the location of the configuration directory so i just type in jupyta space and it would be dash dash config dash dir i press enter and that shows me my configuration directory the next command i want to show the location of the data directory so i type in jupyta space dash dash data dash dir and press enter you see that shows me the location of my data directory if i want to show the location of the runtime directory i'll type in jupyta space dash dash runtime dash dir press enter and that gives me the location of the runtime directory if i want to show all the jupyta directories and their search path i type in jupyta space and i type in dash dash path with an s and press enter and that will show me all the path okay it shows me the location of all the jupyta directories and their search path so you can see it's listed quite a few the final command i am going to type in is going to be a command that will print the directories and search path in machine readable json format so to do that type in jupyta again space dash dash json and press enter you can see here is giving me the path so in this video i've shown you some commonly used jupyta commands thank you for watching bye for now hello and welcome to this video in this video we will take a look at the components of the jupyta notebook the jupyta notebook application is a client server application a client server application basically is a distributed application structure that partitions task or workloads between the providers of a resource or a service which are usually called servers and the service requesters which are usually called clients so the server which is represented by this box here is the resource provider and then we have the client in terms of jupyta notebook that could be your web browser because the jupyta notebook also has a web component which is a web browser which will act as the client to the server so the client will be requesting 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 clients can include other computers it could 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 computer device the main components of the jupyta notebook include the notebook web application we also have the kernel and then we have the notebook documents so let me give you a brief description of each of the components of the jupyta 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 to author notebook documents the second jupyta notebook component is called the kernels the kernels basically are separate processes started by the notebook web application and it usually runs in the user's code and it runs in a given language the default language is python but you can run in other languages and what it does it returns the output from the notebook web application back to the notebook web application and the kernel basically handles things like compute computations for interactive widgets tab completion introspection and other bits and pieces so 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 inside the notebook web application this includes the inputs you have and also the outputs which are produced from the kernel okay it also includes narrative text equations images you can also include videos rich media representation of objects and each of the notebook document has its own kernel so there is a kernel for python there's a kernel for other programming languages as well so that's it for this video in this video i just gave you a brief introduction to the various components of the jupyta notebook thank you for watching bye for now hello and welcome to this video in this video we are going to take a quick look at the notebook dashboard to begin we have to start the notebook server so i'm going to be doing this on a windows 10 machine so in the all programs menu i've got to look for the anaconda 3 folder which is this folder here and in there there is an icon here for jupyta notebook if i click to run this icon it will start up the jupyta notebook server from the root directory where it was installed if i don't want to start it from the directory where it was installed i can use this anaconda prompt command and then specify a directory where it should be started from but for this video i'm going to start it from the default which is where it was installed so i click on the icon for jupyta notebook and it will launch this jupyta notebook interface you see it launches the web browser and it also launches this here so from here you can see where the jupyta notebook is running at it tells you it's serving the notebook from this local directory which is see users administrator and it will list everything in that directory inside the dashboard so let's take a look at the dashboard so this is what the jupyta dashboard looks like when you first start up the notebook server your web browser will open to this notebook dashboard the dashboard basically will serve as a home page for the notebook its main purpose is to display the notebooks and the files in the current directory for example the current directory it is showing here is this directory c slash user slash administrator and it will list what is got in that directory which is listed here yours will be different from mine because what you've got in your directory will obviously be different from my directory okay and then we've got the breadcrumbs at the top here the top of the notebook list here it will display clickable breadcrumbs these are all clickable breadcrumbs of the current directory by clicking on these breadcrumbs or these subdirectories in the notebook list you can navigate your file system so if you want to see any of these here you can see they are all clickable links to their respective directories okay if you want to see what's running in the dashboard you click on running and it shows you whatever is running at the moment you can see there's no terminal running there's no notebook running also if you want to upload you can click here to upload files and so on tells you here when the these subdirectories were last modified this little name arrow here basically is used to sort the list the directory subdirectories in this list here you can see the arrow is pointing down which means it is sorting them in alphabetical order if you want to sort it the other way say from z to a you can see the arrow has gone up and it's flipped it and sorted it from z to a so I'm going to put it back and then you can see here this is just referring to the file size if you want to quit the dashboard you can click on quit or you can click on logout I'm going to click logout and that has successfully logged me out of the dashboard okay and then if I want to quit the server I just type in this command here control c and that will quit the jupyter server so that is it for this video thank you for watching bye for now hello and welcome to this video in this video we are going to take a look at the notebook user interface 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 author your notebook documents interactively the notebook user interface has three main areas we have the menu we have the toolbar we have the notebook area and the cells I have got my dashboard open and I have got one notebook inside my dashboard at the moment the notebook is not running so to run it I'm just going to double click on it and that will run the notebook so you can see here the notebook is running it has now presented me with the user interface 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 on the notebooks the notebook cells and the kernel it communicates with the file here basically is you can use this file option inside the menu you can use that to change the file name for the notebook and then you've got the edit you want to edit you've got the view you've got insert allows you to insert cells above or cells below this here is called a cell okay this border area here is called the cell where the code is and then you have the kernel which is running at the moment we've got widgets so you can save the notebook the state of the widget you can clear the notebook widget you can download the widget and so on and then you've got the help menu okay so that this bar this area here is known as the menu bar and then we've got here this line here is called the notebook toolbar area okay the toolbar has several buttons for the most common actions so if you want to see what each of the buttons do just hover your mouse over each button for more information for example if I hover over there it tells you that is a save and checkpoint and that tells you that's inserting a cell this is cut selected cell copy selected cell paste and this says move selected cells up move selected cell down this enables you to run the cell this interrupts the kernel this one restarts the kernel with a dialogue and this basically restarts the kernel the notebook has mode indicators mode indicators basically indicate which mode the cells are if they're in edit mode or if they are in command mode you can tell that in command mode if it's got a blue strip around the cell so if you click here if I click on this now if it's got a green strip around the cell it's in edit mode so you can see here this icon here tells you it is edit mode if I click outside the edit mode you can see now this is showing as the command mode so it's very important to know that there are two mode indicator which you can identify by the colors around the cell so if you've got a blue color around the cell that's a command mode which means you can issue command if you've got a green strip around it you are in the edit mode which means you can edit the previous code you've got in the cell also here inside the toolbar area we've got this icon here which is a command palette so if I click on that it gives you the command group so if you want to use shortcuts for setting things you can do that from here all the navigation and actions in the notebook interface are available using the mouse through the menu bar and the toolbar which are bought inside the notebook area so that's the menu bar and this is the toolbar so you can use the mouse to navigate through the various actions you want to perform to select a cell with your mouse you just click on the cell and that selects it and if you want to change the mode for example the mode at the moment is edit mode you just click outside the cell and it changes the mode to the command mode so that is it for this video in this video we took a look at the notebook user interface thanks very much for watching bye for now hello and welcome to this video in this video we are going to be creating a new notebook before we create the new notebook I just want to point out a few things a notebook will have the file extension .ipynb also a notebook consists of three basic type of cells they are code cells which will include the input and output of the live code that runs in the kernel and then we have the markdown cells which are narrative text that contains embedded latex equations we also have the raw cells which include on formatted text also notebooks can be exported to different static formats which include html and pdf before we can create a new book we have to start the server so the jupyter notebook server I'm going to start it from a specified directory I've got a directory on my desktop called my notebooks it's an empty directory at the moment but this is where I want the jupyter notebook server to start from and any notebook I create will be inserted inside this directory so to begin I go to my terminal I look for my anaconda folder and then I'll click on this that says anaconda prompt this will give me the prompt which 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 directory to a folder called my notebooks all right and I'll just clear the screen so now I'm in the directory to start the jupyter notebook server I just type in jupyter space notebook and that will start the jupyter notebook server in that directory I have specified all right so it's trying to launch the jupyter notebook so this is the dashboard and you can see the dashboard here this is the root directory of the this directory on my desktop here that's what the jupyter notebook dashboard is pointing to it's empty at the moment because there is no notebook list there's nothing in that directory so to create a new notebook there is a new option that says new you click on this new button at the top here and all these are called kernels so whatever kernels you see here depends on what's installed on the server all right so these are my available kernels and I'm going to click python 3 because I want to create it in python 3 so it's going to open up a new cell this is what is called a cell and if you see here the default cell is a code all right and if I click on the dropdown you can see the other type there's a markdown and there's a raw nb 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 write a live code so I'm just going to type in print and just say hello world so I've just typed in a simple print statement that's going to say hello world and to run this cell you can click on the run button here or you can do you can do 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 the notebook is untied to that moment so I need to give it a name to do that you double click on it and I'm going to call it hello world and then I'll click on this rename button and you can see 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 can see this is running you can tell that it's running because it's got this green icon next to it I've only got the one notebook at the moment but it's possible to have multiple notebooks running at the same time also while the notebook is running there is a box here you can check if you check on it it gives you some options you can duplicate the notebook you can shut it down you can view you can edit and you can also delete so I'm just going to uncheck that box but you see those options when you have the box checked if you have it unchecked the options disappear if I take a look at my project directory on my desktop you can see here that it has saved the notebook this is the notebook here with the extension ipynb it has saved it into my projects directory if you have other notebook files you can also upload them using this upload button or you can just drag them into the notebook area here in the dashboard the notebook shows the green icon when the notebook is currently running and notebooks remain running until you explicitly shut them down closing the notebooks page is not sufficient to shut the notebook down so if you want to shut it down you click on this check there and then there is an option to shut the notebook down notice I've shut it down and the icon now is no longer green so that is it for this video in this video we created a new notebook thank you for watching bye for now hello and welcome to this video on what is python python is a general purpose programming language this means it can be used to write computer programs for various things like games data science websites and so on python is also a high level programming language high level programming languages mean that the languages of writing computer instructions in a way that is easily understandable and close to human language python is portable which means we can run python programs in the various different operating systems like windows mac os linux without any changes python is an interpreted language python is called an interpreted language because it goes through an interpreter which turns code you write into the language understood by your computer's processor python is strongly typed strongly typed languages don't convert data from one type to another type automatically python has a huge set of libraries a python library is a collection of programs you can incorporate into your own program without writing code for them let's take a look at a list of application types you can create with python web applications these are applications you can access using a web browser android applications these are applications that runs 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 python system administration applications so you can use python to create applications to monitor various types of systems you can also create console applications a console application basically is a computer program designed to be used by a text only computer interface let's take a look at a list of software applications that have been created using python so some of these are quite famous and popular first on the list is youtube and then we have google we have dropbox this program lets you save files to a cloud based service that you can then access from anywhere in the world we've also got reddit reddit is one of the biggest open communities on the web you have a question you want to talk about something in specific or if you want to find tons of information regarding a particular topic for example gardening or anything you can just look on reddit and find related information next we have spotify spotify allows you to listen to add free music of your choice this is streaming service that allows you to stream music without any advertisement finally we've got instagram instagram is very popular it has both an app site and also a web site as well and these are just a few list items of software that were created using python there are so many others but these are just some few that you may have come across so that is it for this video on what is python thanks for watching bye for now hello and welcome in this video i will introduce you to high and low level programming languages what are high level programming languages these are languages that only humans can understand so computers can't understand them unless they are compiled or interpreted they need an interpreter or a compiler for the computer or the machine to understand what the programming is trying to get it to do examples of high level programming languages include python java c sharp c plus plus php ruby and there are many others what are low level programming languages these are languages that only machines can understand they do not 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 the nearer the language is to the hardware of the machine the faster it is and it doesn't need to be interpreted because it's so close to the computer hardware whereas the further away it is like we've got this lot here they are further away from the hardware so they need they're easier for programmers to understand because they contain english-related words but not machine to understand so for the machine to understand what this block here is saying it needs to be converted into machine code using a compiler or an interpreter the differences between high level and low level programming languages high level languages are easier to learn low level languages are more difficult to learn high level languages are near to human languages that's easy to read they are like basic english while low level languages are far from human languages so only machines know what they are talking about you need a translator like a compiler or an interpreter to convert a high level language into machine language no translator is needed for low level languages because the machine hardware knows what they're talking about programs written in high level languages are slow in execution because obviously they have to compile or interpret them while programs developed in low level languages are much faster in execution because there's no compiling or interpretation going on the hardware understands the language so it's easy or easier to execute the instructions so these are the key differences between high level and low level programming languages thanks for watching and bye for now hello and welcome to this video in this video i'm going to introduce you to compilers and interpreters what is a compiler a compiler is used to translate the entire source code into machine language before the code is executed so basically what that means is that the computer for the computer to understand um what is you trying to get it to do you have to use a compiler to compile or translate convert your code into a code that the machine can read all right examples of languages that are compiled that means languages you have to compile before the code is executed includes c and c 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 that you write so let's say inside the source file you have this you've got x equals seven y equals eight and then the sum is equals to x plus y and then you want to print the value of the sum using the print function now the computer will not understand this so what needs to happen you need to use the compiler to convert that code into machine code the machine code is something like this called computers only understand zeros and one so the compiler compiles it into machine code and then it executes the code it then passes it on to the computer memory and the computer memory then outputs the result in this case which is 15 so that's basically how a compiler works compiler will compile the entire code into machine code before it passes the information to the cpu to display the result what is an interpreter and an interpreter does a similar job like a compiler the key difference with the interpreter is that the interpreter will translate or convert one line of code at a time okay into machine language before the code is executed examples of interpreted languages include python and pearl so let me show you an illustration of how an interpreter would work so let's say you have your source file and you have this bunch of code inside your source file at this stage the computer would not understand that so for the computer to be able to interpret what you're saying you need to use an interpreter so the way the interpreter works is that it will convert a line at a time so for example it would do x equals to seven compile that and run it you do a y equals to eight it will translate or convert that and then run it it does line by line in comparison to compiler that compiles the all code into machine code before it executes in case of a interpreter it does it line by line and then eventually it will produce the result this is a brief table that illustrates some key differences between compilers and interpreters the compilers basically will transform the entire source code while interpreter would transform line by line of the source code the compilers will generate a machine code first before it executes the interpreter does not generate any machine code the because the compiler generates intermediate machine code it uses more memory the interpreter uses less memory compiled languages run once so once you've compiled it you can run it anywhere because it's already been compiled while the interpreter the source code has to be interpreted each time you run the file the compiler basically is more difficult compiled languages because it's deep more harder to find problems or debug issues while the interpreter is much easier to debug the compiler is faster and the interpreter is much slower so these are some key differences between compilers and interpreters 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 python expressions an expression is anything that has a value for example the number three four plus five and the string hello text are referred to as strings in python an expression can contain operators like the plus operator it can also contain upper hands for example in the example four plus five four is the upper hand also five is an upper hand while the plus is known as an operator i've got my notebook dashboard open i'm going to create a new notebook so here in this area here i'll click on the drop down for new and i'll select python three which is going to interpret and i'll give the notebook a name i'll double click on it and i'm going to call it python expressions and i'll click on the rename button to rename it so it's now saying python expression so you can see i've got the blue strip which means i'm in the command mode inside the cell so i'm just going to issue a simple command i'm going to say three plus four and to run the cell i just click on run cell or you do shift and enter so i click run and that gives me the output of seven let me enter another expression i'll do seven times two and i run the cell click on run and that gives me a value of 14 let me enter a string expression this time so a string which is known as a text has to be enclosed in quotes you can either enclose it in double quotes or single quotes but you can't mix the quotes so i'll say hello world to run the cell i click on run cell and it gives me the output hello world in these example expressions here the three here is known as an upper hand the plus is known as an operator the four is also called an upper hand all right and here also in this second cell we've got the seven as an upper hand the asterix represents multiplication in python which is known as an operator the two is an upper hand and in this cell here we've got a string value which is basically a text so in order for python to understand that this is a text you have to enclose it in quotes so on on either side of the text so you can have either single quotes on either side or double on either side you can't mix single and double quotes in this video i gave you a brief introduction to python expressions thanks for watching bye for now hello and welcome to this video python statements are basically a set of instructions that you give to the computer to perform a task or a series of tasks python statements can contain one or more expressions it can also be on a single line or it can consist of multiple lines to illustrate examples of python statements i'm going to create a new notebook so on the new here i click on the drop down i click python three python three contains the python interpreter that will interpret the code we write into a machine readable format that the computer can understand so i'll click python three and i will just double click to give it to give it a name so i'll change the name to say python statements and i'll click rename so this notebook is going to be called python statements um so you can see we've got a blue strip here which means i'm in the command mode so i'm going to start up with a single line statement it's going to be a simple expression i'm going to say nine times nine and i'm going to run the cell by clicking on the run button and that gives me 81 so this is known as a single line statement because the statement or the instructions is just on one line so depending on what you want the computer to do you can have a statement that consists of several hundred even thousands lines of code depending on the task you want the computer to perform so i'm going to give you an example of a multi line statement so i'm going to use a for loop so i'm going to say four i in range and a range is basically an inbuilt function in python which you can use to specify a range so i'm going to say 13 i'll specify the range and then i will add the colon the colon is very important it creates an indentation level so if i press enter you can see here it's giving me an indentation level so i can add another line of statement i'm going to add a print function so i'm going to get it to print the value of i so let me click to run the code you can see here it's printed out from zero to twelve all right so when you specify a range the first number is usually a zero okay hence it has not printed out 13 because zero here represents the first range okay so this is an example of a multi line statement because the statement is on two lines let me explain what this code is in this cell number two here the four basically is used to iterate over a range of values so here i'm saying this four is going to be used to look through a range of 13 numbers a sequence so the i here is going to be what is going to store the value so i say for i in range range basically is a inbuilt function in python so we're basically using this four loop to look through this range and we're going to print out each value of this i so i here contains all the values so what it's going to do is the first value is going to print is going to be zero so it prints from zero to twelve which gives it 13 values okay so that's basically what that code is doing in this video i gave you a brief introduction to what python statements are so a statement can contain one or multiple lines of code depending on the task you want the computer to perform thanks for watching bye for now hello and welcome to this video python comments can be very useful they can be used to explain your python code to yourself and to others also comments can be used to prevent execution of code when you are testing your code so you may have certain aspect of your code that you don't want to run during execution to achieve that you can add comments to that aspect of code which prevents the execution of that code so this can be very useful during testing purposes there are two main types of comments in python we have a single line comment and a multi line comment so the single line comment is represented by the hatch symbol while a multi line comment you can either represent it by three double quotes on either side of the code you want to comment or you can have three single quotes on either side of the code you are trying to comment i've got my jupyter dashboard i'm going to create a new notebook so on that new i'll click python three and i'm going to call this notebook python comments and then i'll click rename inside the cell i'm going to issue out a simple print function here and i'm going to get it to print out the text hello world and next to it i'm going to add a single line comment which is represented by this hash symbol when the comment is on the right hand side of the code it does not affect the code running but when you place the comment in front of the code it will affect the code so if i click run here it will give me the output because the comment is on the right hand side so notice in the second cell here i have placed the comment in front of the code noticed has commented out all of the code so it will prevent this code from being executed so if i click on the run button you see nothing gets executed because of the comment so be very careful where you place your comment if you place it in front of the code it will comment out the entire line but if you place it on the right hand side as we've done in cell number one it does not affect the code from being executed so these are known as single line comment so let's give you an example of a multiple line comment so to do that you do three quotes on either side all right so you can press enter so you either have three double quotes or three single quotes you can't mix the quote and then any text that is enclosed between these quotes will be commented out and the code will not be executed in this cell here we've got a multi line comment because it spans multiple line this is one line this is another line so we can see that the multi line is enclosed by these quotes so we have three double quotes before and three double quotes on i notice it has turned all the text in between the quotes red which means that when i run this cell those lines of code will be ignored the only line that will print is this print function here that says hello world so if i run this cell by clicking on the run button you can see here it's printed out hello world and it has ignored this here which is the multi line comments so comments are very useful in python they help you explain what your code is doing and also can help you comment out certain lines of code if you don't want those lines of code to be executed so that is it for this video thank you for watching bye for now hello and welcome to this video there are three basic data types in python we have the numbers data type this basically includes integers which are known as int and floating point numbers which are known as float and integer basically is a whole number and a floating point number is basically numbers that includes decimal we also have the string data type which basically is a text or a sequence of characters it's also referred to as str and then we have the boolean data type which is a true or false value is also known as the boolean you can get the data type of any object by using the type function in python so basically you pass in a value in between the parentheses and this type function will return the type of data type so let's create a new notebook and experiment with some data types so I'm going to create a new notebook so I'll come here say new click on python 3 and I will give the notebook a name and I'm going to call it python data types so we're going to experiment with the basic data types in python I'm going to use the type function to enable or detect the type of data type it is so I am going to start with an integer which is a whole number so I'll do the type command and inside this type function I'm going to pass in a value which is 80 so 80 is a whole number so I click on this wrong command you see here it has returned that this type of data is an integer so an integer is a whole number it can also include negative numbers so if I type in I do a type and inside that type function if I pass in negative 30 and run it also return an integer because they can contain both positive and negative values so let's try and get a data type that is a floating point a float is basically a number that includes decimals so we do type and inside this function let's do 28.5 and run this cell you can see it has returned a float you can also have a negative float value as well so if I do type and in between I do negative 1.0 and do a run it also returns a float next let's try and get a string data type so we do a type remember with a string you always have to include the values in quotes so I'm just going to say hello and I'll do a run you can see here it has returned that this is a string data type which is specified by the word str next let's do a Boolean data type so I'm going to do 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 is true I'll click run you can see it's returned a bool if I do it the other way I'll do a type and say 7 is less than 6 it will also return a bool value because 7 is not less than 6 so it would be a false value which would be a bool so if I click run you can see here it has returned a bool value data types are very important concept in Python so when you have to store data in variables it's good to know the type of data type you are storing so that is it for this video on basic Python data types thank you for watching bye for now hello and welcome to this video what is casting casting basically is the process of converting from one data type to another data type there are several functions that you can use in casting for example if you want to cast a value that is in a different data type to an integer you use the int function if you want to cast to a floating point number you use a float function and if you want to cast to a string you use the str function let's create a new notebook so I'm going to click on the drop-down click Python 3 and I'm going to give this a name I'm going to call it casting data types and I'll click the rename button so let's cast a value that is a float into an integer to do that we're going to use the int function so typing int and inside that int function I'm going to pass in a value that is a floating point so I do 2.8 and I run this cell you can see here it has returned two which is a whole number and an integer so it's converted the value of 2.8 which was a floating point into an integer data type so let's try and convert a whole number into a floating point number so we're going to have to use the float function and inside the float function I'm going to pass in a whole number which is an integer so let's pass in 40 and then I'll run that you can see here it's converted it to 40.0 which is now a floating point number next let's convert an integer into a string so to do that we're going to use the str function and we're going to pass in a value that is a whole number so let's pass in the value of 3 now if I run this it will convert this into a string data type so I click on run you can see here it's converted into a string because it has quotes on either side anything with quotes on either side is treated as a string so that's basically how casting works so that's it for this video thank you for watching bye 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 for declaring a variable in python a variable is created the moment you assign a value to a named container there are a few rules that you need to know before you create 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 characters a to z numeric from zero to nine and the underscore character a variable name cannot start with a number also variable names are case sensitive so for example if you declare variable code name with uppercase n and you're 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 which you cannot use as variable names on the screen here i've got a list of some reserved words in python they are called keywords so 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 first i need to just create a new notebook so i click on the drop down and click python three i will give the notebook a name and i'm going to call it python variables and i'll click rename and that will rename 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 name is going to be the container so to the moment you assign a value to the name container that's when it becomes a variable so the name container in this case i've called it name and you use the equals to sign to assign values to variables so i'm going to because this is going to be a string i'm going to enclose the value in quotes all right so i've just created a new variable and i assigned it a value of blue line so if i click run nothing will happen because this the value is stored inside this name so if i want to retrieve the value inside this variable what i can do i can come here and say print and i'll pass in the name remember the variable names are case sensitive so i have to reference it in lowercase because i created the name in lowercase so now if i run the cell you can see here is return the value you can also change the value of a variable container just by referencing the name of the variable so if i can come here i'll call the variable again and i can change the value so for example i want to call the variable i change the name from blue line to jack and if i try to do a print statement again and passing the name of the variable which is name it will now return jack so even though you've assigned the value to a variable you can always change what the variable stores just by reassigning the value let's create a couple more variables here so i'm going to create another one i'm going to call this greetings and i'm going to assign a greeting to it so i'm going to enclose the value in text i'm going to say hello world all right so that's going to be the value that this variable called greetings is going to store so i'm going to run it nothing will happen so each time i want to reference this variable i can just call it by its name if i call it greetings and return and click on the run you can see here it has returned the name what is stored okay if we want to return it without the quotes we can wrap that into a print function and inside the print function we just call the name of the variable which is greetings and run you can see print it out without the quotes around it i've noticed i've spelled the world 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 that so i'll say hello world and just run that so now if i call this variable inside a print function it will then print out 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 2020 because this is a numerical value you don't need to enclose the value in quotes so 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 underscore yeah and click run and you can see it gives me the value that is stored in that variable container with some programming languages you have to specify the data type for a particular variable before you assign 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 a few variable examples 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 one value in a container a python list can store multiple values inside one container each item in a list is separated by a comma and you can create a list by using square brackets for example you can create a list called fruits and you assign the values or the items for that list inside square brackets and you separate each item by a comma you can access individual items in the list by the index position so the first item is always index zero the second item in the list is index one and so on also you can change the order in which an item is positioned in a list by changing their index position let's create a new notebook so i'll come here with new python three and i'm going to double click and give it a name i'm going to call it python list and i'll click rename so you can see here we have a new notebook called python list so let's go ahead and create some list in this cell i've created a new list called animals and i've assigned some values or elements to the list if i want to access any item or elements from the list i will have to do that using their index number so the first item on the list will always have an index of zero the second will have an index of one and so on to access an individual item from a list you do that using the index position so you can see here in this cell i'm using the print statement to print out the index of the item one so that is going to be dog because the first item is going to be zero so if i run this cell you can see here it's printed out dog as the first index okay the first index is zero but the item with the index of one is dog you can also have negative indexing negative indexing means you can access an item from the end of the list using a negative so if you're doing a negative one that means you're accessing the very last item in a list if you're doing a negative two you're accessing the second last item on the list you can see here um accessing negative two which means i expect it to return penguin so if i run this now you can see it has returned penguin i'm creating another list here in this cell called fruits and it's got three items in this list so i'm just going to run the cell to create it to access an item from the list you just reference the index for example here i want to access the fruit called cherry i just call the name of the list and passing the index if i click run you can see here it has returned cherry if you don't want the quotes enclosed just do a print statement and wrap it around the print statement like i did here in this cell number two that will return the item without quotes another thing you can do you can change the value of an item 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 name of the list passing the index of what i want to change which is zero zero is apple and then assign a new value which is orange so if i run that that to change that if i now call the name of the list i should no longer have apple listed you can see the position of apple has been replaced by orange you can also add items to a list by using the append method so in this cell here i'm going to add apple to this list so you do that using the append method so you call the name of the list which is fruit dot append and inside the parentheses for that method you pass in the name of the item you want to insert and normally that will add that at the end of the list so if i run that it will add that to the list so if i now call the name of the list we should have apple listed at the end here i'm creating another list here with mixed data type so you can create a list that has a mixture of data types and you can also have a list include on the other list so in this list here called mixed underscore data inside the items i've got a string i've got an integer i've got a float i've got a boolean and i've got a list see this list here created your core fruit i'm adding that to this new list so let me run that and that creates it so if i want to access an item for example if i want to access the integer from that list so i reference the name of the list which is mixed data and i pass in the name the value or the index of that integer is one which is 47 so if i run that now that gives me the value you can also remove items from a list now there are a few ways you can do that you can use the pop function so you call the name of the list in this case fruits dot pop and inside the parenthesis you pass in the index of the item you want to remove from the list so in this fruits here index number three is going to be apple if you don't supply the index it will automatically remove the last item from the list this is the second way you can use the remove method i've commented that both because i only want the first method to run so you can do a fruits that remove and passing the value of the item you want to remove you can also use the delete key you do d l fruits and then you pass in the index of the item and that will also remove it from the list but in this example i'm only going to use the pop method so i'm going to run this cell and you can see here tells me it has removed apple from that list so if i type in fruits and run the cell you can see apple is no longer listed another thing you can do is loop through a list and you can do that using a for loop so in this example here i'm saying for x x is going to represent each item in the list so i say for x in the list called animals i want it to print x so it will print all the items so if i click run you can see here's printed out all the items in the list another thing you can do is check the length of the list if you want to find out how many items are right in the list this is the function there's a functions called len so because i want to print it out i'm wrapping it inside this print function and inside the len function you're passing the name of the list so if i run this now it gives me eight tells me that that list called animals has eight items in it another thing you can do is clear or empty a list to do that there is a special functions called clear so this is a list i want to empty called fruits so you do fruits or clear you add the parentheses you run that and that should clear the list so if i type in fruits now it should return an empty list you can see it's returned an empty list so that is it for this video in this video we learned 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 type in python a tuple can store multiple values in comparison to a variable that can only store one value each item in 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 to assign values to the tuple which are placed inside parentheses to access the individual items in a tuple you do that by the index so the very first item will have an index of zero second item will have an index of one and so on also one very important distinction between a tuple and the list is that a tuple cannot be changed once you have created it you can't add items to the tuple and you cannot remove items from the tuple it is immutable let's go ahead and create some tuple so in this cell here i'm creating a tuple called animals i'm using the equals to to assign values to the tuples and the values are placed in between the parentheses so i'm just going to run the cell to create the tuple so to access an item from the tuple you use the index of that item for example if i want to access this item called goat this will have an index of three because the first item 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 add my square bracket and passing the index of the item so if i run that that gives me goat you can also use negative indexing to access the values of a tuple negative index basically will access the item from the end of the list so here i'm accessing negative one which means i'm accessing the last item from the list which is tiger so if i run this you can see here it's giving me the value of tiger you can also specify a range of indexes to be returned from a tuple by specifying where to start and where to end the range so in this example here i'm using a print function to print out items from the list so i'm using a range so what i'm saying is that i want to print from index two to five so what that will do it will 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 the index number two which is giraffe and index number three which is goat index number four leopard but it will not give me index number five which is lion so if i run that you can see here it's giving me giraffe goat and leopard you can also use negative indexing on a range once you create a tuple you cannot change it what that means you cannot add to it neither can you change the values so in this cell here if i try to change the value of this tuple by trying to reassign the index of zero which is this bear if i try to replace that with kangaroo i will get an error so if i run that you can see here tells me here tuple object does not support item assignment that's because once you create a tuple you cannot append to it you cannot change it another thing you can do is loop through a tuple looping basically means it will iterate through the tuple and print out each item so i'm saying here i'm using a four loop so i'm saying for x in animals print x x will represent each item so if i run the cell you can see here it's printing out all the items in the tuple if you want to find out how many items there are in a tuple there is a special function called len which enables you to return the length of the tuple so here i am wrapping the len function inside the print function and i'm passing in the name of the tuple inside the len function so if i run that that returns the length of the tuple which represents the item in the tuple you can also join tuples together so in this example here i'm going to be creating three tuples so the first one is called letters and i'm assigning it three values abc second tuple is called numbers and i'm assigning it three values one two three the third tuple is called letters underscore numbers and the values for this i am joining using the plus operator to add the tuple called letters to the tuples called numbers so let me run this cell so now if i reference this tuple called letters underscore numbers if i run that you can see it gives me abc one two three the key thing to remember about a tuple is that once a tuple has been created you cannot change the value neither can you add to the tuple so the tuple is unchangeable or immutable once it has been created so that is it for this video in this video we'll learn about python tuples hello and welcome to this video what is a python dictionary a python dictionary is a collection which is unordered which can be changed and which is also indexed a python dictionary is created by using curly brackets also a populated python dictionary will have keys and corresponding values so the data inside a populated dictionary is paired paired in the sense that they have keys and the keys have corresponding values you can access the items of a dictionary by referring to its key name inside square brackets the values of items in a dictionary can be changed also a dictionary can be nested that means you can have dictionaries inside other dictionaries i have created a new notebook and inside the notebook i have got the code here to create a new dictionary so i'm creating a dictionary called countries underscore cities you use the equals to sign to assign values to the dictionary and you enclose the values in curly brackets that's the opening curly brackets and this here is a closing curly brackets so these here on the left are the keys and then these here on the right are the corresponding values so each item in a dictionary must have a key and the key must have a value the key is always on the left and the values always on the right and then they are separated by the colon so you can see here these are all keys and these are the corresponding values so i'm going to run the cell when i try to run the cell i encountered an error that's because it's telling me here the key that's called Croatia it tells me where i've made the error i've left out the closing quotes so i need to come back here where the cursor is flashing and add the closing quotes so if i run that again that should now work you can access the items in a dictionary by referring to the key or referring to the values or referring to both in this example here i am accessing the item in a dictionary by the key so you can see that's the name of the dictionary in square brackets and passing in the value of the key which is Italy so if i run this i expect Rome to return as the value so let me run that you can see here it has returned Rome as the value you can also use a special function called get to return the value of the specified key so this is the name of the dictionary and i'm using the get function and inside the get function and passing in the key in this case Egypt and if i run the cell it will return Cairo so if i run that you can see it has returned Cairo you can also change the value in a dictionary so in this cell here i'm changing the value of the key that is called United States currently the key for that is New York i'm going to change it to Atlanta so if i run this cell now it should have changed that to Atlanta if i run the dictionary and just passing the key United States it should change it you should see the change we've just made which is Atlanta it should now show Atlanta as a value instead of New York so let me run that you can see now it's returned Atlanta you can also add items to a dictionary inside this cell here i'm adding a new key which is Japan and i am setting the value to Tokyo inside this dictionary called countries underscore cities so i'm going to run this cell you can notice here that i've got an indentation error that's because i've accidentally indented so you can see where the cursor is flashing i need to move back so that i'm indented properly if i run that again you can see now that has worked so if i print the dictionary it should now include the new key i've just added which is Japan so i click to run i can see here is added Japan as well that's Japan is the key and Tokyo is the value you can also remove items from a dictionary there are several ways to do this the first way is by using the pop method so you call the pop method on the dictionary and you're passing the key of what you want to remove so i've passed in the key Japan and this will remove the item for the specified key another way to do that is by using the delete key so you type in DEL the name of the dictionary and you're passing the key inside square brackets and this will remove the item from the specified key another way to do that is to use the pop item method and inside the pop item method this will remove the last inserted item all right i've commented that both because i don't want that to run i only want to run the pop method so let me run that and that will i've run that and also this print function here prints out the modified after removing Tokyo you can see Tokyo is no longer on the dictionary list after we've removed it using the pop method you can also loop through the dictionary keys to do that you use the for loop which you use to iterate over the dictionary keys so we say for x in the dictionary called countries underscore cities you print x x basically will represent each of the keys so if i run that you can see here all is done is printed out just the keys if you want to print out just the values there is a special function called values so you add that function to the name of the dictionary and you print x and that will return only the values so if i run the cell you can see it's only return the values for the dictionary if you want to get both the keys and the values there is a special function called items that you can call on the dictionary so here in this cell i'm saying for x comma y comma in countries underscore cities or items so this will print out the keys and value x represents the key and y represents the values so if i run the cell you can see here is printed out the keys and the corresponding values if you want to check the length of a dictionary there's a special function called len you can use that to print the length so you wrap that inside this print function and then you pass in the name of the dictionary inside the parentheses for the len function if i run the cell you can see it's return six tells me the length of my dictionary is six which means i have six keys and the corresponding values you can also have nested dictionaries which means you can have a dictionary inside another dictionary so in this cell here i'm creating a dictionary that has other nested dictionary so the name of the dictionary is family and you can see it contains other dictionary this is the first dictionary called first child second dictionary called second child and third dictionary 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 you pass in the name of the nested dictionary you want to access so in this cell here i want to access the dictionary called second child so if i run the cell you can see it's giving me the keys and the corresponding values for the dictionary called second child you can also clear or empty a dictionary by using the clear method so i'm calling the clear method on the dictionary called family if i run that that should clear it so if i now call the dictionary it should return an empty dictionary if i run that you can see here it has returned an empty dictionary so that is it for this video in this video we learned about python dictionaries thanks for watching bye for now hello and welcome to this video what are python operators python operators are used to perform operations on variables and values there are different types of operators in python so i'm going to cover some of the operators in python the first one is the arithmetic operators so these are basically used with numeric values to perform common mathematical operations so they include things like plus subtraction multiplication division and this here is called the modulus operator the next type of operator is the assignment operators and these types of operators are basically used to assign values to variables so these are what the symbols look like you've got the equals to the plus equals minus equals multiplication equals division equals and modulo equals we also have the comparison operators which are used to compare values and they include double equals two if you want to compare if two values are strictly equals to each other you use the double equals to sign if you want to check if one value is not equals to another you use this if a value is greater than you use that the value is less than the value is greater than or equals to the value is less than or equals to so these are all comparison operators the final type of operator i'm going to cover in this video is called the logical operators they are used to combine conditional statements so they include things like and or or not i have created a new notebook so inside this cell here i'm going to add some operators and i'm going to run through the code to explain what the operators do i have added some code into this notebook cell to illustrate how arithmetic operators work so i'm going to start with the addition operator so here i'm creating two variable variable x and variable y variable x i've given a value of seven and variable y i'm giving a value of five so i'm using the print function to print the value of x plus y so this here is the addition operator all right so i will run the cell later i'm not running the cell now i'm just showing you the examples of the operators within the arithmetic operator here we've got two values value x value y i'm using the print statement to print the value of x subtract the value of y so this here is the subtraction operator next we've got the multiplication the multiplication in python is represented by the asterix again we've got two values x and y we are using the print function to multiply the value of x times the value of y and then here we have two variables x is equals to 12 y is equals to 4 and we're using the print function to divide x by y slash is known as the division operator we've got one more which is the modulus operator so we've got two values values x equals seven value y equals five we're using the print function to print x modulus y modulus basically means when you divide by a number it will only only return the remainder from that division for example if you divide um seven by five basically five can go into seven once remainder two so the modulus operator will return the remainder which is two so let me run the cell and you can see the output you can see here the first value here is 12 which is x plus y so seven plus five is 12 and the second value here is two so if you take away seven from five which is the subtraction operator that gives you two the third value here says 35 which is multiplication if you multiply seven by five that will give you 35 next one is the division if you divide 12 by four that will return three and for the modulus operator modulus will always return the remainder so five can go into seven one remain one time remainder two so it returns the remainder which is two so this is how the arithmetic operator works i've added some code into my second cell in my notebook this is the second cell and this code here is going to illustrate how the assignment operator works assignment operators basically use to assign values to variables we already used that in the previous example for the arithmetic operator you can see all this equals to sign here we're using it to assign values to variables all right so there are different types of assignment operators so here i've got a variable called city i've given it a value of London using the equals to which is the assignment operator so here i'm telling the print function to print the value of city here i've got two values two variables x equals to seven and then x equals to plus equals to when you have a plus equals to you're basically saying add this three to the value of x so when you print x x will now print 10 because x is seven and we're saying we're calling the value we're calling x here and we're adding plus equals to means add three and then using the equals to to assign the three to the seven making it 10 so the same process with the minus if you do a negative equals to that means you're taking three away from the value of x same thing with the multiplication what that is saying is that you are multiplying three by seven with the division the same thing you are multiple you are dividing three the value of three here slash equals to mean divide equals to you are dividing that by three that will return two same example with the modulus here we've got the variable x equals to seven then x equals to the percent equals so which is modulus equals to three what that means is that for the modulus operator you're going to divide three by seven and return whatever is left so this here print x will return one because three can go into seven two times it will have one remainder that's what this print x is going to return so let's run this cell and then we can see so you can see here these are all the values let's go to the top of the value it says the we're printing x here which is a value of city and you can see here prints London and then the next one here we have the variable x and we're adding three to it so we print x x now becomes 10 so the same thing here we've got the variable x which is seven we using the negative equals to it will subtract three from that that will return four and then here we are multiplying three by seven give us 21 and here for the division we divide in three by six gives us two and here for the modulus three goes into seven two times remainder one so the modulus will return one I have added some more code to a new cell here to illustrate how the comparison operators works so comparison operators are basically used to compare two values so let me run through the examples here here I've got a variable x equals to seven variable y equals to three I'm using the print function to check the comparison where you have a double equals two it means you are comparing so you're saying print x is equals to a single equals two is used to assign a value where you have a double equals two is used to compare a value so not the difference here x equals to seven is a single equals two that is used to assign values to variables here in the print function I am checking comparison here so I'm checking if x is equals to y all right so this if I run the cell this is going to return fours because seven is not equals to three if we look in this example x equals seven y equals to three print x where you have the question mark it means print x is not equals to y this will return true because x which is seven is not equals to three and then we have again I'm going to use the same variables for the examples variable x is seven variable y is three I'm using the print function to print is x greater than y this will return true because seven is greater than three same thing here we're checking is x less than y this is returned false because seven is not less than three again the same thing we're checking x is less is greater than or equals to y this will return true because seven is greater or equals to three in this example same thing check if x is less than or equals to y this will return false because seven is neither less than or equals to three so let me run the code and you can see the output with a comparison operator you always get a true or false value because you're checking things is this equals to what and so on so you always get a Boolean result Boolean basically is a true or false outcome I have entered some code into another cell and this cell here is going to illustrate how the logical operators work logical operators are used to combine conditional statements okay so here I've got a variable x equals to seven and I'm using the print function to check some conditions so I'm saying x is greater than three and this and here is a logical operator and x is less than 10 this is going to return true because seven is greater than three and seven is less than 10 all right so if we look at this example here x equals to seven we're going to use a print function to check the comparison we're saying x is greater than three or x is less than four this is going to return true because one of the condition where you have an or all you need is one of the conditions to be true and that evaluates to true if you have an and both conditions must be true for it to return true you can see this x is greater than three is one condition and then x is less than 10 it's another condition the and here means that both conditions must be true for the outcome to be true with the or logical operator you only need to have one of the expression to be true and that will return true so in this case x is greater than three that will reach that returns true okay but seven is not less than four you can see here says x less than four seven is not less than four so this part of the expression is forced but it will evaluate to true because one of the condition in the comparison is true when you use the or operator here we're saying x is seven we're using the print function to use the not part of the logical operator we say not x is greater than three and x is less than 10 this is going to return force because not is used to reverse the result so let me run the cell and you can see the outcome you can see here first outcome is true second one is true and the last one is false in this video we learned about some of the operators in python thank you 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 type of computations or actions based on certain conditions which will evaluate to true or false these conditions are known as boolean conditions there are three main types of conditional statements there's the if statements the l if statements and the else statements what are if statements if statements are used to check conditions before executing a certain block of code they help make your programs make smarter decisions and they will only run or execute the code inside the if block only when the condition evaluates to be true if statements use comparison and logical operators to check whether conditions are true or false i have created a new notebook and inside this cell i have some code here to illustrate how the if statements work so you 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'm using the if statement here to check if variable b is greater than a now that is the condition so the greater than sign is what we use to check the condition so b has 80 and a has 40 so b is definitely greater than a so that 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 underneath the colon is the block of code that will execute when the condition is true so this print function here will execute this code that says b is greater than a because that condition is true if the condition was false nothing will happen the code will not execute so let me run the code by clicking on the run command you can see it's executed the code 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 do find the condition that is true it will only execute the block of code as soon as one of the conditions evaluates to true so if you're checking for a few condition it will execute the code it finds for the first conditions that evaluates 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 variable b has a value of 40 so they both have the same value so i've got an if statement which is checking is b greater than a so if b is greater than a the code inside the if block which is a print statement will execute in this condition the condition is false because both of them have the same value so that code inside the if block will not execute and then we have the code in the l if block which is checking so i'm using a comparison operator to check if you have a double equals two that means your checking is something is equals to another so i'm checking is a equals to b we know that they are because they both have the same value so the code inside the l if block will will execute because that condition is true they both are equals to each other so let me run this cell and you will see that the code inside the l if block is the one that has been executed which is the sprint statement that says a and b are equal what are l statements l statements are used to execute a block of code when conditions evaluates only to force added some block of code here into this new cell to illustrate how the l statement works so i have two variables variable a has a value of 20 variable b has a value of 10 i've got an if statement to check if variable b is greater than a if it is the code inside the if block of statements which is a print statement will execute in this case b is less than 20 so that will evaluate to force so that code will not execute we move on to the l if code in the l if we check in is a is equals to b this will evaluate to force so that code block will not execute we move on to the else statement which is going to evaluate to true because a is greater than b so that code will execute so let me run the code and you see is saying a is greater than b because that will that is the only condition that is true we also have what is called a nested if statement which is basically an if statement embedded inside another if statement i have added a block of code into this cell to illustrate how the nested if statement works so i've got a variable x which has a value of 51 and i've got my first if statement which is checking if x is greater than 10 that is going to evaluate to true so the statement which is the print statement above 10 is going to be printed and then we have the second if statement which is embedded inside the first one which is checking if x is greater than 20 that is going to evaluate to true so the print statement which says above 20 is going to be executed all right so we have two statements that evaluate to true so if i run that we should have two printouts the first one says above 10 which is for this one and second says above 20 which is for that so that's basically how the nested if statement works so in this video we've learned about python conditional statements thanks for watching bye for now what are python loops loops in python is basically a sequence of code that you want to be repeated or you want to run continuously until certain conditions are met so if you have a block of code you want to execute several times based on certain conditions you can use a loop and that code will continue to run until certain conditions has been reached there are two basic types of loops in python we have the while loop which are basically used to execute a set of code continuously until a condition evaluates to false so 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 item so for loops are particularly useful when you're using a list a tuple or a dictionary it can even be used to loop through a string so the for loop if you want to iterate and say print out certain elements or all the elements in a list you can use a for loop to iterate over that sequence i've created a new notebook inside the notebook cell here i've added some code to illustrate how the while loop works so with a while loop you have to have an initial starter point so i'm doing that with this variable called i and i've set the variable to a value of one so now that we have a starting point you can now start the while loop so to implement a while loop you type in the keyword while and then you specify the conditions you are trying to check for so i'm saying this variable i as long as this variable i is less than seven i want this print function to keep printing the value of i so what this will do it will continue printing i until it reaches seven so once it goes past seven that conditions becomes false and the loop will stop also when you have a while loop it is very very important to add an increment counter because the variable has a value of one so here you can see i have this counter here plus equals to which means it's going to be adding one to the value of that variable each time so the first loop will run it will print out the value of one and then this statement will add plus equals to means add one to the value of the variable i so it will keep adding one until it gets until it exceeds that level so the moment it comes to seven the loop will stop because it would have evaluated to force because i will no longer be less than seven so but it's very important you add this increment counter if not the loop will go on forever it will never be forced so the counter is very important so that at some point it evaluates to force all right so let me run this and then you can see what i mean you can see here it will print it prints up to six it doesn't print seven because that basically is where the condition becomes false it will keep printing as long as this condition is true so once it becomes greater than seven it turns to false and then the loop stops but it's very important that you always add the increment to the original value which is one if not the loop will continue forever which is which means that this condition i will always be less than seven if you don't add this increment to be adding one each time the loop runs to the original value i've added some code here into this second cell to illustrate how to use the break statement with a loop so the break statement basically is used to stop a loop even if the while condition is true so here we can see the counter i the variable i is close to one and i'm setting the while loop to say while i is less than seven i wanted to print the value of i and you can see here the increment counter is very important so that the loop will eventually evaluates to force and it will stop running so you can see here i'm adding a break statement so i say if when i becomes equals to four i want there to be a break all right so let's see how that works we'll run that and you can see here it stops at four even though the condition is still true because i at this stage is still less than seven but we are breaking the loop using this break statement you can also have the continued statement which you can use to continue from where you stopped within the current iteration of that loop so the continued works slightly different from the way the break statement works so here we've got the variable i equals to zero i was saying that while i is less than seven here you can see we are adding the increment here because initial value zero so we are now increasing the value to one and here we're saying if i when i becomes four continue and then we're telling it to print i so you will see here in when i run this cell that the number four is going to be missing from the report from the result because we're telling it to continue when it gets to four so it will skip four and then continue with the loop so if i click run you can see here it does one two three it skips four and then prints out the rest i've got some code in this cell here to illustrate how the for loop works so with a for loop you have to use that to iterate over a list so i've got a list here called fruits and it's got different elements in it so if i can use a for loop to iterate over this list of items and then print out each value so to implement a for loop you type in four x here is going to represent each item in this list called fruits so i say for x in fruits print x if i run the cell here you can see here is printing out all the items within that list you can also use a for loop to iterate into a string so you see here i've got a string called strawberry i can use a for loop to iterate over each character within this string called strawberry so if i run that you can see here is printing out 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 is called adj and the second is called fruits they both have three items so here i'm implementing a for loop so i'm saying for x in the first list called adj x we represent each item and then the second loop i will say for y y represent each item in the list called fruits so i'm using the print statement to print x we should print all the items in the list x and the items in the list called y so if i run that to make more sense you can see here is saying red which is this value and then apple for the other one and so on okay so that's basically how a nested for loop works it's a loop inside another loop in this video we learned about python loops thanks for watching bye for now hello and welcome to this video in this video you will learn about python functions you learn how to create a function and also how to call or activate a function what are functions in python functions are pieces of code 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 your programs into smaller and modular chunks so that as your program grows larger and larger the functions makes the programs more organized and easier to manage functions avoids repetition and makes it possible for you to reuse your code so once you've created a function you can reuse it as many times as you want once you've created a function the function does not do nothing until you activate or call the function so the process of activating the function is also referred to as executing or running a function and you do that by calling the function with its name so whatever name you've called your function if you want to activate or execute you need to call it by its name when you create functions you can have them have parameters which are variables so you can create a function and then passing variables which are known as parameters and also when you are calling or executing the functions you have to call it and supply arguments the arguments are referred to as values functions can return data as a result there are several types of functions they are built-in functions and they also use a defined function an example of a built-in function is the print function which you can use to print stuff or data on the screen and then you have your own custom which are user created custom they also refer to as custom functions the syntax for creating a function is fairly straightforward you use the keyword def which means you're trying to define a function followed by the name of the function and then you have the parentheses and then the colon the colon is very important because that creates an indentation for the function so anything underneath the indentation here which is created by this colon anything here is called the function body so when you execute or call the function this is the part of the code that will execute I have created a new notebook and inside the notebook I've added a block of code here I'm creating a new function called sum so you create a function by using the keyword def space you give the function a name and inside the parentheses you can pass in parameters if you want to parameters are like variables so you can see here I've passed in two parameters x and y you can also leave the parentheses blank without any parameters so after you define the function you add the colon the colon creates this indentation level 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'm calling the function which is called sum and inside the parentheses I'm passing in two values the first value will be for the variable x and the second value will be for the variable y so when you pass in values inside when you're calling 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 it has returned a value of nine because I've passed in two arguments four and five which will then execute what this function says it will print out the value of x plus y in the example function we created we use parameter and also argument I just want to explain again the difference between the parameter and the argument the parameter is the variable that is defined inside the functions parentheses while the argument is the actual value you pass or give to the function when the function is called what is the default parameter value this is the 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 as values are assigned by the position in the second cell here I've created a variable called student underscore names and inside the parentheses I have specified a default parameter value all right so this is the value that the function is going to use when I if I call the function without passing it any value so the name inside the parentheses is names this is going to be the variable and the value is going to be blue line so when I call the function this is what is going to happen is going to print this text hello plus whatever value that this variable names has so here I'm calling the function with and without arguments the first one here I'm calling the function without passing any value to it so if I call it now this should print the default parameter value which is blue line it should say hello blue line here I'm calling it and I'm passing it a value of john so now the name variable will now have the value of john and this I'm calling here again I'm giving it a different value so let me run that and then you can see you can see it says hello blue line which is a default value 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 call it again and give it a value of jane and it says hello jane so it basically execute the code in the body of the function which is this print statement here so whatever value the variable names has it will say hello to the value of that names variable