Python Variable Types

--Originally published at Programming

Assigning Values to Variables

Before we start listing the different Python variable types we need to know what a variable is. A variable is defined as a reserved memory location to store a value. Depending on which data type you are using the interpreter will decide what can be stored in the reserved memory.

Unlike any other programming languages in Python you don’t need to explicitly declare variables. In other words, the declaration happens whenever you assign a value to a variable. The operand left to the “=” sign is the variable and the one on the right is the value you are assigning to the variable. Let’s see some examples.

1.png

Standard Data Types

The variables in python can be declared of many types. Some of the Python data types are the Integers, Floats, Complex numbers, Strings, Boolean. etc…

2.png

 


How to use Python in Eclipse

--Originally published at Programming

Hi! Today I’m going to teach you how to use Python in eclipse. This is what you are going to need in order to be able to use Python in Eclipse.

Materials:

  1. You have to download the Java Platform, Standard Edition Development Kit (JDK) You can do this right here http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  2. You need to install Eclipse from https://www.eclipse.org/downloads/
  3. You need to have Python 3.0 or higher installed in your computer https://www.python.org/downloads/

Steps

Open eclipse, go to help and select install new software

1.png

Click on the Add button on the top right corner. In the location text area you are going to paste this link http://www.pydev.org/updates/ and you can name it however you want.

2.png

Go to File > new > Project > PyDev Project. Name your project however you want and select the Grammar Version 3.0 – 3.5. Afterwards you need to click on Click here to configure an interpreter not listed and select Quick-Auto config.

3.png

Now you are going to change the interpreter from Default to Python. 4.png

Click on Finish. You are going to notice on the left a folder with the name of your project. Right click it and select Source Folder. Right click on Source Folder and select new > PyDevModule. You are ready to start coding!


Use Of Comments In Python

--Originally published at Programming

Hi,  welcome to my very first blog post! Today we are going to learn how to add comments in Python as well as the importance of using them.

Use of Comments (Why and When?)

You may be wondering. Why should I use comments in python? Are they really that big a deal? Well my friend, the answer to both questions is YES! And I’m going to tell you why. If you are a beginner in Python or any other programming language, you may think that the use of comments is not very important since you are working by yourself and your program is easy to read. However when you start coding bigger programs that require several lines of code, not only is it going to become more complex and more difficult to read, but also you are going to require a bigger team of programmers that can help you do the job.Therefore the use of comments is going to become essential for the communication between programmers.You need to let them know what you intend to do with a specific part of your program such as your functions, a function’s parameters, the variable names, arrays etc…

How to add a Comment

Now that you know when to use comments it’s time to teach you how to do it. There is just one official way to add comments in python:

  • Single-line comments: Start with the character “#” and end by the end of the line. In other words, Python ignores anything that comes after the “#” to the end of the line.

In case that you want to add multi-line comments then you just need to add “#” at the beginning of every line.