Category: Getting Started with Python

Getting Started with Python

Arrays in Python

Arrays in Python

Simply an array is a group of related data items that share a common name. Arrays are of sequence types and behave very much like lists. The major difference is the elements of a...

Code Blocks Use Indentation

Code Blocks Use Indentation

Code blocks are identified by indentation rather than using symbols like curly braces. Without extra symbols, programs are easier to read. Also, indentation clearly identifies which block of code a statement belongs to. Of...

Dictionaries in Python

Dictionaries in Python

Dictionaries are Python’s hash table type. They work like associative arrays or hashes found in Perl and consist of key-value pairs. Keys can be almost any Python type, but are usually numbers or strings....

Lists and Tuples

Lists and Tuples

Lists and tuples can be thought of as generic “buckets” with which to hold an arbitrary number of arbitrary Python objects. The items are ordered and accessed via index offsets, similar to arrays, except...

Strings

Strings

Strings in Python are identified as a contiguous set of characters in between quotation marks. Python allows for either pairs of single or double quotes. Subsets of strings can be taken using the slice...

Numbers in Python

Numbers in Python

Python supports four different numerical types: int (signed integers) long (long integers [can also be represented in octal and hexadecimal]) float (floating point real values) complex (complex numbers) Numeric types of interest are the...

Variables and Assignment

Variables and Assignment

Rules for variables in Python are the same as they are in most other high-level languages: They are simply identifier names with an alphabetic first character—”alphabetic” meaning upper- or lowercase letters, including the underscore...

Operators in Python

Operators in Python

The standard mathematical operators that you are familiar with work the same way in Python as in most other languages. + – * / % ** Addition, subtraction, multiplication, division, and modulus/remainder are all...

raw_input(), Input in Python

raw_input(), Input in Python

The easiest way to obtain user input from the command-line is with the raw_input() built-in function. It reads from standard input and assigns the string value to the variable you designate. You can use...