Computer Programming Basics

Save
Next Video:
How Do Circuit Boards Work?....5

The basics of computer programming can be practiced through the use of Python, which can be downloaded for free at python.org. Use a command line, which is the Python programming interface, with help from a software developer in this free video on computer tech support.

Part of the Video Series: Computer Tech Support
Promoted By Zergnet

Comments

Video Transcript

Hi. My name is Dave Andrews. Today, I'm going to talk to you a little bit about some computer programming basics. I'm going to use Python for this. And you can download Python for free at Python.org. Let's go to our computer. We're going to to open up Python by clicking on our start button. Let's go to All Programs. Find Python. Now, we want to open up Python in the command line. This opens up a command line that you may have used before to interact with Windows, but this is actually not the typical command line. It's the Python programming interface. Now, the very first thing I want to show you is what's called a variable. A variable is given a name, for instance, X. If you've ever been to algebra class, you know that x can be a variable that holds any number. But I'm going to set X = 5. Now, I just say X = 5 and I hit enter. Now, if I just type x, it'll show me that x hold the value 5. If I say X = 25 x 100/4 and I type x again, it gives me the result of that calculation. It's that easy to do calculations and store them in variables. Now, the very next thing I'm going to do is called a conditional. And that is where you make a decision based upon the value of a variable. So, I'm going to say again that X = 5. Now, let's type "if" which opens our conditional "X" and then a double equals "==" which is our comparison value. A single = is an assignment. Double equals is a comparison. So, if X = 5 and let's put a : there. Press enter. Now, press your tab key to put the value that you want to type. Say "print X is 5". Now, let's do an "else: print X is not 5." Now, here it's going to compare 5 to X and if it is 5, it's going to say X is 5, else it's going to say X is not 5. Press Enter a couple of times and there's your answer. X is 5. Let's say X = 6 and do the same thing. If X is equal to 6, print X is 6, else print X is not 6. Of course, in this case, again it is 6, so we'll say X is 6. Now, last thing I'm going to show you is a lop, which is a very simple construct. It's going to loop from a range. I'm going to say "for value in range 0 to 20". It's going to loop from 0 to 20, colon : print value. And hit Enter. So, there we have from 0 to 20, not including 20. We have the values in that range. It's that easy to do variables, conditionals and loops in Python.

Featured

Related Searches

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!