Python – Quick Guide

Python Basics

This article summarizes the most important Python topics and provides links and summary information to more detailed articles on our site. We hope you bookmark this page for future reference.

How to setup Python on your computer

Python is free and open source, available for all operating systems from python.org. If not already installed, this article will help you with your python setup.

IPython is a interpreted language which means that the code is translated (interpreted) to binary code while the program runs.

To run Python code you need to have a Python interpreter. There are different versions of Python, either Python 2 or Python 3.

Python Variables

In Python, variables are a storage placeholder for texts and numbers.

Using the Python Interpreter

The Python interpreter is usually installed in /usr/local/bin/python on machines
where it is available.

Python Comments

When working with any programming language, you include comments in the code to notate your work.

This details what certain parts of the code are for, and lets other developers know what you were up to when you wrote the code.

Python Docstrings

Python documentation strings (or docstrings) provide a convenient way of associating documentation with Python modules, functions, classes, and methods.

Keywords in Python

Keywords in Python are reserved words that cannot be used as ordinary
identifiers. They must be spelled exactly as they are written.

Booleans in Python

Boolean values are the two constant objects False and True.

They are used to represent truth values (other values can also be considered
false or true).

Operators

Python includes the +, -, *, /, % (modulus), and ** (exponentiation) operators.

Regular Expressions in Python

Regular Expressions are a string pattern written in a compact syntax, that allows us to quickly check whether a given string matches or contains a given pattern.

Using math in Python

The Python distribution includes the Python interpreter, a very simple development environment, called IDLE, libraries, tools, and documentation.

Exception Handling in Python

In this post we will cover how Python handles errors with exceptions.

Strings in Python

A string is a list of characters in order.

Concatenate Strings

One common task you’ll need to accomplish with any language involves merging or combining strings. This process is referred to as concatenation.

The best way to describe it is when you take two separate strings – stored by the interpreter – and merge them so that they become one.

Lists in Python

The simplest data structure in Python and is used to store a list of values.

Lists are collections of items (strings, integers, or even other lists).

Dictionaries in Python

Dictionaries are collections of items that have a “key” and a “value”.

Dictionary Manipulation in Python

Methods of Dictionary Objects

String Manipulation in Python

Methods of String objects

List Manipulation in Python

Methods of List objects

Loops

To keep a computer doing useful work we need repetition, looping back over the same block of code again and again.

List Comprehensions in Python

List comprehensions provide a concise way to create lists.

Functions

A function is something you can call (possibly with some parameters, the things you put in the parentheses), which performs an action and returns a value.

Conditional statements in Python

In programming, very often we want to check the conditions and change the behavior of the program.

If..Elif..Else Statement

Conditions tests if something is True or False, and it uses Boolean values (type bool) to check that.

Modules

Python modules makes the programming a lot easier. It’s basically a file that consist of already written code.

ArgParse Tutorial

Sys.argv Tutorial

CSV Module Tutorial

FeedParser Tutorial

How to use Pillow, a fork of PIL

Pillow is a fork of PIL (Python Image Library), started and maintained by Alex Clark and Contributors. It was based on the PIL code, and then evolved to a better, modern and more friendly version of PIL. It adds support for opening, manipulating, and saving many different image file formats. A lot of things work the same way as the original PIL.

Reading and Writing Files in Python

When you’re working with Python, you don’t need to import a library in order to read and write files. It’s handled natively in the language, albeit in a unique manner.

With Statement in Python

In Python you need to give access to a file by opening it. You can do it by using the open() function. Open returns a file object, which has methods and attributes for getting information about and manipulating the opened file.

Python Style Rules

This style guide is a list of dos and don’ts for Python programs.

Python Language Rules

PEP8 has emerged as the style guide that most projects. it promotes a very readable and eye-pleasing coding style.

iPython

IPython is an interactive shell for the Python programming language that offers enhanced introspection, additional shell syntax, tab completion and rich history.

 

Leave a Reply

Your email address will not be published. Required fields are marked *