Python Archive

Easy_Install python on Windows 10

Easy Install is a python module bundled with setuptool which lets you automatically download, build, install, and manage Python packages. This small tutorial will guide you step-by-step on how to install easy_install/ setuptools on windows and make your life easier on to install different python packages using command prompt. Goto Click on Installation. Right Click on file and click

Lists in Python

Lists in Python Python has a very versatile data type available that are lists. Lists can be written as comma separated values inside square brackets. As in many other languages python lists can not be of same data type e.g integers or string or floating points. Suppose following code to create a list. [crayon-59c3f851eddd5653073322/] To

Installing Python on Windows 10

Which version to choose 2.x or 3.x? Which version you ought to use is mostly dependent on what you want to get done. There are some key issues that may require you to use Python 2 rather than Python 3. Firstly, if you’re deploying to an environment you don’t control, that may impose a specific

Files in Python (Part I)

When we want to read or write a file (say on your hard drive), we first must open the file. Opening the file communicates with your operating system which knows where the data for each file is stored. When you open a file, you are asking the operating system to find the file by name and make sure

Strings in Python (Part II)

A segment of a string is called a slice. Selecting a slice is similar to selecting a character: >>> s = 'Monty Python' >>> print s[0:5] Monty >>> print s[6:13] Python If you omit the first index (before the colon), the slice starts at the beginning of the string. If you omit the second index, the

Strings in Python (Part I)

A string is a sequence of characters. The index indicates which character in the sequence you want to access and similar to Java indexing in python also starts from zero.You can access the characters one at a time with the bracket operator: >>> fruit = 'banana' >>> letter = fruit[1] >>> print letter a len

Iteration in Python (Part II)

For Loop Sometimes we want to loop through a set of things such as a list of words, the lines in a file or a list of numbers. When we have a list of things to loop through, we can construct a definite loop using a for statement. We call the while statement an indefinite loop because it

Iteration in Python (Part I)

Updating Variables A common pattern in assignment statements is an assignment statement that updates a variable – where the new value of the variable depends on the old. x = x+1 This means “get the current value of x, add one, and then update x with the new value.” If you try to update a variable that

Conditional Execution in Python (Part II)

In order to write useful programs, we almost always need the ability to check conditions and change the behavior of the program accordingly. Conditional statements give us this ability. The simplest form is the if statement: if x > 0 : print ‘x is positive’ The boolean expression after the if statement is called the

Conditional Execution in Python (Part I)

Boolean Expressions A boolean expression is an expression that is either true or false. The following examples use the operator ==, which compares two operands and produces True if they are equal and False otherwise. >>> 5 == 5 True >>> 5 == 6 False True and False are special values that belong to the type bool;