Posted on 23 Comments

(FREE) The Complete Red Hat Linux Course: Beginner to RHCSA!

For a limited time, enroll for FREE in one of our top rated Linux system administration courses!

https://www.jtdcourses.com/courses/red-hat-linux?coupon=ytfree

Get The Complete Linux Administration Course Bundle!
https://josephdelgadillo.com/product/linux-course-bundle/

Enroll now in our bestselling Linux courses!

A Beginner’s Guide to Linux System Administration!
https://www.jtdcourses.com/courses/linux

CentOS and Red Hat Linux to Certified System Administrator!
https://www.jtdcourses.com/courses/red-hat-linux

BASH Programming Course: Master the Linux Command Line!
https://www.jtdcourses.com/courses/bash-linux

The Complete Wireshark Course: Go From Beginner to Advanced!
https://www.jtdcourses.com/courses/wireshark

If you want to become a Red Hat Certified System Administrator, you will LOVE this course! Whether you have no experience with Red Hat Linux or any other type of Linux operating system, you can count on this course to get you started with the basics and show you what to do all the way into the advanced material. You get to see immediately why Linux is worth learning and using. Learn the basics of CentOS and Red Hat Linux! Prepare and pass the RedHat certified system administrator (RHCSA) exam!

https://josephdelgadillo.com/product/linux-course-bundle/

List of topics

  • Introduction
  • Why is Linux worth learning?
  • VirtualBox installation/setup
  • RedHat virtual machine setup
  • RedHat dual boot setup
  • Linux GUI essentials
  • File system navigation ls, cd, pwd
  • Finding files commands find, locate, upadtedb, man
  • File & folder ownership commands chown, chmod
  • Move, delete, and copy file commands mv, rm, cp
  • Commands grep, pipe, echo, cat
  • YUM package manager
  • RPM package manager
  • Redhat Certified System Administration Exam
  • Globbing (wildcards)
  • IORedirection
  • Linux file system
  • Links
  • Backups and compression
  • Automating tasks with cron
  • User properties and where they are stored in the system
  • Creating a user
  • Creating groups and assigning users to them
  • Intro to network interfaces
  • Network manager and configuration + troubleshooting tools
  • Installing and configuring SSH server pt.1
  • SSH passwordless and SCP (secure copying of files between hosts)
  • Partitioning and file systems
  • Partitioning a new disk
  • Formatting a partition using xfs file system
  • Mounting the partitions
  • Linux volume management (LVM)
  • LUKS
Posted on

(FREE) Create Your First Udemy Course!

If you want practical tips for publishing your first course on Udemy, you are going to love this FREE course! Watch as I go step-by-step through the course creation process and show you the quickest and most efficient way to get your first course published.

http://bit.ly/2mqxviS

Learn from an instructor with over 2 years of experience teaching on Udemy, working with top instructors to create bestselling courses, and marketing online courses across multiple platforms!

This course requires absolutely no experience working with Udemy, teaching online, or recording in front of a camera. Anyone can start teaching on Udemy today, and that’s what makes it such a fantastic learning platform!

Thank you for taking the time to read this, and I hope to see you in the course!\

http://bit.ly/2mqxviS

 

Posted on 5 Comments

(FREE) Python Programming Course on Udemy!

If you want to learn how to program, you will LOVE this Udemy course! This course was designed for complete beginners with little to no understanding of programming, and will give you the knowledge to get started coding using Python 3.

Enroll for FREE on Udemy

http://bit.ly/2lDvi2O

We will cover the following topics in this course:

  • Python installation
  • Running Python scripts in terminal
  • PyCharm IDE setup
  • Numbers, strings, Boolean operators, lists, dictionaries, and variables
  • Functions, arguments, return values, loops, and modules
  • Final project using the information covered in the course

We hope you enjoy the course and it our goal to give you the knowledge to begin writing your own programs in Python!

http://bit.ly/2lDvi2O

Posted on

MATLAB Programming Tutorial

Limited FREE coupons 🙂
http://bit.ly/2kmmttg

$10 Coupons on Udemy
http://bit.ly/2jPlZuG

I hope you enjoy this FREE MATLAB programming tutorial. This video is a compilation of lectures from MATLAB from A to Z: From Programming to App designing on Udemy.

Topics covered

  • MATLAB user interface
  • Basic commands
  • Using help topics in MATLAB
  • Introduction to programming in MATLAB
  • M-file scripts
  • M-file functions
  • Input and output commands
  • Accessing the guide
  • Available controls with their types and generated files
  • Properties of controls (initial values and tags)
  • Positioning and aligning controls
  • Created functions in the .m file
  • Two key functions
  • Layout of app designer – design & code view
  • Available controls and their types
  • Alignment and arranging options
  • Spacing and resizing
  • Grid lines
Posted on 47 Comments

(FREE) The Complete Ethical Hacking Course: Beginner to Advanced!

For a limited time, enroll for FREE in one of our top rated ethical hacking courses!

https://www.jtdcourses.com/courses/ethical-hacking-beginner-advanced?coupon=ytfree

Get the complete hacking bundle for only $19!
https://josephdelgadillo.com/product/hacking-bundle-2017/

Enroll in our best-selling ethical hacking courses!

Learn Ethical Hacking: Beginner to Advanced
https://www.jtdcourses.com/courses/ethical-hacking

Certified Ethical Hacker Boot Camp
https://www.jtdcourses.com/courses/certified-ethical-hacker

The Complete Python Hacking Course: Beginner to Advanced
https://www.jtdcourses.com/courses/python-hacking

Build an Advanced Keylogger for Ethical Hacking
https://www.jtdcourses.com/courses/keylogger

If you want to get started hacking you will LOVE The Complete Ethical Hacking Course: Beginner to Advanced! This complete course will take you from beginner to expert hacker. We will begin with the very basics showing you how to setup your environment, and move on to password cracking, WiFi hacking, Dos attacks, SQL injections, and much more! Enroll for free!

https://www.jtdcourses.com/courses/ethical-hacking-beginner-advanced?coupon=ytfree

Enroll in The Complete Hacking Course Bundle for 2017!
https://josephdelgadillo.com/product/hacking-bundle-2017/

  • Complete list of topics covered, time stamps available on YouTube!
  • Introduction to ethical hacking
  • Prerequisites for this course
  • Basic terminology: white hat, gray hat, black hat
  • Basic terminology: SQL injections, VPN, proxy, VPS, and keyloggers
  • VirtualBox installation
  • VirtualBox installation through the repositories
  • Creating a virtual environment
  • Installing VirtualBox on Windows
  • Kali Linux installation/setup
  • VirtualBox Guest Additions installation
  • Linux terminal basics
  • Linux command line interface basics
  • Tor browser setup
  • Proxychains
  • Virtual private network
  • Changing your mac address with macchanger
  • Footprinting with network mapper (nmap) and external resources
  • Attacking wireless networks cracking WPA/WPA2
  • Aircrack-ng & reaver installation
  • Installing aircrack-ng on Windows & Crunch on Linux
  • Aricrack-ng & crunch hacking example
  • Cracking WPS pins with reaver pt.1
  • Cracking WPS pins with reaver pt.2
  • Cracking WPS pins with reaver pt.3
  • Performing denial of service attacks on wireless networks pt.1
  • Performing denial of service attacks on wireless networks pt.2
  • SSL strip pt.1
  • SSL strip pt.2
  • SSL strip pt.3
  • Funny things pt.1
  • Funny things pt.2
  • Funny things pt.3
  • Evil twin pt.1
  • Evil twin pt.2
  • Evil twin pt.3
  • Using known vulnerabilities pt.1
  • Using know vulnerabilities pt.2
  • Using known vulnerabilities pt.3
  • Post authentication exploitation (DNS) pt.1
  • Post authentication exploitation (DNS) pt.2
  • Post authentication exploitation (DNS) pt.3
  • SQL injection pt.1
  • SQL injection pt.2
  • SQL injection pt.3
  • SQL injection pt.4
  • SQL injection pt.5
  • Brute force methods for cracking passwords – cracking hashes
  • Cracking Linux passwords with john the ripper pt.1
  • Cracking Linux passwords with john the ripper pt.2
  • Cracking windows passwords with john the ripper
  • Hydra usage pt.1
  • Hydra usage pt.2
  • DoS attack pt.1 introduction to denial of service attacks
  • DoS attack pt.2 combine slowloris.pl with nmap
  • DoS attack pt.3 featuring hackers.org
  • Intro to metasploit and reverse shells
  • Metasploit starting from a two terminal setup
  • Making reverse shells persistent on another system and escalating privileges
  • Creating a persistent shell with metasploit
  • Using netcat to make any kind of connection you may need
  • How to upload a reverse shell onto a web server
Posted on 3 Comments

3 FREE Udemy Courses for Black Friday!

3 FREE technical courses for Black Friday! Coupons expire 11/25/16.

If you want to get started as an ethical hacker and build a keylogger using C++, you will LOVE this course!

Build a Keylogger for Ethical Hacking!

2016-11-20_0-00-33

https://www.udemy.com/how-to-create-an-advanced-keylogger-from-scratch-for-windows

Learn to program using C++ with this FREE Udemy course!

Get Started Coding with C++!

2016-11-20_0-01-15

https://www.udemy.com/learn-c-plus-plus-from-beginner-to-advanced

Learn to program web application using Angular 2!

Get started using Angular 2!

2016-11-20_0-01-51

https://www.udemy.com/learn-angular-2-from-beginner-to-advanced

 

Posted on

Python 3 Final Project

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

Click here to subscribe for more videos like this!

Alright guys, welcome back. We are at the end of the second section for this course which means you guys have a basic understanding of Python. You actually have enough right now to build some basic programs. Now, you might be thinking well, hold on, we didn’t even do that much. That might seem like it’s true but we’ve learned some core principles and concepts here as well as the language syntax, so far. So, we currently know how to create loops like while and if, or while and for loops, we know the if else statement, we know how to create strings and all the different types like Booleans, and numbers, and we also know how to set variables, among some other stuff. So, what we’re going to do right now is for the project for this section we’re going to put most of what we’ve learned in this section and we’re going to build a calculator program. So, I’m going to open up Chrome here and we’re just going to search Python calculator, just to see you know basically how we might write a calculator, so this looks good. So as you can see in the top of the script their defining for functions, one for addition, subtraction, etc, and each one of them is going to take a limit of two numbers and it’s going to return the result of the chosen mathematical equation between the two numbers. So that’s going to be the same for multiply, divide, everything and here’s where the actual program is going to start to output/input. So basically it’s going to say select an operation and it’s going to tell you what each number is equal to, and then it’s going to create a variable called “choice” and it’s going to use an input function which basically allows the user to type something in that hit enter and whatever the types can be stored choice. So this is going to be the prompt, so this is going to print out before the input so basically it’s gonna say enter choice 1, 2, 3, 4 and then whatever the user types after that it’s going to be stored in the variable choice, and then they’re creating two other variables, the first number and the second number, and for each is going to ask you to enter the number. So, first you enter the type of math you’re gonna be doing, and then you enter the first number, and then you enter the second number, and once you enter here what it’s going to do it’s got everything it needs, so it’s going to use an if else statement to determine what your choice was so that it knows what function to call with the two numbers that you’ve put in, which is awesome, and you guys might be really excited to build this. But, we’re actually going to go a few steps further, and the reason is if we open up a calculator you’re probably going to know that I wasn’t asked right off the bat what mathematical operation I want to perform, it just loads up with the number 0, and then I can type a number so let’s say 50, and the mathematical operator which we are going to use multiply, then two, we’re going to enter and we’re going to get a 100. Now with the ending of the math equation here you’ll notice two differences between this program and the Python script in the background there, and that’s that it didn’t quit, and actually we can continue to operate on the result of that first equation. If I want to add 75 I’m going to hit + 75 and hit enter and it’s going to add it to the result. If i want to multiply that by 2 I just hit x 2 and it’s going to multiply by that. So this is a continuous mathematical operation where the Python script allows you to perform one operation and is limited to two numbers, and it’s not very efficient, and I guess very simple. So, that’s good but we’re going to go a little more advanced. So, go ahead and open your IDE. What we’re going to do here is we are going to be using the regex library, so we’re going to import regex, and we’re going to print out the name of our program and it’s going to be called “print(“Our Magical Calculator”)” Now right off the bat we’re going to create two variables, so “previous = 0” and what this is gonna do is the previous variable is going to hold the result of the previously calculated equation, so we’re going to set it to 0 because we haven’t done any math yet, and then we’re going to create a variable called “run = True” You guys can probably guess what this is gonna do. Now, we need to create a loop for our program so we’re going to type “while run”: and we’re just going to call a function called “performMath” Let’s go up here and create a function called “def performMath” So the first thing we need to do is be able to accept input from the user to type in something, so let’s go ahead and type “equation = input(“Enter equation:”” and for now we’re just going to print out whatever they type so “print(“You typed”, equation)” hit save, now let’s run this. So I’m just going to print “Hello World” and it says you’ve typed Hello World, and then it drops back into the prompt. So going to type “Again typing something” and this is going to loop forever because we haven’t created a way to stop it other than, you know, closing the terminal window, or hitting stop right here. So, what we’re going to do now is create a way to end or quit out of this application. So let’s go ahead and “print(“Type ‘quit’ to exit\n”)” so let’s save that, Now what we need to be able to do is if they type “quit” we want to be able to you know actually quit out of the program. So what we need to do is we need access to the run variable in here, so for example let me just do this first. “if equation == ‘quit’:” let’s go ahead and set “run = false” “else:” print out whatever we typed. So go ahead and save and we’re going to run this. So we can type “Hello” and what it’s doing is this we didn’t type in quit so it’s not doing this instead it’s doing this. So let’s type in “quit” it’s not doing anything. So, basically what’s happening here is this is variable scope. Basically, to explain this this is a variable we created the top level of our program, so not defined in any functions or anything. We are in a function here and we’re in an if statement so we’re further into the code and we’ve stated run equals false. Now this is not going to have any effect on this very well it doesn’t have access to it. So, what we need to do first is actually get that global variable into this function. The way we do that is just at the top of the function type “global run” and then the name of the global variable you’re trying to get access to. Let’s go ahead and save and restart. So you’ll see we can still type in stuff but soon as I type “quit” it actually exits. So that’s what we wanted to do. Now, let’s go ahead and restart this. We’re expecting equations to look like this. So, how can we do that? Well, let’s actually how can we do that without creating a limiting set of functions that will perform operations, what if we want it to do this, you know, or what if we wanted to do this? In the script that we just looked at this wouldn’t be possible because we can only use two numbers and they’re each collected in their own variable, So what we’re going to do is we are going to use a built-in function. So actually what I’m going to do is grab access to the previous global variable as well, going to set previous here “previous = equation” then if we go ahead and rerun this, well we see it still says you’ve typed 80+2, or you’ve typed you know whatever the equation was. So we want this to perform math and what we’re going to do is we’re going to use a built-in function called “eval” So let’s go ahead and type that here “previous = eval(equation)” and then let’s save, let’s restart, and you’re going to see that before it prints out the result, or whatever we’ve put in, it’s going to evaluate it. So this is going to be able to perform complex mathematical operations from strings. So we can literally type in “80*100+42-10+78*142” hit enter and it’s going to calculate that up, and it does it in the correct order. So we all know that multiplication happens before addition and the evaluate statement our function actually is aware of that and it does that for us. You might be thinking, well that’s awesome, why don’t you know in those basic calculator examples why don’t they just use the eval function? The reason is because the eval function is actually supposed to be avoided because it can be dangerous. So, let me show you why. I’m going to print out here “print(“Hello World”)” you’ll see what happens is when it evaluates actually if we type in Python code here it’s going to execute that. So, let me go ahead and set “global run” see so we can actually crash it as well. Now this is going to work as long as we assume that our users are going to be performing math equations, but what if they are not? Well, because of this we are actually going to do this. So go ahead and “equation = eval(equation)” is going to be equal to the evaluation of equation. Actually, hold on “previous” Okay, so what we need to do first is perform regex on it, so we want them to only be entering mathematical symbols or numbers, we don’t want them to be able to type anything or to issue commands. So the way we do that is basically let’s create a new variable, actually let’s assign here we’re going to be entering our regex so “equation = re.sub( ‘ [a-zA-Z,.()” “] ‘ , ‘ ‘, equation)” “equation = re.sub( ‘ [a-zA-Z,.()” “] ‘ , ‘ ‘, equation)” So we’re going to remove everything except you know well everything important. Let’s actually go ahead and also remove the colons, we’re going to replace it with nothing, we’re going to do this equation, so we go ahead and show you what I mean. We’re going to rerun this and I’m going to say, “Hello 6 World” and what happens is going to strip everything out of that before it evaluates it, so it’s only going to accept numbers or as you can see you know the plus symbol, sorry, plus right there, let me remove that, alright. There you go. So “5+11×2” is 27 because 11 x 2 is 22 + 5 = 7. So, we’ve already got an awesome calculator but it doesn’t look quite right. So what we’re going to do is we’re basically just going to put an if statement, it’s only going to ask for you to enter equation if there’s no previous. So what we’re going to do is actually “equation = ” “” here, we’re gonna go ahead and say “if previous == 0:” it’s gonna put that otherwise equation is going to be “else:” “equation = input(str(previous))” So let me go ahead and the first time it’s going to ask for an equation, so “4+3” and then it’s is going to drop down and we can go “-1” and you’ll see that it doesn’t quite work. So, what we need to do is we need to tell it if it is, let me separate this here, there. We want to evaluate it separately if there’s a previous result or not. So what we need to do is let’s go ahead and “if previous == 0:” we’re actually going to do this “previous = eval(equation)” which is going to only evaluate whatever we type in. “else: previous = eval((str(previous) + equation)” “else: previous = eval((str(previous) + equation” Go ahead and save, restart, we’re going to go “4+4” equals 8, “-2” is 6, “*10” is going to be 60, and you can see that we’re actually using different types of math on it. So “+5-2+3” is 66. So this is what we want, but let’s just remove where it says you typed because we no longer need that. “3-2” is 1, “+56” and you can see that now we can really get into the math here. You can evem type, let me start that again, so you can perform basically any mathematical operation here, and when you’re done just hit “quit” Now we wanted to give a specific message when it quits, so let’s just drop down here and have it print out “print(“Goodbye, human.”)” Go ahead run it and we type “quit” you’ll see it now says “Goodbye, human.” and then it closes. So this is actually a completely valid program, and it looks a lot different from the other example that we looked at. Now the eval function can be dangerous OK, it very well can be, and that’s why what we’re doing before we evaluate anything is we’re making sure there’s no letters and there’s none of these characters in it, because if there were you know somebody could…let me open up this. I can’t do that, okay. Somebody could you know if they import the system and the OS modules that are included in Python they could end up damaging their system, and so by using regex to remove all that before its evaluated we’re keeping things safe. So thank you guys for joining me and congratulations on finishing the second section of this course. In the next section, in the next bunch of videos, we’re going to be learning more advanced concepts, and we’re going to be developing more complicated programs than this.

Posted on

Modules Explained in Python

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

Click here to subscribe for more videos like this!

Hey guys, what we’re going to do in this video is learn how to import different modules to a Python script and we’re going to learn about regex. So, what’s a module? Basically, it’s an external library that you can include and use in your project providing additional functionality without you having to write this additional functionality. So, for example, we are going to go ahead and “import re” which is the regex library, and that’s how you import something, just type import and the name of it. Now, re is included with Python and so there’s nothing that we need to install in order to use it. So, now the basic usage, but well let’s get into regex. So I’m going to go ahead and create a “string = “‘I AM NOT YELLING’, she said. Though we knew it not to be true.” Now basically regex is not part of Python. It’s kind of like a mini programming language that you can use in basically any programming language. So I mean you can use regex in Python, in PHP, in JavaScript, you know, Java, C++, so regex is basically a way to match certain characters and then do something based on that. Now as you can see on Wikipedia here, there’s standard libraries for .net, java, python, c++, and there’s some built-in for Pearl, JavaScript, etc. So this is not Python specific and we’re only going to cover it to a limited degree as we need it. So, in this instance we’re going to be learning a few things for in the next video. So let’s go ahead and start figuring out how to use regex. So, the first thing we’re going to do is you know if I “print(string)” you’re going to see it says ‘I AM NOT YELLING’, she said. Though we knew it to not be true.” So we’ve got capitals, lower case, we’ve got a period, comma, and quotations. So, let’s go ahead and play around with this a bit. I’m going to create a new variable called “new = re.sub ” and what we’re doing is we’re instantiating the re object that we imported at the top of the script, and we’re calling the sub or substitute function on the re object, which the sub is built-in to the re object. So just like calling any other function when you call a function on an object you need to put the parameters into the parameter list. Now, how we haven’t discussed classes and objects yet, and we’re going to get to that, but this is you know we need to know this for the sake of this video and the next one now. The three parameters that this substitute function takes is the matches that we want to make, what we want to replace them with, and then the string that we’re going to manipulate by doing this. So we’ve already got the strings stored in the variable named string, let’s go ahead and cover some matches. So let’s say we want to remove all the capital letters. So what we’re going to do is basically open and close square brackets “[ ]” now rules in regex are contained within square brackets. So if we want to remove all the capital letters I mean we could go “[ABCDEFGHI]” you know we could do it that way and list out the entire alphabet, but regex actually provides a way to not have to do that by allowing us to choose a range of letters so this is going to say any capital letter from “[A-Z]” we want to replace with nothing, and we wanted to do this on the string, string. Let’s go ahead and hit enter. Now, if I “print(new)” you’re going to see that it removed all the capital letters and left everything else intact just the way it is. So we can also do the same for lower case letters, so instead of removing all the capital letters, it’s leaving everything except the lowercase letters. Well let’s say we want to remove all the special characters. So what we do is actually we could put multiple rules inside of the square brackets. So let’s go ahead and put “new = re.sub(.,\’]’, ‘ ‘, string)” let’s hit enter, print it out, you’ll see that it removed all the punctuation from the string. Now let’s go ahead and combine this with the lowercase letters, and then additionally uppercase letters. We’re left with nothing except the spaces, can’t see them here but there are spaces here. Let’s go ahead and leave the lowercase letters just so you guys can see. There are spaces. So there’s about four right there, you know, and so we’ve got spaces. So let’s remove the spaces as well. How we’re going to do that is within here “new = re.sub(‘[.,\’A-Z+” “]’, ‘ ‘ , string)” “new = re.sub(‘[.,\’A-Z+” “]’, ‘ ‘ , string)” Now let’s go ahead and, let’s add actually, so let’s go “string = string + “6 298 – 345″ ” then let’s “print(string)”, and what you can do as well you can actually create “new = re.sub( ‘ [^0-9] ‘ , ‘ ‘ ,)” what we’re going to do here is we’re just going to tell it to remove anything except numbers, we actually need to put that in quotations, we’re going to replace anything that’s not numbers with nothing, and we’re going to perform that on the string. So if I “print(new)” you’re going to see that all that remains is the numbers, so that’s the extent to which we need to learn regex in order to do what we’re doing in the next video which is building an awesome calculator.

Posted on

Loops Explained in Python

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

Click here to subscribe for more videos like this!

Alright guys, so we are about to create a calculator program in Python and before we do that actually we need to learn a few more things. So we’re going to go over a couple of the loop types in Python, so there’s two. One of them is a for loop and one of them is a while loop. So basically a for loop is good for if you want to iterate over an array or a list in Python. You can do something for each item in the list, so let’s go ahead and create a list. So let’s just call it “numbers =” and we’re going to create array “[1, 2, 3, 4, 5]” So let’s type “for item in numbers:” and we’re going to just “print(item)” going to save and let’s go ahead and run this, and you’re going to see that on each line it prints out it’s number. So, we would be able to do this if we wanted to have different names in here. So, again, “[“Nick”, “Someone”, “Another Person”]” save this. Let’s go ahead and run the script again and it’s going to print out “Nick Someone Another Person” So what we can do here actually is we can “print(‘This persons name is”, item)” So let’s go ahead and you’ll see that for each one it does print out that. So that is a for loop and basically the second parameter here in the for loop is the array or the list, and then the first one here is what you want each item in the list to be called while inside it’s little block of code. So in this case we’re calling it item. So that is a for loop, now we’re going to learn about a while loop. So let’s go ahead and create two variables, one is going to be called “run = True” and the other is going to be called “current = 1” So let’s go ahead and what we’re going to do is type “while run:” and then we write what we want to happen you know if it’s currently running. So what we’re going to do is we are going to put an if statement here, so we’re going to go “if current == 100:” actually don’t need those brackets. Alright so if “if current == 100:” we are going to set “run = False” but if it’s not “else:” we’re going to “print(current)” then after we print current, “current += 1” Let’s go ahead and save this and what this is going to do is basically we’re setting run to true initially because we want it to run at least once, so while run which in this case the first time it goes over it’s definitely going to be true. It’s going to check is current equal to a 100. Well, on the first time no it’s not it’s equal to 1, so this block of code won’t run. If it’s not equal to a hundred what it’s going to do is it’s going to print the current number, and then add one to the current number, and then run is still true so it’s going to go over it again. So what we should see here is it’s going to print the numbers 1 to 99. So let’s go ahead and run the script, and that’s exactly what we see here. Now these are two useful concepts that we’re going to be using, so hold onto those, and if you didn’t quite understand what I’m doing here, let me know in the discussion section.

Posted on

If Else Statements in Python

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

Click here to subscribe for more videos like this!

Alright guys, now we’re going to be learning about some conditional statements in Python. So we’re going to be learning about the if-else statement, and this basically provides a way to evaluate if something is true or false, or if something is something, or it’s not something and can do something different based on which condition is true. So let’s go ahead and let’s set “check = False” and what we’re going to do with that is we’re gonna say “if check == false:” “print(“It is false”)” and I’m going to save this and this is the minimal you need for an if statement. We’re going to go ahead and run this and it’s going to say it is false because it is false. Now if we were to change this to true, and run the same code, it’s not going to do anything, and that’s because we haven’t provided and else. So if it’s equal to false it will do this otherwise it’s just going to do nothing. So let’s go ahead and drop back four spaces to where the if statement began, I guess, and that type “else:” and we’re going to “print(“It is actually equal to True”)” So let’s go ahead and let’s run the script and you’ll see that now where this is not the case, check is not equal to false, so then it’s going to do this instead. Now, what we’re going to do is this is good if you want two conditions, but what if you want more the two conditions? Between the if and else you can actually use something called “elif:” and here we actually need to supply a condition to the elif. So think of it like another level to the if statement, and think of the else as a catch-all like if none of the above are true than just do this. So if check equals false it’s gonna do that. “elif_check == “Hamburger”:” we are going to “print (“Yummm, hamburgers”)” and let’s throw another “elif_check == “Yo”:” and say “print(“Hello”)” So let’s go ahead and save this, we’re going to run it again, and as you can see check is equal to true. So it says is this true? Nope, move on. Is this true? Nope, move on. Is this true? No, move on. Okay, well the else is going to say well if none of the above is true them we’re just going to do this. So what we’re going to do right now is we’re going to set this to “check = Hamburger” and we’re gonna run the script, and you’ll see what’s happening is it’s checking this one first, that’s not true, so it moves on its like okay this one’s true so let’s just do this and then let’s get out of the if statement, so it doesn’t check any further. So that’s what an if statement is in Python and that’s necessary for what we are about to do.