Installing Python on Windows 10/11

Installing Python on Windows 10/11

Introduction

 

Hello and welcome to another tutorial on Learn Code Today. Today we are going to learn how to install Python to your computer. There are several different ways to install Python to our systems, but we are going to look at what I call a “Hard Install”. This means that we will install Python directly to our PC and not to something like Docker which containerizes installs so they don’t conflict with one another on a system. Let’s begin!

Step 1

 

To start, we need to navigate over to the Python website. Head over to https://www.python.org/ and you will see a downloads button right on the front page.

Python.org Downloads

Click on the “Downloads” button on the navigation bar, and it will take you to yet another page that will allow you to choose which version you would like to download. 

Python Download Link

Now quick caveat. This will always download the 32-bit installer. If you are looking for the 64-bit installer, you will need to scroll down the page until you see the spot that says, “Looking for a specific installer”. This is where you will click the latest version and be taken to another page that will have the source files, exe’s, and web installers in both 32-bit and 64-bit. 

Python Specific Installer
Python 64 Bit installer

So you can see in the picture directly above, I have indicated with check marks, which python installer is 64-bit. While 32-bit is often enough for most people, if you have more than 4GB of RAM in your PC, you can benefit from running 64-bit Python on your system. If you have less than 4GB, most likely you are only running a 32-bit version of Windows, and installation will fail when trying to install the 64-bit version.

Ok enough technical speak, lets move onto downloading and installing Python! So once you have clicked the version you would like, a download prompt will appear asking you where you would like to put the installer. You can rename the installer if you like and put it anywhere easy to remember on your system.

Python Installer Save Location

Step 2

 

Ok, once you have the installer saved to your system. Its now time to run it. Quick side note, if you downloaded one of the optional installers as I highlighted above for the 64-bit version, make sure you understand how to run it. If it was the zip file, extract the contents first, and then double click the installer. If it was the EXE, well then all you need to do is double click it just like those that download it directly from the button on the second page without going for the 64-bit version.

Ok, now that you have opened the installer, you will be greeted by a first screen. It is important that you check the box at the bottom that says, “Add Python 3.X to Path” or something along those lines. This will save you major headaches down the line when trying to run python or scripts from the command line. Once you have checked that box, you can proceed with the normal installation by selecting “Install Now”. If you prefer to install Python to a different location, go ahead with the custom install and provide the location and proceed as normal from there.

 

Python Installer Screen 1

Once you begin the actual installation, it should go pretty quick, depending on your internet connection. There will be a UAC popup requesting permission to continue, so make sure to approve that to get the actual installation underway. 

Python Installing

Once the installer has completed, one final screen will appear asking you if you want to disable the path length limit. I would advise selecting yes for this option. Clicking on it will bring about yet another UAC popup. Just confirm and it will take you back to the complete screen with a “close” button in the lower right hand corner. You can now safely close the installer and Python is successfully installed on your system!

Python Installer Success

Step 3

 

Congratulations! You can now start using python on your system. To get started, simply navigate to the windows start menu, and in the recent programs section at the very top, you should see something like this:

Recently Added Programs

Click on the IDLE option and an interactive display will appear allowing you to start coding in real time with Python. You can also just open up the Command Prompt (CMD) and type in Python and hit “Enter” or “Return” and it will launch an interactive version there as well. 

Python IDLE
Python CMD

Conclusion

 

That is it for this tutorial. I hope you found it helpful. If you are on MAC or Linux, the process is fairly straight forward as well. With MAC, you install python just like any other MAC program and there is a section on their website with the download and instructions on how to do so. For Linux, just use your favorite package manager or compile from source and you are good to go! Most Linux distros come with Python pre-installed already as it is, but it is often and older version. I assume also, that if you are on Linux, you are already fairly familiar with installing applications and decent when it comes to being “tech savvy” and are more than capable of figuring it out.

Python Variable Names

Python Variable Names

Introduction

 

Python is a powerful programming language, and here at Learn Code Today, it is also one of our favorite to work with! Over the years, Python has jumped to the top of the pack for programming languages over competitors because of its versatility and ease of use. This language can be used to create scripts, to create games, machine learning, AI, and so much more. It is a loosely typed language, meaning that you do not need to declare variable types as the interpreter figures that out for you, making it an excellent choice for beginners to pick up.

In today’s tutorial, we are going to talk about variables. A mentioned in some of the starting tutorials, variables are like little boxes that hold some information in them, with a human readable name, that we can call at anytime for use! How cool is that? So you want to store someone’s name and recall it late? Easy in Python!

 

How to Declare a variable

To declare a variable in Python, all you need to do, is to give the variable a name and set it equal to some content. See the example below:

name = "Peter"
Pretty easy right? Name anytime that we want to use this name, say to print it to the screen, we just call the variable up and it will output that for us!
print(name)
expected output:
Peter

You can also create multiple variables at once by separating them with commas:

x, y, z = 1, 2, 3

In this example, x has the value 1, y has the value 2, and z has the value 3.

So that’s easy enough to understand, but what else can variables hold in them? Everything just about! You can store numbers, or as they are called in programming terms, integers. You can also store floating point integers (decimals), references to objects, output from a method or function, boolean values, entire functions, etc.

 

Naming Variables – more important than you think

So with variables, comes great responsibility though. They can easily be overwritten and named poorly making code very hard to read and understand. It’s best to name your variables something meaningful so that just reading the name explains what it is holding. For example, while this is perfectly valid:

x = "Peter"
Trying to figure out what “x” is several hundred or thousands of codes lines down is going to be near impossible. It’s best to name it something more in line like:
name = "Peter"
user = "Peter"
username = "Peter"

As you can see, the variable name is much easier to understand what is contained inside of it.

 

Naming Gotchas

The last topic I will cover with naming variables is that capitalization does matter in Python. Peter, peter, PeTeR, PETER, are all valid different variables. Please be careful when naming your variables as to not cause confusion. Find a naming convention and stick to it. There are two main naming conventions that are used today in most programming languages. camelCase and PascalCase. Lets see what this looks like in practice.

ageInYears = 20
HeightInCentimeters = 177.8

As you can see, with the first variable name, we keep the first word lowercase and uppercase each word afterwards (This is called camelCase). For PascalCase, every word is capitalized from the get go. In Python, you can also use underscores and hyphens ( – ), but I would recommend one of the two that I have shown here since it is used in other languages more commonly.

While PEP 8, the Python guidelines for styling code, suggests using all lowercase names with underscores, if you ever plan to use another language such as C#, you will not find this convention very often and it can lead to confusion. If you are only going to be using Python, then stick to the PEP 8 guidelines and use all lowercase with underscores like so:

height_in_inches = 70

If you are only going to be using Python, then stick to the PEP 8 guidelines and use all lowercase variable names with underscores

Globally Reserved Names and other tips

I know I said this would be the last topic, but one more quick note. Some names are reserved for Global Variables and cannot and should not be used for your programs.

 

33 Python Reserved Words not allowed for variables

False def if raise
None del import return
True elif in try
and else is while
as except lambda with
assert finally nonlocal yield
break for not
class from or
continue global pass

 

 

 

 

 

 

 

 

 

 

 

 

Also avoid using lowercase l (el) or uppercase O (oh) as single named variables as in some fonts, they are indistinguisable from 1 (One) and 0 (Zero).

 

Conclusion

In conclusion, Python variables are a fundamental concept in programming. They are used to store and manipulate data in a program. In Python, variables are created by assigning a value to a name. Good variable naming conventions and following PEP8 rules can make your code more readable and easier to understand. Remember to use descriptive variable names, avoid using globally reserved names, and use all lowercase letters for variable names to avoid confusion.

By understanding the basics of Python variables and following these best practices, you can write more efficient, readable, and maintainable code. Happy coding!

Pin It on Pinterest