Python Scripting Tutorial for Beginners | Python Tutorial | Python Training | Edureka
Video Title: Python Scripting Tutorial for Beginners | Python Tutorial | Python Training | Edureka
[Music] hey guys I you she from Ed Eureka and today we’ll be learning Python scripting so let’s just quickly jump on to an agenda and let’s see what’s there in a plate today so we’ll start off this session by first discussing how scripting language is different from any other programming language after that we will be discussing about Python and the most popular versions that are out there in the market today then they will likely jump on to the practical aspects wherein we will learn about different modules in Python how can you perform a double scripting using the boto module so under this topic I will be telling you how can you write scripts to launch an ec2 instance or create an s3 bucket in AWS and all of this can be done by just typing few lines of code guys and find towards the end we will be going to the basics of GUI programming and will implement some of that as well so I hope you got the objective of this session now let us begin with the very first topic that is scripting versus programming language what is the difference between the scripting language and a programming language so scripting is used to automate certain tasks now there is one more thing that scripting language is less code intensive as compared to a traditional programming language they do not require the compilation step and I rather interpreted so for example a Java program needs to be compiled before running whereas normally a scripting language like Python JavaScript or PHP need not become pi now as you can see here in Java it creates a class file and then the output will be displayed whereas in Python all the codes are executed at the runtime so programming languages are compiled whereas your scripting languages are interpreted so basically a compiler translates your entire code and then runs the program there as an interpreter if translates and runs your code one instruction at a time now I would also like to add here that python is just not the scripting language it can also compile a Python code into byte code and then interpret it just like Java does and it’s nothing like one language is better or worse than the other every language has bronze and cones next let us not deviate at understand the next topic which is introduction to Python so python which is very famous many big clients like google youtube uses it so it must be having some great features so now let me just list a few of them so first of all python is easy free and open the first reason Lions held that it is extremely readable since it closely resembles our English language also it was created by guru vandalism in 1989 and was released first in 1991 next it supports your procedure ended as well object on the program now I am only told you that it’s an interpreted language which also a high-level language where one does not need to bother about low-level details you can simply write your code in English and Python to the intern convert into low-level details then moving ahead Python is portable as well as extensible so by portability I mean it is fit for many platforms the apply next platform beat Macintosh feed solar soy or any other then it is extensible so by extensibility of Python I mean you be completely integrate Java as well as dotnet components with it isn’t this great guys you can do a lot of things with Python next let us move ahead and talk about the popular versions of Python so there a lot of confusion between Python 2 and Python 3 let me first clear this confusion and then we’ll move ahead with the practical demo so if you’re learning new just jump into Python 3 because it has come up with some neat and clean features and also it is the present and the future of the programming language but if you’re already learning Python 2 or 2.7 or any version of 2x family don’t worry guys Python 2 is not too different in terms of your core language they are just a few differences here and there and if you learn to code in Python 2 it will hardly take you some time to learn the differences and the syntax so we all know that python 2 is used for many years many organizations make use of version 2 or 2.7 which contains a large number of libraries with a wonderful support community but again with the Riesz of Python 3 many libraries require support of the latest version so let’s say if you are doing web development and using a lot of libraries then you must go for Python 3 also python 3 has recently gained a lot of attention from the developers there is lot of additional features such as your overall performance has been increased then you have a better interpreter history also there are Auto completion features and you have many more like that it has also fixed some of the minor glitches from the older version and released Python 3 which is more stronger so it is faster and quite a stable version till now so as I already told you guys python 2 is the legacy whereas Python three is the present and the future of the programming language so you can learn either version of Python which you can later tailor according to your needs even if you start learning from Python 2.7 it will be a no big deal to ship the latest version as far as your focus remains to learn Python so I guess enough of theory part next let us discuss the various modules in Python so a module in Python is basically a file which contains Python definitions and statements now as you can see here I will be talking about these modules so it is majorly classified into sis module then OS modules sub-process Mac random date time model and the JSON module simply begin with the very first module that is the SIS module so now sis module basically provides to the information about the constants functions and the methods of Python interpreter so it is basically responsible for controlling and interacting with the interpreter now for example if you want to know any information on operating system or the version of Python you are using you will be using this module for that so first let us import sis using the import statement so it must actively show you how this can be done so let me just open my IDE that is pycharm all right so I’m in my PI chunk community edition project named as Python scripting so now inside this project I will created a Python file let’s say I name this SS module so now the first thing I need to do is to import this module so all you have to do is to just type in import sis now let’s go ahead and print the version let’s say I want to know the current version of Python so what I’ll do i type in print sister version and let me just run it so as you can see here the kind was your Python that I am using is Python three point six point one let me just zoom this a bit alright next if I have to print the command-line arguments which is path to the script so what I can do I can simply type in let’s say print since dot argv so basically argv is a list which contains the command-line arguments passed to a script so let me just run this again so as you can see here we are in this location which is indeed drive in IOC folder then I have a project name followed by the file that I’ve just created so as you can see here argument follows the script name so whatever argument we have currently we don’t have it right now but whatever we have it it will follow the script name now similarly we have a lot of functions we have stderr which basically stores your error messages then we have stdin STD out which is used to accept the input from the user whereas your STD out method prints you to the screen then you have an exit function which basically tells your interpreter to quit or you can say it’s a direct way to end a Python script next let me go back to the presentation and let’s see what is my next module so next is my OS module which stands for operating system so it must be pretty clear that this module is used to interact to my operating system also the primary use of this module is to create folders remove folders move your folders or sometimes change your working directory as well so you can also access the names of your file path by just typing in list dir so let me just show you some of the operations with this OS module if I go back to my pie chart it will create one more file here and I’ll name it as OS module so now first of all I have to import the modules who are typing import OS now let us first print the current working directory so I’ll type in print oh s dot get kind working directory that is CWD and let me just run this now as you can see here that my kind working directory has been printed now I can also change the directory so for that what you need to do you can just need to type in CH dir and just give the path so it means do that as well as well type in OS dot CH dir that is for change directory and inside this I’ll be giving a path so let’s say I want to go in this type through only D Aisha Python scripting so I’ll go to my files so let’s say I am in my D Drive and inside IOC folder I am creating a new fold over here let’s say you let the name be new folder only and I’ll just go inside this and I’ll copy the path from here now I’ll go back to my pycharm again and mint paste the path over here so remember guys whenever you copy or paste the path you have to be careful for the slashes you have to keep in mind that either double backslash will book or a single front slash we work so I’ll just type in here double backslash and I just print my current working directory so I’ll just cut it from here and it’s a spaceship below that and now let me just run this so as you can see guys my current working directory has been changed to new folder so this new folder is we have just created and using the command CH dir I have just changed my path so we have talked how to create a different directory all together but what if you need a directory in an existing directory so yes you can go ahead and create a directory as well for that what you need to do you just need to type in OS top mkdir and swift me ass typing OS dot mkdir that is make directory and I can write the path over here so let me just take this path only and in spite of new folder I want a folder named as Eddie Rekha let me just comment above sections all right so as you can see here we don’t have a directory named as a dareka so now let me just run this all right so remember guys a double backslash or a single firm slash will only work so I just changes to double backslash and now I just run this all right so here it says that in the name only exists so let us type in a Dirac r1 and now if I just run this so here you can see inside my D folder then in ayesha folder I have one folder named as ad Rekha one chick me just go to my folder and here it must be a breaker one so as you can see here I have a folder named Asteria Rekha one so if you don’t want to do it over here you can directly do it in your PyCharm also so for that lets me just copy this path this is my pressing directory so I’ll just copy my path and over here I’ll be pasting in this path so now this folder or you can just write area Rekha and I’ll just type in double backslash and if I run this code you will see the editor co-director here so let me just run this code so if you run this code you will see that a dreg a folder or you can see the directory has been created over here now you can also remove this I trip by just right-clicking it and delete it but now if you want to do it by codes so for that what you can do you can simply type in OS dot remove directory that is rmdir and then you can just mention the path so I’ll just copy the path so now I don’t need this 80 legged I trivializes paste it over here I’ll just comment this line and now let me just run it so as you can see a draga directory which was felt over here has been deleted next similarly you can delete a file as well so let’s say I don’t want to delete a directory instead of that I want to delete one file so let me just delete this module so let me just copy the path from here and to remove a file I just need to type in OS dot remove and I just paste the path over here remember guys to put the double backslash or a single front flash so I just put a double backslash I just come in the buff line and I’ll just run this so as you can see it says model miss peasant over here has been deleted now next you can also learn about another sub model of power switches OS dot path so it provides a range of useful methods to manipulates the files and directories should may implement some of the methods of this also so first let us talk about join so OS that path Jo join is one of the important Oh a spot tools so it takes one or more paths and joins them by using the current OS path separator say to join two paths so let me just comment this so now I need to perform the join operation so I just simply type in OS dot path toward join and inside this I be writing two paths so first of all what I will do I will just simply copy my directory path so I’ll take it from here I’ll pass it over here then I’ll be writing another part let’s say I want to join the OS module so I will just copy the path I’ll type it over here I’ll add the double backslash all right so now let me just run this so as you can see here my OS model has been joined with the Python script ring so next you can also split these paths so basically split function it takes a path name and turns it into the two parts that is the directory path and the file name so for that what you can do you can type in print and say OS but part pasty pasty let me just copy the spot alright and I’ll just comment this let me just now run them so as you can see it has splitted into two parts first is the directory and second is the Python file that is present over here so that is how you can use another function that is split next you can also use another function that is exists so this will basically tell that whether the path exists or not so it will return you a true or a false value so Isis type in over here exists I need to mention a path so in spite of this let’s say I want the OS module path so I will just copy the path and paste over here I’ll add the double backslash and I just run this so now as you can see this path exists so it is giving me the value true now similarly if the path doesn’t exist it will give me the value as false so these are some of the methods which are used in the OS module next let me go back to my presentation and pick up the next module so my next module is sub-process so this model basically lets you interact with operating system to create new processes pass the information into and out of them and then get the return codes so it can be used by using the coil function so you can simply write sub process call and what will it do it will basically run a command wait for the commands to finish and then gives back the return code so this is pretty much basic guys next let us talk about the next module that is the Matt module so as the name says it performs various mathematical function let’s say if you want to find out sine of X or let’s say tan of X you can do it very easily using this module you can also convert a number from radians to degree or vice versa or you want to calculate the natural log or let’s say log base 10 and a lot of other things so using this math module you can perform angular conversions hyperbolic functions special functions and you can do a lot of other things so let me just implement few of it for you so again go back to my PI charm I’ll create one more file let’s say this is maths module so first of all I need to import it so I’ll type in import math so now let me just return the value of constant so for that what I will be doing I’m typing in math the first typing in print and inside that I will be printing the value of pi all right so let me just run this so as you can see here the value of pi’ has been printed next what you can do you can determine the value of a constant also so if me just type in math dot e so this one basically returns me the value of constant e so as you can see here the value of e has been printed next what you can do you can also convert an angle from radians to degree so for that what I’ve been doing I will be typing in print math dot degrees and side that I will be writing any value let’s say zero point one and let me just print it now so as you can see here the value has been converted from irradiance to degree that is five point seven two similarly you can find the cosine of X or you can say any value in radians in degrees or anything so let me just do that as well so I’ll just type in print math dot a cause and inside this I’ll be giving a value let’s say zero point five and let me just comment the above statements and now let me just run this so that you guys will not get confused so here as you can see the cosine value has been printed next I want to do it for sine as well so I can simply type in a sign let me just run this so here the value of sine has been printed similarly you can do for tan as well let me just type in a tan and I’ll be giving the value let’s say five and it means printed now so as you can see here the value has been printed so why am i writing a because it will basically return the arctangent of X ingredients which is the value press it over here you can also type in let me just copy this and let me just paste it over here all right so in spite of writing a tan you can simply type in course and inside that I will be given the value let’s say three and let me just print it now so here it tells me the cosine of X or you can say the cosine of three ingredients now we have a lot of other functions as well so it means implement power and logarithm functions to let me just comment this till here and I’ll just copy it I will place it over here so it must implement some of the power and the guide tube functions so I will just type in math dot exp and inside that I will be giving a value to so this is basically they turned me areas to part two so if I just run this so as you can see here it returns me the value of e raised to power two next let me implement my new admin function as well let’s copy this first and instead of this I’ll be typing in Matt dot log and here I’ll be saying X comma base so here with ban argument you can return the natural logarithm of X to the base E and with two arguments you can return the log of X to the given base so if me just do that as well I just typing X space there or you can say 10 base 10 let me just run this now so we know that log 10 base 10 is 1 so it’s giving me the value 1 next let us go back to my presentation and let’s see what is the next module so next is my random module so this module will basically helps you to generate random numbers so it’s a pseudo-random number generator for various distribution let’s say you don’t want to type the number so you ask your computer to generate some random numbers and that is how it is used let me just go back to PI Chun and let us implement few of the operations of this random module so now let me just go ahead and I’ll create one more file which I’ll name as random module all right so first of all I need to import the model that is random next let me just print some random number so for that what I will be doing I be typing in print random dot R and range and I specify the range so I’ll type in 0 comma 50 I can simply say 50 and let me just print this so this will basically give me the number which will never be greater than 50 so as you can see here it gives me the number 2 they let me run it again it has given me 25 let me run it again it is given 38 and so on the numbers will be generated but again it will not exceed the number that is 50 now if I want to make this in a range of let’s say I want to make it in the range of 0 to 50 so here it will just give me the numbers between 0 and 50 and also you can add some steps to it so let’s say I want the step size to be 10 so let me just print this and let us see what does this step size me so I hope you see it’s giving me the result in step size of 10 so it’s giving me 10 then is giving me 30 then it’s giving me 10 again 20 so basically it gives me the output between 0 to 50 and in the step size of 10 so it will not be less than 0 and I will not be greater than 50 now you can also change the step size let me just change the step size to 5 and now let me just run this so as you can see here it’s giving me in step size of 5 so here it has been printed 25 that’s giving me 20 that’s giving me 5 similarly there will be numbers that will be generated now next if you want this Interiors so what you can do you can simply type in print random don’t run in and you can specify the range so let’s say I want the change in let’s say 0 20 it means post comment this and let me now print this so now it will give me the random numbers or you can see the impeding numbers between the range that is 0 to 20 so here it’s giving me 9 lens giving me 2 it’s giving me 6 and hence the number will be generated like these so now let me go back to my presentation and let’s see what is my next module so my next model is date time module so this model basically includes the tools for working with dates time and their combinations so the time mode includes the tools for working with time and dates in the recent past to the near future so it focuses mostly on manipulating time based on the computer’s internal representations of thing so let me go back to pipe job and it implements some of the functions of this module so I will just create a new file let’s say time module and first of all I need to import it so I will just type in import date time next for nets prints today’s day so for that what I be doing either typing in print date time dot date dot today so now let me just run this so as you can see here the current date has been printed so today it’s 21st March 2018 so now you can also perform some arithmetic function on this for example when you perform an arithmetic function on date time objects you will get the result in a time delta object so basically their attributes are days seconds and microseconds so i’ll create a new object let’s same now i’ll say date time or date time . today so now what we’ll do I’ll bring the difference between the two dates so what I will do I am applying some arithmetic operations to them where you will get the result in a time delta object shrink metate one more object let’s say other and say other dot date equals to date time dot date time and I mention a late let’s say 1994 now let me just print the difference between these two objects should I say print now – Adam so now let me just comment the above print statement so that you guys do not get confused and now let me just run this all right so here I have not specified a comma so now let me just run this alright so as you can see here difference between these two dates has been printed so I have already told you that the attributes for these are days seconds and microsecond so here it is telling me that 8563 days are there and then we have the other retailing as well let’s say I see in the last module that is my JSON module so JSON is popular communicating between the web servers and the clients so in Python the JSON module provides an API singer to convert in memory Python objects to a serialized representation that is known as JSON or you can say JavaScript object notation and a wiser versa so JSON has the benefit of having implementations in many languages and specially JavaScript making it suitable for your interrogation communication so this JSON module provides an easy way to encode and decode data in JSON so now let me just go back to my pycharm and i just implement this as well so I will create one more file JSON module first of all I need to import it so I’ll just type in import JSON so now what we’ll be doing I’ll be force typing in some data in JSON so let’s say I have an employee data so I will say employee data equal to let’s say I have some people let me just give some attributes to them so I say the name let’s say the name is Yoshi then I specify and emails well type in email and then I’ll just type in let’s say hey at the achievement calm and then let me just give one more email id let’s same hundred email again then I’ll give one more attribute let’s say married or you can say the marital status will say false and I’ll just close this similarly I’ll take one more so I’ll just copy it from here I just paste it I just changed the name so let’s say this time it’s an ammeter I’ll change some email ID as well and now let me just print it so I’ll just print this employee data so as you can see here my JSON has been printed now let me do it in Python as well so I’ll just take a variable it’s a data and I just load this JSON so I’ll say json dot loads inside this i’ll be just passing my json that is my employee plus and I’ll just print it let me just run this now all right just giving me some edit all right so I haven’t closed this so I’ll just close this all right so I guess it will work now so let me just run this now yes so as you can see here my JSON which is being printed over here and that is how I just load the data in Python it gives me this result so basically it has converted your JSON to a dictionary so whenever you load JSON into Python it uses some conversions such as your JSON object has been converted to dictionary so as you can see here your data has been in key value pairs now so this is my key and this is the value of the key similarly I have another key which is email and this is the value to it so basically whenever you load the data in Python it has the object or you can see the JSON object is converted to a dictionary now there are also few more changes which has been done so if you see here such as your array has been converted to list then if you see here you have a JSON which says that matter is false and if you see here it has been converted to the upper case false so these are some of the conversions which Python do this one with a version where you have a value which is null and then if you see it over here it will be changed to none so that is how whenever you load a JSON into Python it uses some conversions also this JSON module provides an easy way to encode and decoding JSON so there are basically two main functions which are json dot dumps and json dot loads so I already told you about json dot loads so here you have a function which says json dot load and inside that you can just load a file similarly you have json dot loads so basically this as a difference of s so whenever you want to load up string so for that what you can do you can just typing json dot loads and inside the brackets you can pass on the string value now you have another function which is called a json dot dump so using this function you can just load the json object to a file and again if you type in json dot dumps you will be having an output JSON object as a string so that is how JSON object plays a major role in the modules in Python so now let’s move on to our next topic that is aw scripting so here we were talking about the boto module which is an AWS SDK for Python so an AWS favorite formal to task first of all will be creating an ec2 instance and then we create an s3 bucket now let us see how you can configure this boto module so first of all to import what we just need to type in pip install Bo to 3 and once the installation has been done you also need to install the AWS command-line so for that we just need to type in pip install AWS CLI many times you have some problems regarding PIP so what you can do you can go to Google and you can just download the MSI file for AWS CLI then one this is done you can just type in AWS configure and then they’ll be asking you for the access key so now let us go to my PI champ and let us implement how we can do that so I’ll just create one mol file let’s say AWS scripting so first of all I just go to my terminal so I’ll just type in fist install boot o 3 so now this will take some time so now it tells me that the requirement is already satisfied so I already have my Bordeaux 3 installed so next what you need to do you need to install the AWS CLI so I’ll just type in pip install AWS CLI and hit enter so again I have already installed my AWS CLI so again it’s giving me this statement that the requirement already satisfied next step you need to type in AWS configure so I just type in AWS configure so now as you can see it’s asking me for the a dumbness access key ID so what I’ve been doing I’ve been going to the aid of list management console and be generating a user which has an access key to it so once you configure your AWS it will ask you for the AWS access key so now to find an access key what you need to do you need to go to your AWS management console and there you have to create a user which will be having an access key to it select Amina’s go to my AWS management console alright so this is my aid of this management console over here I will be just typing in I am which basically stands for your Identity and Access Management so over here you just need to go to users and just add a user over here so I just create one user over here so I’ll say user I give a name to it so let’s say user one let me just give the permissions to it just click on next so I’ll look at some policies then let me add some admin sheiter access and then just quickly go and click on next so here as you can see I have a username I have access type and you have all the required information then you just need to create a user so I just click on create user it just takes some time so as you can see here I have the user which is named as user 1 then I have the access key ID and I have the secret access key along with the password so here what do you need to do you can simply download the CSV so I am just downloading a CSV from here now why I am telling you to download it because later if you face any problem with the AWS authentication you will not be able to access these keys so the better way is to just download the CSV if I just open the CSV and let me show you what all is present over there so as you can see here I have the username I have the password I have the access key ID and I have the secret access key and this is the console link so what I’ve been doing and we just copying this access key ID and paste it to my PI job so here it’s asking me the aid of his access key so I just paste it over here then ask me for the aw secret access key so I will again go to that CSV and I will copy this and paste it over here then tells me the default region which is us is 2 okay and I just click on enter so here my AWS has been configured and the default region is the US east so now let me just go to my coding part and let us just write the script for it but first let’s understand what exactly they are so easy to basically stands for your elastic cloud computing which is a web service which provides resizable compute capacity in the cloud so it is basically designed to make the web scale computing easier for developers so it allows the users to rent virtual computers and wish to run their own computer application so there are many big companies who use an ec2 like limbo Guinea Netflix NASA and many more like that so now let me just go to my coding part and let us just write the script for it so first of all I just go ahead and import boto 3 next what I’ve been doing I’ll be creating an ec2 instance so for that what I will be doing I’ll be creating an object let’s say easy – then I’ll say ec2 equals to bordeaux 3 dot resource and inside this I’ll be passing ec2 so here I’ll be writing a script so to launch an ec2 instance without manually going to the AWS console and adding the instance over there so I can show you that as well so if we just go to AWS console so here as you can see the first compute services ec2 so Isis click on it so what you can do again come to this area based management console and launch the instance from here but in spite of this what I will be doing I will be writing a script so that if ec2 instance can be launched automatically so next what I have to do I have to type in instance is equals to e C to dot create instance and inside that I will be giving some specifications to it so first of all I bet giving the image ID or you can say the ami which stands for Amazon machine image so here I’ll be giving that so from where I can find this image ID so again I go back to my Amazon console and I’ll click over launch instance so here as you can see I have my a my or you can say that image I despise this copy this image ID I’ll pass it over here next I just need to give the main count and mark out next time is specifying the type of instance so I have t2 dot micro and finally I’ll be printing the ID of the instance that has been created or that has been launched so I’ll say instance zero and I’ll just type in ID I’ll just remove the extra praise all right so here as you can see I have just created ec2 instance where and I have just given the image ID and specify the min Max and the instance type so now let me just run this or before that I just go to my console and show you that there are no such ec2 instance running so I go to our instances so as you can see here I don’t have any instance now let me go back to code and let me just run this code now so as you can see here it has printed me the ID of the instance so now let me go back to my console and let’s see whether the instance has been launched here or not so now let me just refresh this so yes it has been launched it has the same instance ID which is given over here and the instance is t2 micro and the instant state is spending right now but it will be launched in just a few seconds so let us just wait for some time so as you can see how my instance is up and running now now you can also delete this instance so you can also go here you can click on actions and you can just go to instance state and terminate it but again if you have to do it to python script so what you can do you can go to a PI job again and in the stipend instance ID so I’ll specify my ID which is this while just copied from here then what I’ll be doing I’ll be just saying instance is equals to ec2 I’ll give the instanceid to it then I’ll be having response wherein I will terminate this ec2 instance so I’ll just type in instance not terminate and I’ll just bring the response so first of all let me just comment this part so that the new instance is not being generated all right so this is the code for deleting the instance so here I have just specify the instance ID that I need to terminate and I’m just print the response so now let me just run this so as you can see here it has been terminated we have the current state then we have the code we have the name – shutting down and we have the instanceid so here it is also telling me that the previous state was running and now it has been changed – shutting down let me just go to my concert in it to see whether here we have changes or not shake me just refresh it so here as you can see it has been shutting down so now I’ll just wait for few seconds and it will be terminated so as you can see here my instance has been terminated without manually going to the actions and then clicking it over here so it can simply write the Python codes and it will indeed do the same task for you so isn’t this easy guys now let me go back to my presentation and let’s see what is my next task so here I have just launched an ec2 instance and then we have terminated the state as well moving ahead let us understand AWS s3 so a Douglas s3 is a simple storage which is offered by AWS so it is basically a web service interface that can be used to store and retrieve the data so s3 basically stands for your simple storage service which is a storage for the internet so SC provides object storage which is similar to your file system wearing the folders are represented as buckets and the content of the buckets are known as the keys so now that is move ahead and launch an s3 bucket as well so now let me create a new file let’s say s3 scripting so first of all I need to import my boto module so now what I’ll be doing I’m creating an s3 storage so a bit I think in s3 boto three-dot resource the same thing that we have done for easy to so inspire this I’m just typing in s3 now let me go back to my AWS console and let’s see where this is present and how can you manually create an s3 bucket so I just go to my services and go in my storage s3 so as you can see here I have a button over here which says create bucket so you can manually go and create a bucket from here and these are the buckets that have been stored in my account now what I’ll be doing I’ll be writing a Python script so as to create an s3 bucket automatically for me so I’ll just type in let’s say the name of the bucket well type in bucket name and I specify a name let’s say bucket 1 and I’ll try some cry out to it so I see response equals to f3 not create bucket wherein I will pass on the bucket names well say bucket is reposed took my bucket name which is bucket one then I just pass the configuration so I’ll say create bucket configuration some attributes to it so I will be giving in the first attribute that is location constant and I specify the location so remember that is when you are configuring your AWS account they gave you an option to fill in the access key so they’re also they ask you for the default location so there I didn’t change any so I have the default location as US East two and here I’ll just print my response then I be just typing in the except that is the exception except exception as error and as print the error if any other comes so now let me just run this code all right so here it’s giving me an error that in by bucket name well it’s well just change his bucket name let’s say I usually bucket so I’ll just run this code now so as you can see here I have the response which says s3 bucket and with the name IOC bucket so now let me go back to my AWS console and let’s see whether the bucket has been created here or not so here as you can see I don’t have any bucket with this name but now let me just refresh it so now as you can see my s3 bucket has been created so guys this is how you can write simple codes and implement a lot of things by using Python so now let us go back to my presentation and let’s see what is the next task so here we have successfully launched an s3 bucket next let us move on to a last topic which is the GUI programming Python provides a various options for developing your geo ice which is nothing but your graphical user interfaces so many libraries which I’ve been commonly used I peek into then we have Jethro and we have the Blake’s Python so he does just create a GUI using P character so here this is my library which is called as tkinter and this is a simple code wherein you will just generate a window so now let me go back to my PI charm and let us see how take into works so here I will be creating a new file let’s say gy programming and over here are the first importing tkinter so I’ll say import tkinter you can also import these libraries by going to file just going to settings and under the project just go to the project interpreter and over here you can add the packages from here so you just need to click on this Plaza icon and the list of packages will be displayed to you so from here you can import any packets so now with these since you might talk about boto so we can just type in Berto 3 and here Bota 3 is presence we just click it on here and install the package so guys if you have any shoes or any problems regarding the code comment below the video and I will be happy to help you with the same so now let us just come back to a program and let’s implement tkinter so thinking it is available for all the versions of Python now first of all let us check whether this the kinder is working or not so for that it may just type in tkinter dot underscore test and now I just run this so here as you can see I have this pop-up coming up which gives me this window with two buttons we just click me and quit so this proves me that my peek inter is successfully installed now what I will do and remove this line and I will be creating a blank window wherein we have a closed sign minimize and all that stuff so for that what I need to do I need to type in from tkinter import ek so now let us enter some dummy text to it for that let me just remove this so here I have just import a key so you can also import from tkinter import TDK or you can simply write in from tkinter import star now what I’ll be doing I will be creating an object or I can say let’s say it’s named as dude so I’ll say it would is equal to Tk so here the root is basically a class which is the main window that surrounds our interface then once we have done that we’ll give a title to this so we’ll say root dot title and inside this I will be writing some text so let’s say first GUI using Python adding some button as well so for that I’ll be just typing in ttk dot button and I’ll be passing in the root and a text to those patterns let’s say I want the text as hello and Eureka I have set a grid to it so grid is nothing but a simple layout manager which will help you to structure different components or the widgets inside the window next I just close this loop so I’ll just type in root dot main loop so as I’ve already explained you that this window will keep on running untain this you decide to close it so here’s run this code and as you can see here I have a title to this window as well as a button so now let us see the different complaints which can be used in GUI application let me go back to my presentation once so have discussed that how you can create a window next what are the different components in a GUI so these are the basic competence which are present in the GUI application so first we’ll start off with labels how we can add a label then we’ll see how we can create a button so we have already seen how you can create a button then what we’ll be doing will be creating a frame wherein we have the label as well as buttons then we’ll go into the details of grid where this geometry manager and tells how you can define all the components within a window then we’ll be talking about the radio buttons and check buttons as well let me go back to my PI charminator implement these so till now we have just given a title and a button to it now let us create a frame so for that let me first comment this code all right so now let us create a frame so frame is nothing but our widget which surrounds the other widgets so I’ll just type in frame and it’s a frame and I pass in the root is nothing but charge DK or you can say Peking though next I’ll create a label text so let’s say label text I’ll say string math so over here I am just defining this but we’ll be changing the text for the label components so now let’s create a label and buttons with some attributes so first of all I create a labels who lets a label is equals to label and it should be inside of frame so I’ll just type in frame and then I have text variable equals to my label text so here this label text will be changing this afterwards now let’s have a button so I say button which should be placed inside a frame and we have a text tech tip hey I am a button then let us just change the text inside the label component so for that what you can do you can type in label text got set inside this I can just change the text let’s say I won’t type in hey what’s up and then what I’ll be doing I be just using a pack so pack is nothing but it’s geometry manager which defines how all components are arranged inside the window or you can say it’s used to position the widgets inside a label so I have just packed my label then what I need to do I need to pack my button as well so i say button dot pack I’ll pack my frame as well and finally I’ll be just closing the loop so I’ll say do dot mean do I just run this Sigma just expand this a bit so as you can see here I have a label and I have a button and as you can see here my label text has been changed as well now you can also have various attributes to this Geo application you can also fill the directions to it you can mention whether it should be stitched among the x axis or y axis or it should be stretched from both of them and there are a lot of things you can do it so when it means implement some of the attributes to it so I have just committed all the above code and inside this I’ll be having one label so I’ll say label it should be in spite of frame then I have a text let’s say say and I just simply Pat this next I have a button which is again inside of frame I have a text to it let’s see text is B Y and then I just bug this now when I pass this I can mention the attributes such as I’ll say that it should be in the left hand side then I specify the field which should be filled in the y-direction so this field I actually basically it will tell you how they will be stretched so it will be stretched along the x axis or Y axis or x y axis or both of them similarly you can have many more buttons like that so I’ll just copy this line and I’ll just paste it over here well it and I’ll just change the text to it so I will say b2 b3 b4 and then as us change the side as well so you can distinguish between the different buttons let’s say it’s right now remember guys it should be in uppercase so I’ll say right then here I’ll say it should be top and it said be left only and then I’ll be changing that direction also so I’ll say it should be X direction or should be straight among along the x axis and this should be Y again so now what I’ll be doing I’ll just pack the frame and I just close the loop now let me just run this all right so he’ll my label should pick capital all right now let me just run this so now as you can see my patterns has been arranged beautifully so here my b1 has been set to left so here it has been aligned left then my b2 is been aligned right so it’s again in the right hand side and it’s in the x-direction similarly your b3 and b4 are aligned top and left along with the directions so that is how you again set various attributes to AGOA application let’s let me go back to presentation and let’s see what all are left so we have learned how to create labels then buttons then how to create a frame in with labels and buttons are pack then let us see how you can create a grid so now let me go back to my pycharm let’s implement green as well so again I just comment the whole code for now so now what we’ll be doing I’ll be first having some labels so let’s say as specify a label inside a root and I have already mentioned root is equal to Tk so I’ll be giving some text to it so let’s say I want text let’s a name and I want the grid to it so grid is nothing but a geometry manager which will basically help you to structure different components or the widgets inside the window so here you can mention the row and remember guys your index will always start from zero then you can mention the column let’s say my column is also 0 then I have sticky and I can give some direction let’s say not so sticky is nothing but how your widget can expand and in which direction so you have very directions such as North you can type in East you can type in W for West and you can specify according to your needs so I just created one label now what I’ll do I create one entry both wearing the user get take input so I will type in entry and I’ll pass the route then I can specify the width let’s say it is fifty dot grid and I’ll again mention the road to it let’s say Rho is equal to zero and lets it column is equals to one and I’ll have one more button let’s say button and I’ll say it root and I’ll have a text which says submit and then pass the grid functionality which is in the row zero and column let’s say five and I just close this loop now let me just run this code so as you can see here I have my label which is named as name then I have an entry box so here you can type in any name let’s say I want to type in ABC and I have a submit button so here the submit button will not do anything but you can actually save the entries to a SQL database or anything you like so we’ll be discussing the SQL databases in all those stuff in our upcoming sessions but in today’s sessions let us focus on GOI also if you have any doubts you can just let me know in the comment section and we will be replying you as soon as possible alright so this is done so now let me go back to my presentation and let’s see what else is left so we have covered the various attributes of grid now let us talk about the radio buttons and check button so let me go back to our PyCharm let’s see how can you add a radio button and check buttons to your code so now what I will do I have a label I have a entry box and I have a button so next what I’ll be doing I’ve been creating one more label let’s say I’ll just try it over here let’s say I have one more label inside a root and I want text as gender via the great functionality to it so I say Rho is equal to 1 then Coulomb is equals to 0 and sticky to north or you can say n then what I will be doing I’ll be creating a radio button so for radio button what do you need to do you just need to type in radio button inside a root which has the text let’s say if that is for female and I’ll specify the value to it let’s say 1 so this will basically ensures that which radio button is clicked on next I’ll be just giving the grid so I’ll just copy the same thing from here and I’ll change the column value let’s say it is one now and I’ll have one more radio button where I have a text as M or you can say mail I have a different value to it let’s say value to it should be in different columns while specify a column – and stickety so now let me just run this all right so as you can see here I have my two radio buttons that is female and male and once you click on this the value over here that we have given you can click on these radio buttons now let us see how we can implement the check buttons as well so here I have implemented radio buttons so check buttons are also very simple so again for check buttons I will first create a label so I’ll just copy this label line and place it over here I’ll say the text as courses it should be in my Row 2 column should be 0 and should be stick it was the noir direction next I need a check button so a safe check button it should be inside route and specify a text to it so let’s say I want Python then I’ll mention the grid let’s say it should be in the Row 3 column should be 1 and sticky towards the north direction now I’ll just copy this line and paste it over here so now let me just change the courses name let’s say it’s Django then let’s say it’s it’s fast which are nothing but the frameworks of Python so now I just change the rows that is 4 and 5 and columns should remain the same only so now let me just run this code so as you can see here I have the radio buttons and I have the check button this will so if I click on python a check is been displayed similarly you can do it for django and class which are nothing but the python frameworks so as you can see here i have created a shorty or a application which has a name which has a gender and then you have some courses or you can say the check buttons and similarly you can create a entire form and just click on submit so clicking on submit right now it doesn’t do anything but you can do a lot more when you go into details of it so let me just close it for now so here i have discussed all these comm prints so now let us implement a basic operation using all these so now let me just comment the whole code and what i’ll be doing I will be performing some arithmetic operations so now what I’ll be doing at the first creating a function so let’s shape I will be creating a function let’s say Square this will basically give me the square of a number so here I’ll be writing in event so there I have just created a function which is Square and inside this I’ve given an event now let us first create the interface and then we’ll come back to the logic so whereas a root is equals to Tk well it’s I guess over here I haven’t so let me just comment from him all right before creating a label so let me just type in label then it should be inside a root I’ll give some text to it to let’s say I want to find the square of a number I just type in that and I’ll just pack it next what I’ll be doing I will be taking an entry of a number so I say number one I can say num 1 is equal to entry and I’ll pass on the root next I’ll just Pat this route and I can give some attribute let’s I want to give it should be aligned to left next what I’ll be doing I’ll be creating one button so this should be inside a root and it has a text let’s say squares 2 and I’ll just bind my button so I’ll say button dot bind and I’ll specify the button let’s it’s button one and pass on the function that is square so what I’ve done here I have just find it even handler to a button which is nothing but bpn so whenever person enters a number and clicks on button which is equals to squares 2 it will just bind or event listener so now let me just pack this button as well so I will say button I can see BTN dot back I’ll say sign is equals to left next I’ll have one more entry box which gives me the result so I’ll save results and I’ll have a entry I’ll pass on the truth then I will be typing in result dot pack and I specify the side as left again and finally I’ll be just closing my loop so now my interface is ready now let’s go to my method where I will write the logic so here what I’ll be doing I’ll be first needing the number so what I’ll do I say a hint and I’ll say number not gate so this will basically get my number so next what I have to do I have to calculate the square of that number so I say a into a and stood in the B then would I need I want the desired which is a button over here I want to display the desire in this button so I’ll say dissolve dot insert and I’ll pass over 0 comma B which is the square of the number so now let me just run this and let’s see whether this works or not so now as you can see here I have the small Jo application so now let me just enter the number let’s say two squares – so this gives me the result as 4 similarly if I say 22 squares – so it’s just giving the output after that so what I need to do I just go over here I just change a logic a bit so I just need to delete the previous value so as a result not delete and say 0 and I’ll say end and now let me just run this so now I press it two squares – – then I say 22 squares – for a repo and you can buy it similarly you need any number so this is how we can perform various operations on this GOI application well now let me go back to my presentation let’s see what else we left with so here we have implemented all these small components to create a basic geo application so let me summarize this session so first of all we have discussed how a scripting language is different from a programming language after that I have introduced you to Python and smelliest features then we have covered the various modules in Python which are sis sub-process OS math.random date/time and json and we have implemented some of them as well then they have talked about aw scripting wherein I have showed you how to create an ec2 instance using the boto module and then you also created an s3 bucket with the same and find it well chain we have learned the basics of GUI programming so I hope you found this session informative so if you guys have any doubts or any questions you can just comment below and I’ll be happy to help you with the same well thank you everyone bye bye I hope you have enjoyed listening to this video please be kind enough to like it and you can comment any of your doubts and queries and we will reply them at the earliest do look out for more videos in our playlist and subscribe to any Rekha channel to learn more happy learning
-
Sale!
Wireless WIFI Repeater Extender Amplifier Booster 300Mbps
$29.99$14.99 Add to cartWireless WIFI Repeater Extender Amplifier Booster 300Mbps
Categories: Electronics, Wi-Fi Router, Wireless Wi-Fi Extender Tags: 300Mbps, 802.11N, Amplifier, Booster, Extender, mobile wi-fi booster, Remote, WIFI, Wireless, Wireless WIFI, Wireless WIFI Repeater, Wireless WIFI Repeater Extender, Wireless WIFI Repeater Extender Amplifier, Wireless WIFI Repeater Extender Amplifier Booster, Wireless WIFI Repeater Extender Amplifier Booster 300Mbps$29.99$14.99 -
Sale!
Full RGB Light Design Gaming Headset Headphones with Mic
$24.99$14.99 Add to cartFull RGB Light Design Gaming Headset Headphones with Mic
Categories: Electronics, Gaming, Gaming Headsets Tags: Design, Full, Full RGB Light Design Gaming Headset, Full RGB Light Design Gaming Headset Headphones, Full RGB Light Design Gaming Headset Headphones with Mic, Gamer, Gaming, Gaming Headset Headphones, gaming headset wireless, Headphone, Headphones, Headset, Light, Mic, Package, RGB$24.99$14.99 -
Sale!
Wireless BlueTooth Multi-Device Keyboard Mouse Combo
$39.99$19.99 Add to cartWireless BlueTooth Multi-Device Keyboard Mouse Combo
Categories: Electronics, Gaming, Gaming Keyboards, Keyboard Mouse Combos Tags: Combo, Keyboard, keyboard mouse combos, Mouse, MultiDevice, Set, WireKeyboard Mouse Combo, Wireless, Wireless BlueTooth Keyboard Mouse Combo, Wireless BlueTooth Keyboard Mouse Combos, Wireless BlueTooth Multi-Device Keyboard Mouse Combo, Wireless BlueTooth Multi-Device Keyboard Mouse Combos$39.99$19.99 -
Sale!
High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar
$199.99$139.99 Add to cartHigh Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar
Categories: Gaming, Gaming Chairs Tags: Adjustable, Chair, computer chairs, Desk, Executive, Gaming, Girl, Headrest, High, High Back Leather Executive Adjustable Swivel Gaming Chair, High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest, High Back Leather Executive Adjustable Swivel Gaming Chair with Headrest and Lumbar, High Back Leather Executive Adjustable Swivel Gaming Chairs, Leather, Lumbar, Office, Racing, Swivel$199.99$139.99 -
Sale!
Professional LED Light Wired Gaming Headphones with Noise Cancelling Microphone
$29.99$19.99 Select optionsProfessional LED Light Wired Gaming Headphones with Noise Cancelling Microphone
SKU: N/A Categories: Electronics, Gaming, Gaming Headsets Tags: Cancelling, Gaming, Gaming Headphones with Noise Cancelling Microphone, gaming headset, Headphones, Headset, LED, Light, Mic, Microphone, Noise, Professional, Professional LED Light Wired Gaming Headphones, Professional LED Light Wired Gaming Headphones with Noise Cancelling Microphone, Wired, Wired Gaming Headphones, Wired Gaming Headphones with Noise Cancelling Microphone$29.99$19.99 -
Sale!
Gaming Desk with LED Lights USB Power Outlets and Charging Ports
$349.99$249.99 Select optionsGaming Desk with LED Lights USB Power Outlets and Charging Ports
SKU: N/A Categories: Computer Desk, Gaming, Gaming Desk Tags: and Charging Ports, Charging, Desk, Desks, Gaming, gaming desk with led lights, Gaming Desks with LED Lights, Home, LED, Lights, Monitor, Office, Outlets, Port, Power, Room, Stand, USB, USB Power Outlets, White, Workstation$349.99$249.99 -
Sale!
Wired Mixed Backlit Anti-Ghosting Gaming Keyboard
$99.99$79.99 Add to cartWired Mixed Backlit Anti-Ghosting Gaming Keyboard
Categories: Electronics, Gaming, Gaming Keyboards Tags: Antighosting, Backlit, Blue, brown, Gaming, Gaming Keyboard, gaming keyboards, gaming keyboards and mouse, Keyboard, Laptop, Switch, Wired, Wired Mixed Backlit Anti-Ghosting Gaming Keyboard, Wired Mixed Backlit Anti-Ghosting Gaming Keyboards, Wired Mixed Backlit Gaming Keyboard$99.99$79.99 -
Sale!
Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset
$119.99$59.99 Add to cartWireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset
Categories: Electronics, Gaming, Gaming Headsets Tags: 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset, ANC, Audio, Bluetooth, Cancellation, Ear, Earphone, gaming headset, Headphones, Headset, Hi-Res Over the Ear Headphones Headset, HiRes, Noise, Wireless, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Headphones, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headset, Wireless Bluetooth 5.3 ANC Noise Cancellation Hi-Res Over the Ear Headphones Headsets$119.99$59.99 -
Sale!
Wired Sports Gaming Headset Earbuds with Microphone
$19.99$9.99 Select optionsWired Sports Gaming Headset Earbuds with Microphone
SKU: N/A Categories: Gaming, Gaming Headsets Tags: Accessories, Earbud, Earphone, Earphones, Gaming, gaming headset with microphone, Headphones, Headset, IOS, Microphone, Sports, Wired, Wired Sports Gaming Headset Earbuds, Wired Sports Gaming Headset Earbuds with Microphone, Wired Sports Headset Earbuds$19.99$9.99 -
Sale!
150W Universal Multi USB Fast Charger 16 Port MAX Charging Station
$49.99$29.99 Add to cart150W Universal Multi USB Fast Charger 16 Port MAX Charging Station
Categories: Charging Stations, Electronics Tags: 150W, 150W Charging Station, 150W Universal Multi USB Charging Station, 150W Universal Multi USB Fast Charger 16 Port MAX Charging Station, 150W Universal Multi USB Fast Charger 16 Port MAX Charging Stations, 150W Universal Multi USB MAX Charging Station, 16 Port MAX Charging Station, 3.5A, Charger, Charging, Fast, laptop charging stations, Max, Multi, Port, Stand, Station, Universal, USB$49.99$29.99
Got a question on the topic? Please share it in the comment section below and our experts will answer it for you. For Edureka Python Machine Learning Course curriculum, Visit our Website: http://bit.ly/2OpzQWw
Do we have a 2023 version of this python scripting tutorial? please do share the link if video available.
Such nice information about modules 👍
pretty good tutorial video, thanks
Thank you. Extremely helpful.
I love how straight to the point this tutorial is <3 Well done!
JUST A BEGINNER RUSH TO LEARN
It was very informative.. thank you mam
Excellent!! Thank you so much its so useful. Do post more about python scripting
Mam/Sir Can u please share the code
what is the purpose or use of joining two paths using the join() funciton?????
Thank you Aayushi! This video provided great insight into Python Scripting
learned so much in just 1 hr mainly because of this amazing platform. Really good job
Applauds to YOU, very nice session!!
hey can you make a video in networking from scratch to advance
Nice Tutorial
Helping me towards Scripting and Web Applications understamding
Thank you.Great intro!!!! Really gotta pay attention to capitalization 🙂
great stuff. as an accomplished engineer i found this super helpful for brushing up on these skills! keep up the good stuff!
o wawo i have learn so much ,
her tricks to teach and i ahve take intrest in her class
thanks from italy
Informative video
At 19:50, random.randrange(50) gives you a random number in range [0,50). It would not return 50 itself.
At 16:25, she means arc (inverse) cosine.
At 13:00 what do you mean by "joined"? It seems to me like nothing has happened?
very nice vedio que how to python script in background
The tutorial is crisp and clear.
Same as your voice 🙂
Great job Ayusha,keep up the good work . Beginners like me will be benefiting a lot fro this tutorial. Thank you!!!U r a Pro in this 😉
really super session on python Ayusha , i got clear idea about python .
How do you remember that json ? and how should I remember that json ?
Awsome video!!! Thnqqqq vey much!!!
You got me craving for prawns now..damn it! 1:54
Hi After terminate ec2 instance …How to start it again?
not understanding for json scripting
very nice and easy to understandable for beginners……awesome
Great tutorial, Love and Respect from Pakistan, Thanks
How to join complete course
Very nice video.please if possible make videos on some program of python for beginners.thanks:)
Would you upload the whole session of python scripting for begginers