Posted on

Boolean operators in Python

Enroll in The Complete Python 3 Course: Beginner to Advanced!

Click here to subscribe for more videos like this!

Welcome back people, in this video we’re going to be talking about Boolean operators. So, what is a Boolean? Well, basically is not just a Python specific concept it’s a programming concept in general and it consists of two items, one is true, one is false. Now in a lot of programming languages you typed true as “true” and false as, well you know how to spell those, but you’d spell them all lowercase, Python’s different. So let’s explore that a bit and open up terminal here, and launch a Python3 console, and we’re going to just type in true and it’s going to return true, this is not in quotations, make sure when you’re typing true and false for truth checking that you’re typing true and false and not like this, because that will return a string which is true, yeah. So let’s talk about what these operators do. Basically, and we’re going to get into comparison operators a bit later which is like checking if something is equal to something, or more or less than, or if it even exists, or if it’s a certain type, and so you can basically perform different actions on different types of data and that’s why it’s necessary to do some fact checking with that. So, we need the true and false in programming, however we can explicitly declare true-and-false like we’ve just done by just typing true or false, or we can generate it in other ways. So let’s have a look at some of the ways we can generate a true or false. So let’s type “5 = 5” that’s true. Now when you’re comparing two objects and you’re checking if they’re equal to each other you can’t type that because the single quote, the single equal sign there, is used for a different purpose and programming it’s used to assign a value to a variable, and we’ll go over that here soon as well. So when we’re comparing to check if two numbers or two strings are equal to each other we need to put two equal signs, so you’ll see that returns true. So let’s go ahead and “5 == 4” that’s going to return false because of course we’ve all been through grade 2 math and we all know that 5 is a little larger than 4. Now you can also do this with strings and also without using equal signs at all, you can actually type “5 is 5” and that will return true, and you can type “5 is not 5” and that will equal false. So basically you’re saying 5 is not 5 and Python is saying well that’s false. So you could type “5 is not 6” and that will return true. Again you can do this with strings as well so you can type “This” is “This” and this is going to compare both of these strings to see if they’re equal to each other and it’s going to return true because yes, it is. Now we can also do this “True is True” will return true because of course true is true. Now that last one is a bit of a you know obvious result, so let’s go ahead and compare this with this “True” is True. If you think this will return true because we’re comparing true and true the results will not be as obvious as you expect because one of them is a string and the other one is a Boolean operator. So, not only when you compare two items is it checking if the value is equal, it’s also checking the type of data that it is. So, if we wanted to make the above statement return true we would have to convert true into a string. So just like you would convert a number into a string, you can just wrap the Boolean operator in the str function and it will convert it to a string prior to the comparison, and then it will return the result of true is true which equals true. Now, true-and-false again they’re going to come up in in the if-else statements because that’s where we’re really going to do some error checking and you know make sure things are set and that you know they’re not just not equal to each other, and you’re going to see more practical uses of Boolean operators later on, but this was just to show you guys what true and false is and again you should already know this without a programming background. So in the next video we’re going to be looking at Pythons version of arrays which are called lists.

Posted on

String manipulation in Python

Enroll in The Complete Python 3 Course: Beginner to Advanced!

Click here to subscribe for more videos like this!

Alright, so what are some of the fun things and useful things that we can do with strings in Python? Well there’s a few concepts that I want to talk about here, so what we’re going to do is go ahead and open up a Python interpreter, you can do this in pycharm by going to view tool windows, and then selecting python console, or you can open up terminal and type Python3 and hit enter. However you enter this if you want to follow along that’s probably helpful because I find if you’re told how to do something you know you kind of know how to do it, but if you actually do it yourself you have a better handle on what happens, and you’re more likely to remember how it works. So from here on out basically what I want you guys to do is to follow along with your code and do everything that I do. So, with that being said one of the first things that we’re going to do is in a previous video when we were talking about numbers I showed you how to convert strings into numbers if the only thing in that string were numbers. So, this is going to be kind of the opposite. Let’s say you have a few values, let’s say you have the number 6, right, and you want to print out this costs six dollars. You can’t, just well actually first we’re going to talk about concatenating, because you can’t do that in Python. I’m going to show you how, but first let’s learn how to concatenate a string which means had a glue multiple strings together. So we saw this actually in the numbers video as well when we tried to add numbers that had been identified as the string or yeah the string type and what it did was concatenate the numbers and made 5 and 6, when you add them together, it made it equal 56, and so your gluing strings together. So I want to say “Hello, ” then pop out of that string put a “+” and then in this string I’m going to type “Nick” Now what’s going to happen is it’s going to print out “Hello Nick” because I’m concatenating these two strings. You can also do this with however many instances of strings you want, so if I really wanted to get a little bit convoluted I could do this and this would print out hello using five strings all concatenated together. Now what happens if I want to say this costs six bucks? “This costs” + 6 + “bucks” Well, because part of this line is an integer it’s going to try and use those plus symbols to perform a mathematical operation rather than printing out a string, actually it’s the opposite it can’t convert the integer to a string so it knows that we want to concatenate some strings together but it’s like well hey hold up this is not a string I don’t know what to do with this. So what we have to do is use the string function which is similar to the int function. So how we do that is “this costs + str(six) + “dollars” and what this is gonna do is it’s going to convert the number 6 to a string so it can be used. Now you can also perform mathematical operations within the string parameter, I believe so. Let’s test this out. “This costs” + let’s go str(6 + 5) + “dollars” and hit enter. Yeah, so it can perform mathematical operations within that parameter. It’s going to convert the sum or the result of whatever mathematical operation you are performing on it, it’s going to convert that to a string and then use that string to be concatenated with the other strings that you’re working with. So that’s how to use the string function and maybe this doesn’t seem like it’s going to be important, or maybe it does but you’re like well how often do you use this, you know. We’re going to see because when we get into defining some functions we’re going to be using both strings and integers to return certain information and so this is going to be important at that point. So, that’s how to convert integers to strings, it will also work for any other type. So if you have true, we’re going to get into that after actually, but we’re going to be using this string function again at a later point. Now what happens when you want to do the opposite of concatenating strings? So, think of concatenation, I’m not sure if that’s the appropriate term, think about contaminating two strings as actually let’s look that up. Now it’s gonna open up xcode just go in to Google here, because if I’m saying that wrong I want to know. Yeah, okay, concatenate, good stuff. Not sure if you guys heard that but I’m using that word correctly, good stuff. Alright, so anyway back to the code that’s how you concatenate two strings together. What happens when you want to do the opposite, you want to split strings apart? So, let’s say we have this string like this so we’re going to say “Hello:Nick” we’re going to separate that word from the other word with a colon so that we actually have a character that we can use to split. So what we’re going to do is after the string we’re going to put a “.split(“:”)” going to call a function split on it, and the split function or method takes one parameter, well for the sake of this video takes one parameter, and that’s where you want the string to be split. So we’re going to split it at the colon there and hit enter. What it’s going to do is it’s going to create an array with all elements that had been split from that point, so for instance it split it into two items in the array but let’s say I did this it’s going to have an array with three values in it, and then we can reference those values by its index number, so this is going to be a bit more complicated. Let’s say we’re splitting it at this so let’s concatenate that lets say “My name is” + so we want this to print out my name, and not hello world, and not anything else, so what we’re going to do is put 2 square brackets and the number one “[1]” and it’s going to say “My name is Nick” I’m not sure if that’s a bit too complicated, so I’m going to try and explain it again from the beginning. So, we have a string, we have it say my name is and then a space, and then we can concatenate it with the result of this right here. So this can be broken down into a few parts, here’s the string that we’re performing the split function on okay, then we’re calling split on it and this is going to turn this string into an array with three values each with an index. It’s gonna split it into hello, Nick, and world and stuff those values into its own array, and then we can access the result of this by using an index number here in square brackets so we’re calling the index number one, so hello would be 0, Nick would be 1, and world would be 2. So, what’s happening is it’s printing out my name is Nick. Now you might be thinking shouldn’t it be printing out my name is hello if we’re using the number one here? This isn’t so much Python but it’s a concept in programming in general, no. So, 0 equals 1. If you have an array the first item in it you think would equal 1 but it actually it equals 0 and we’ll talk more about arrays, which are actually called lists in Python, we will talk more about those coming up in you know I think not the next video but the video after the next one. So that’s how you can manipulate strings in a very basic way, we might expand on this in the future, we actually probably will. So, next we’re going to be talking about Booleans.

Posted on

How to use strings in Python

Enroll in The Complete Python 3 Course: Beginner to Advanced!

Click here to subscribe for more videos like this!

Alright, so what is a string? Well, a string is any text that you want to be treated as text within a program. So again we need to talk about a few other things that we’re going to be talking about actually a few videos from now, but for right now just trying to follow along. So, this is a string because it’s wrapped in quotations, and if we hit enter Python is going to say hello string. Now, you can also use single quotations here to do the same thing. So basically you have two options either using double quotations or single quotations, and let’s say you want to have a word in your string that you well let’s say you need to have a word in that string of text which contains an apostrophe. So let’s say we wrapped in single quotes and we say ‘don’t do that’ Python is going to freak out about that because what it thinks is happening is that we’re starting a string here, we’re typing three letters, and then we’re ending the string, and then it doesn’t know what to do about all this. It’s saying well t do that I don’t know what that means, it’s no variable, and there’s no function that I can perform on this, so I’m just going to freak out and give you a syntax error. So what you would need to do in order to print out don’t do that is you can just wrap it in double quotations and then just type don’t do that, and as you can see what I print it’s going to keep that intact. Now alternatively let’s say you want to quote somebody. So, let’s wrap in double quotes and say, “she said “I want this” and then close it, close it. Again, it’s gonna freak out because what it thinks that we’re trying to do is start a string, say she said, then end the string and then it’s going to freak out over all this because it doesn’t realize that this is part of that string because we have explicitly told it to end the string here. So what you would do in this instance is just wrap the entire string in single quotations. So, ‘she said “I want this”‘ and as you can see it’s going to print it out correctly. Now alternatively what if she said something that had an apostrophe in it. So, let’s try and cope with that so ‘she said “don’t put that there”‘ again it’s going to freak out because we’re starting the string here, we’re adding a single quotation which is not interpreting as the other string, in fact right here where this apostrophe is it thinks that’s the end of the string, so it’s treating this like a string and then this as constants, or variables, or whatever and it doesn’t know what to do with them because we’re not telling it to do anything and then these just random quotations here. So what we need to do in this instance is we need to learn about escaping certain characters. So, let’s write it out first then I’ll explain it. So what we’re going to do is wrap it in single quotes and we’re going to say ‘she said “don/ ‘t do that”‘ and what’s happening here, let’s hit enter. That’s not what…let me that out. It’s just returning what we wrote there. There. So we print that out and what this does is the backslash here tells the next character to be interpreted as text regardless of what it would normally be interpreted as, so rather than this trying to end the string Python knows at this point that we want this to be printed out with the string and not end the string but just printed out as a single character, and so that’s what it’s going to do. So there’s times when you’re going to need to do each of these in your Python code and so that’s how to handle strings and what they are. Again, a string is just a series of characters which is interpreted as text and you can print it, you can manipulate it, we’re actually going to get into string manipulation in the next video.

Posted on

Learn Python Episode #6: Numbers

Enroll in The Complete Python 3 Course: Beginner to Advanced!

Click here to subscribe for more videos like this!

Alright, so before we actually get into functional programming, or object oriented programming for that matter, with Python we need to discuss some basic types, and then variables, and some other stuff. So in this video we’re going to be covering numbers. So, what is a number? Well, I’m sure you guys know what a number is and I’m sure we’ve all been through grade primary and one so we’re all familiar with that. Now there’s two different types of numbers, one is called an integer, and then a floating point. The floating point is basically any number that has a decimal included in it. So let’s go ahead and write out some numbers on the screen. Now I’m going to be using the Python console down here for this video so watch down there, that’s where stuff is going to happen. So, for an instance of a number we can just write a number, it’s going to appear in the console, or the ID, or whatever you know has syntax highlighting that you’re using it’s going to show as blue or it should you know, actually that really depends on your color scheme that you’ve got going on, it’s going to show a specific color. Now, we can just use numbers in Python just by writing the numbers and if we hit enter it’s going to print out 5. Now with numbers we can perform mathematical operations on these numbers as you saw in some of the previous videos that we’ve done so far. So I could write 5 + 6 and we’re going to get a response of the sum of 5 + 6. Now what would happen if I wrapped these numbers in quotations? So let’s go ahead and write “5 + 6” if you think that this will produce 11, you’re wrong, It’s going to produce 56, and you might be thinking, hold up, 5 + 6 does not equal 56. You’re absolutely right. Not in math, however when you’re concatenated strings it does. So basically when you wrap something in quotations in Python, Python is going to treat it as a string, not a number. So if you’re trying to perform mathematical operations just remember don’t wrap your numbers in quotations. Now additionally we can use floating points to perform math operations, and you can see it returns a floating-point. Now if we ran 5.5 + 5.5 it’s going to still return a floating point, however you know it’s 11.0 because we’ve passed it, you know, decimal floating-point numbers and so it’s going to return with one because that’s just how it works. Now, we’re going to talk about how to convert different types of types, I guess. These are called types. A number is a type, a string is a type, and right here we’ve got, we’ve shown, both numbers and strings and we’re going to cover strings in the next video, but for right now let’s say well I have some numbers but they’re wrapped in quotations and I still want to perform mathematical operations on them, how can I do that? So, basically in Python there’s a built-in function called int which will convert a string to a number if that string contains only numbers. So let’s look at a correct usage of int and then an incorrect usage and see the output for both. So let’s say I have the number “5” wrapped in quotations, what I’m going to do is wrap that in the int function and this is also how you write a call to a function in Python, and then I’m going to perform a mathematical operation on it with another number wrapped in quotations. Now this is not going to produce 57, in fact it’s going to convert both of those into integers and then perform the math operations on them. So that’s how to add up different numbers that are contained within quotations, let’s have a look at trying to convert text to an integer. So let’s write “int” and let’s write “(hello)” and hit enter. As you can guess it’s printing out an error because there’s an invalid literal for int with base 10. Basically, what that means is we’ve passed it something that is not an integer. So think of this function basically as it takes whatever you put into the function, it removes the quotations, and then returns that. Same if I just type this, Python is going to freak out because it doesn’t know what hello is because this is going to be interpreted not as a string, but it’s going to be interpreted as computer code, and we’re going to get more into strings in the next video.

Posted on

Learn Python Episode #5: PyCharm IDE Setup

Enroll in The Complete Python 3 Course: Beginner to Advanced!

Click here to subscribe for more videos like this!

Alright, so what kind of work environment do we need to be efficient at programming with Python? The question can be posed for any programming language really, and so the answer is usually going to be same. I mean feel free if you want to, to openup notepad on Windows or you know some basic text editor and write a script and go over to the terminal and command prompt and run it, however that’s not efficient for a variety of reasons. So, what we’re going to be using is an IDE, which stands for integrated development environment, and we’re going to be using Jetbrains PyCharm. Now, PyCharm is free for, I spelled that wrong just go to Google, search PyCharm, and click on the link there which is from jetbrains.com, and you can download it. Now when you get to the download screen you’re going to get a professional or community version, choose the community version that is free, it’s completely fully featured as far as i can tell, and that’s the one that we’re going to be using in this video. Now alternatively I mean you can go have a look at other IDEs for Python, but I find that this one it just works really well, it’s simple, and it does everything that we need it to do, and it also has some advanced features which we may look at some point in the future. So, go ahead download the installer for your platform, it does require Java as well, so you can just open up Google and type download Java, and it’s going to take a java.com/download if you click that link, just click download the appropriate version for your system, and once you have that installed then you can install PyCharm. So, let’s take a walk around PyCharm right quick. So, this is going to be the first screen that you see every time you start up PyCharm. The first launch screen is a bit different you can choose a theme and whatnot, all that is relevant really. We’re going to create a new project, it’s going to be pure Python, now there’s also other options here if you want to start a Django project, etc., but we’re just going to start a Python project here and we’re going to choose version 3.5.1 which is also going to tell the IDE here where to find the binary files to run Python. Now, we’re also going to name the project here, so first program, and this is going to be the name of our project. It’s going to create a folder called first program and this is how we’re going to identify it within here. So, along the left-hand side here this is the project view so let’s go ahead and right click and create a new file. Now, additionally you can create a new directory, a Python package, and a bunch of different file types here. We’re just going to choose a Python file and I’m going to name it main, which is going to name it main.py, and here we can start typing our script. So, again I’m just going to use the hello world example, and that’s all it’s going to be. I’m going to save it, keyboard shortcuts are going to take you a long way if you’re going to become a programmer, so I expect you know some already, if you don’t on Windows Linux control + S saves the file and on OS 10 its command + S so you don’t have to always go through the menus and stuff, but let’s have a look through the menus. If you want to create a new project, a new file, or directory you can open one etcetera, you can actually access the settings by going to default settings for this project, and a bunch of different options down here that we don’t really need. If you go to edit you’re going to see you can undo and it’s also going to show you the corresponding keyboard shortcuts for each one of these options, so this is command + Z and that’s going to undo whatever action I previously did, this is also going to be useful if you’re going to become a professional programmer. Same is true for copy, paste, find. We’re going to be discussing find at some point, I mean it’s a pretty powerful command you can find not only in the current file but your entire project if you want to look for instances of variable or string or something you can actually search through the entire root directory of this project if you want. If you go to view and go tool windows here is what we’re looking at here project if we select that it’s going to, it should hide that, yeah, so it hid the project sidebar, so we’re going to leave that open. Now, we can also show favorite structure, etcetera. If you have version control setup this will not be disabled and you can use that to perform first control actions. We’re going to open up a Python console here and here we can actually run Python code. If we wanted to say 5+5 you know and it’s going to return that so this is the interpreter itself, however if we want to actually open terminal we can open a terminal here and here we can just type python3 main.py and it’s going to run what we have up in this file right here. Now additionally we have a run right here. We can set up run, a run configuration here, to actually every time we hit the run it’s going to automatically run our project so let’s go ahead and hit the plus sign, choose python, and it’s gonna be called a Python run, script is going to be python3 or the script is going to be the actual python script that we want run so it’s going to be main.py, script parameters this is if we’re passing in any arguments or anything we’re not going to it’s already found the Python interpreter because when we set up the project we chose the correct Python version. This is going to be interpreter options we’re not going to be using any, and that’s all that we need to do. So, let’s go ahead and click apply and then run, and it’s going to run the script, output that, and then it says it finished with exit code zero which is completely normal. So, every time you want to run if you have this little section opened here just hit that play button, the Run button there, it’s going to run the code in real time. So, make changes, hit ctrl + S, and then run the code right there, this is the most efficient way to run a program in an IDE, you know, you don’t have to switch back and forth between windows and stuff. So, this is the primary reason that we’re going to be using this IDE for the sake of this course. Again, feel free to have a look at some others but I recommend if you’re a complete novice to any of this just follow along exactly with what I’m doing and you shouldn’t have a problem. However, if you do there’s a discussion section to the right of this video, use it, let me know if you have any trouble, and I’ll try to clear it up. So, with all that said we are finally ready to actually get in to the language itself.

Posted on

Learn Python Episode #4: Running Scripts in Terminal

Enroll in The Complete Python 3 Course: Beginner to Advanced!

Click here to subscribe for more videos like this!

So, let’s go ahead and create a Python script and learn how to run it. So, I’m going to be doing this in terminal completely we will discuss other options later, what I need to do first is change directory into “pycharm projects” and there’s nothing really in here so I’m going to create a file using the nano text editor, you guys don’t have to follow along, however if you want to that’s great too. I’m just going to call it test.py. Now all Python scripts need to have the .py extension. So, what we’re going to do is just a simple, simple script it’s going to print “hello world” So, I’m going to control + O to save, and control + C to exit, control + X to exit. Alright, now if we just type “test.py” you’ll see BASH doesn’t know what to do with this command because test.py is not an installed program. So what we need to do is run “python3 test.py” and it will return the result of anything in that script. So, that’s how to run python scripts, in the next video what we’re going to be doing is setting up an actual work environment using an IDE, and get you guys all ready to start with the basics.

Posted on

Learn Python Episode #3: Interpreted vs Compiled Programming Language

Enroll in The Complete Python 3 Course: Beginner to Advanced!

Click here to subscribe for more videos like this!

So, the interpreter, and this is going to be a short video I think, but we’re basically going to talk about the difference between an interpreted programming language and compiled programming language, and this might be a little adept for the novice programmer but just stick with us again if you have any questions or not sure if you completely understand it, there’s a discussion section to the right of this video, yes should be right to the right of this video, so use that and I will try and clear up any confusion. So, first, with a compiled programming language you write your code and you save it into this file, and you can’t run that file yet. Let’s say you’re writing C++ code, so you write a function, you write a script that will do something. If you try and open that file with the .cpp extension, which is for C++ files, it is just going to open that in a text editor or code editor because that’s not an executable file. What you need to do with a compiled programming language is once you save your file you need to compile it into a language that the computer can read, so binary ones and zeros, and by compiling this file into an executable file, then you can double click it and it will run. So, if you’re on Windows building executable files for windows they will have a .exe extension. If you’re on Linux I don’t believe they have an extension. So, the difference here is with Python when you write a script you can instantaneously run that script without having to compile it into binary and because we can do that what’s actually happening is when you run the Python command you’re not running the file standalone. So, when you compile a programming file into a binary file you can just type the name of that file in the terminal or command prompt and hit enter and it will run that program as a standalone program because the computer already knows how to run it, but when you run Python scripts you’re going to run it with the Python command and then the name of the file, and what basically happens is you’re running the program Python which is interpreting your code and running that. So, what happens is it does compile into binary but it does what’s called just-in-time compilation, and what that does is every time you run its going to parse all the code and it’s going to convert it into a temporary file and then run that temporary file. So, let me break out of this, there. So, how you would run a script and we’re going to talk about that later but basically how to enter the interpreter on its own you just type python3 to use the three version of Python you can see the version we are using Python 3.5.1. So, basically in the interpreter you can run real time code, so if I were to type “print hello world” it’s going to instantaneously run that line of code. If I run “4 + 6” it’s going to return 10 because that’s the sum of four and six, and so the interpreter is great to use if you want to test something really quick, if you want to debug a few lines of code, or if you just want to see if something would actually work. So, we’re going to be starting out using the interpreter but as things get a little more complex we’re going to get into writing scripts and executing those scripts. So, now we need to learn how to run a Python script.

Posted on

Learn Python Episode #2: Windows 10 Installation

Enroll in The Complete Python 3 Course: Beginner to Advanced!

Click here to subscribe for more videos like this!

Hello everyone. Last video Nick touched briefly on installing Python on a Windows system, and I assume many of you are using Windows as well, so i’m gonna go ahead and walk you through the installation real quick. So you want to go to python.org and we’re going to click the Downloads button, and then what we’re going to do is we’re going to download the latest version of Python 3 for Windows, and your browser should automatically download the installation. So let’s go ahead and click on that, and actually this is not what we want because I know for a fact I have a 64 bit system. I don’t know why it automatically downloaded the 32-bit version of Python. I’m going to cancel this, and if you’re curious whether or not you have a 32 or 64 bit operating system you can right click on the Windows icon, go to system, and it will tell you which operating system you have. So we have a x64 based processor and we need a 64-bit version of Python. So go ahead and click on the Windows link here instead of clicking the download button. Alright, so that’s beta, go ahead and click on 3.5 release again and what we’re going to do is scroll down a bit. Let’s do the Windows x86-x64 web-based installer and this should include both versions of Python. Try that one more time, there we go 64-bit. So you want to go ahead and click this box down here that says Add python 3.5 to PATH, this is so we can issue commands through the prompt, so we want to make sure this is clicked. We’re going to go ahead and hit Install Now, click yes, and then this should install everything you need to follow along with the course. So, thank you for taking the time to watch this video. I just wanted to do a quick video showing you guys exactly how to install it on Windows just so you don’t have any problems getting set up for the course.

Posted on

Learn Python Episode #1: Mac/Linux Installation

Enroll in The Complete Python 3 Course: Beginner to Advanced!

Click here to subscribe for more videos like this!

So, the first thing that we need to do to get into programming in Python is installing it. So, let’s go ahead and discuss about the three different ways that you’re going to be installing it. First, we’re going to cover Mac because that’s what i’m using and so it’s easiest to show you how to do it. So, what you’re going to do is open up terminal which I’ve moved into that folder and put right here. Now, if you haven’t installed Homebrew, what you’re going to do is run a Ruby command that’s going to download and set it up. So, basically what Homebrew is, is a package manager that you can use to install a lot of packages. So, if you’re used to Linux basically on Linux if you want to install a package you don’t need to go all around the internet and search for packages on websites and then download from shady sources and get viruses, that’s just a bad construct of computer operating systems, but unfortunately that’s how Windows works and so i’m going to show you guys the right way to install in Windows as well. Using Linux or OS 10 you’re going to be installing through terminal. So, first setup Homebrew, this is how you do it, come to brew.sh and it’s going to give you this line of code here. You just paste this in terminal, run it, it’s going to install brew. Once you’ve got brew installed what you’re going to do is run “brew install python” Now that’s how easy it is. OS 10 does ship with a version of Python but the the version included in OS 10 is 2.7 series and I think it’s actually an old really something that’s like to 2.7.5 or something like that so it’s pretty old. At least I think it was that. We can actually run “–python version” here, so okay so the version that OS 10 El Capitan ships with is 2.7.10. When you run brew install Python it’s going to install python 3, that’s the command that we’re going to have to be using because there’s already a Python version installed, so we’re going to be using Python 3 and you can check the version we’ve got 3.5.1 that’s the version that homebrew is going to install for you. Now similarly if you’re on Linux what you would do there’s a few different ways because there’s a few different package managers. So if you’re on Arch Linux I don’t think you’re gonna need help setting it up, and actually a lot of Linux distributions have Python/Python 3 pre-installed, so you can just run “python –version” and “python3 –version” and see what version you have installed, you might need to upgrade, it it might be fine. If you have 3.4 you can follow along with this course I don’t think there’s that many differences between the two versions and there’s definitely not code-breaking differences, so that shouldn’t be a problem. However, if you do notice that you’re having a problem you could upgrade the version of Python either through the repository or otherwise. If you’re on Ubuntu you’re gonna be using the apt-get command, so you’d run “sudo apt-get install python3” That’s going to install Python 3 for you. If you’re on Fedora I believe it used to be yum, I think it’s dnf now. Yeah, so let’s just review exactly what commands you’re going to be using, I think it’s like dnf install. So, you can still use yum I guess, ok so you can use yum to install. So, what you’re gonna do is we’re gonna run “sudo yum install” and then I believe the package is just called python3, Python 4 is going to be pretty amazing but right now we’re using Python 3. So, there we go. Now if you’re on Arch and I said I don’t think you need any help getting it setup but just for you know if you are new to Arch you’d run “sudo pacman -S python3” but again python3 should be pre-installed, so you shouldn’t even need to do any of this but if you do that’s gonna do it. Now on Windows you do need to go download a file from the internet and run it, the the difference between what I said before what I’m saying now is this is not a shady location. So, what you’re going to do is go to python.org, go to the download sections, and if you just hover over this it’s actually going to show you a drop-down and you can choose what platform you’re on. So you would choose windows and they actually have a 3.6 which we’re not going to we’re not going to be using because this is in alpha. So, click latest python3 release python 3.5.1, it’s going to take you to this page and basically give you a changelog and whatnot. If you go down here make sure you get the version that’s compatible with your system. If you have a computer that is not obsolete it should be running a 64-bit operating system which means it has a 64-bit processor. So you would download this one right here, Windows x86 64 executable and what that’s going to download is an .exe file which you can use to install the program. If you’re running a 32-bit system you’re going to download this one just the x86, and yeah just install it. Now, there is one note on the installation, when you run the installation there’s going to be a certain step where you have some checkboxes and one of them is going to say add python to the path variable, make sure that’s checked because if it’s not checked if you try to run Python in the command line you won’t be able to because it won’t know where to find this mysterious Python command. So, by checking that box basically it tells windows where the Python binary file is located, so you want to make sure Windows is aware of where that file is. And that’s all there is to installing it. To confirm that you’ve got it installed open up a command prompt to terminal and just type Python3 and it should drop you down into the interpreter, which we’re going to be discussing in the next video.

Posted on 2 Comments

Complete Python 3 Programming Tutorial

Enroll in The Complete Python Course: Beginner to Advanced on Udemy
http://bit.ly/2yMsS7v/

Check out the Learn to Code Course Bundle!
https://josephdelgadillo.com/product/learn-to-code-course-bundle/

Hello everyone and welcome to the Python tutorial that we’re going to be doing. My name is Nick and I’m going to be the instructor for this course, and it’s going to be my job to get you completely immersed in the Python programming language. Now, this course is going to be aimed at somebody who may have basic knowledge about what a programming language is but this would be your first programming language, and this is a great programming language to start with. It does have some limitations and sometimes this is not the right tool for the job, but a lot of times this offers people who have no experience programming a really great way of understanding what a programming language is and how to use one. So, the main differences between Python and other languages like C++, or C, or Java is that Python is built around two main focal points which I believe are code readability and simplicity. So, we’re gonna jump into the language here and in a few videos but we need to do a few things first. First we need to discuss what Python is, and then we need to get it installed, and then we can start discussing you know what’s an interpreter, how do you run a Python script, and then get into the language itself. Now, the language is different but it’s easy, and once we get past an understanding of how the programming language works, and the syntax, and all the different stuff you do with it, we’re going to move on to actually programming real applications and showing you guys different practical applications of the Python programming language. So, for instance, we’re going to be building a website, we’re going to be building a web scraper, and a graphical utility we’re actually going to be building multiple graphical tools because there are a few different graphical or GUI, GUI, whatever you want to call it there’s a few different frameworks for Python that we could use. So we’re going to explore three of them. So, right off the bat here’s a fun fact if you didn’t know python is actually named after Monty Python who’s made some great films, so if you if you haven’t seen Search for the Holy Grail or the Life of Brian go do it, they’re great movies, which is completely beside the point. So, Python is actually a pretty old programming language. It was first introduced in 1991 which makes it 25 years old. There’s two current versions, now this may be confusing as well, so there’s a Python 2 series and there’s a Python 3 series. The Python 2 is currently at 2.7.11 and the 3 series is at 3.5.1. Now we’re going to be using Python 3 in this course however Python 2 shouldn’t be much different if afterward you want to explore using Python 2 that’s completely acceptable. Now as I said Python is based around simplicity and readability and this means that when you look at Python code it’s all indentation based. So, if you looked at another code like Java you would see a lot of curly braces, and brackets, and a lot of things that are just there to confuse the novice programmer. Python is based on indentation so you don’t need to wrap blocks of code in curly braces and you guys will see what I mean coming up in the next few videos. So, that’s all we’re going to talk about today. I hope you guys enjoy this course and find it useful. There’s a comment section to the right for each video if you guys ever feel that you’re not too sure on something that I explained, or maybe you had some input in addition to what I explained, feel free to use that. So, yeah, let’s get started!