Wednesday, September 11, 2013

Download and install spyder on Ubuntu

Download latest spyder-2.2.4.zip from https://code.google.com/p/spyderlib/downloads/list. Unzip the file, change to the unzipped directory, run the command:

$sudo python setup.py install

To run installed spyder, you need install python-qt4 in your system.

Run installed Spyder with the command in Terminal

$spyder


Install python-qt4 on Ubuntu

Install python-qt4 on Ubuntu, use the command in Terminal

$sudo apt-get install python-qt4

Spyder, a Scientific PYthon Development EnviRonment

Spyder is a powerful interactive development environment for the Python language with advanced editing, interactive testing, debugging and introspection features.

Spyder lets you easily work with the best tools of the Python scientific stack in a simple yet powerful environment. Run on all platforms, include Windows, Mac OSX and on Linux.

Spyder

Tuesday, September 3, 2013

NumPy Beginner's Guide - Second Edition

NumPy Beginner's Guide - Second Edition


An action packed guide using real world examples of the easy to use, high performance, free open source NumPy mathematical library
Overview
  • Perform high performance calculations with clean and efficient NumPy code
  • Analyze large data sets with statistical functions
  • Execute complex linear algebra and mathematical computations
In Detail
NumPy is an extension to, and the fundamental package for scientific computing with Python. In today's world of science and technology, it is all about speed and flexibility. When it comes to scientific computing, NumPy is on the top of the list.
NumPy Beginner's Guide will teach you about NumPy, a leading scientific computing library. NumPy replaces a lot of the functionality of Matlab and Mathematica, but in contrast to those products, is free and open source.
Write readable, efficient, and fast code, which is as close to the language of mathematics as is currently possible with the cutting edge open source NumPy software library. Learn all the ins and outs of NumPy that requires you to know basic Python only. Save thousands of dollars on expensive software, while keeping all the flexibility and power of your favourite programming language.You will learn about installing and using NumPy and related concepts. At the end of the book we will explore some related scientific computing projects. This book will give you a solid foundation in NumPy arrays and universal functions. Through examples, you will also learn about plotting with Matplotlib and the related SciPy project. NumPy Beginner's Guide will help you be productive with NumPy and have you writing clean and fast code in no time at all.
What you will learn from this book
  • Install NumPy
  • NumPy arrays
  • Universal functions
  • NumPy matrices
  • NumPy modules
  • Plot with Matplotlib
  • Test NumPy code
  • Relation to SciPy
Approach
The book is written in beginner’s guide style with each aspect of NumPy demonstrated with real world examples and required screenshots.
Who this book is written for
If you are a programmer, scientist, or engineer who has basic Python knowledge and would like to be able to do numerical computations with Python, this book is for you. No prior knowledge of NumPy is required.

Friday, July 26, 2013

Read online for free: Python Cookbook, Third Edition

If you need help writing programs in Python 3, or want to update older Python 2 code, this book is just the ticket. Packed with practical recipes written and tested with Python 3.3, this unique cookbook is for experienced Python programmers who want to focus on modern tools and idioms.

Inside, you’ll find complete recipes for more than a dozen topics, covering the core Python language as well as tasks common to a wide variety of application domains. Each recipe contains code samples you can use in your projects right away, along with a discussion about how and why the solution works.

Read online:
http://chimera.labs.oreilly.com/books/1230000000393

Thursday, July 25, 2013

Python language Video Tutorials

Python language Video Tutorials

If you're interested in learning how to write computer programs, you'll love this training.

It's perfect for desktop/web application developers who need an intro course in Python, for systems administrators who are interested in using Python for automation and for anyone interested in a programming career.



Tuesday, July 23, 2013

Python for Everyone



Cay Horstmann's Python for Everyone provides readers with step-by-step guidance, a feature that is immensely helpful for building confidence and providing an outline for the task at hand. “Problem Solving” sections stress the importance of design and planning while “How To” guides help students with common programming tasks. Photographs present visual analogies that explain the nature and behavior of computer concepts. Step-by-step figures illustrate complex program operations, while syntax boxes and example tables present a variety of typical and special cases in a compact format. This book contains a substantial number of self-check questions at the end of each section. “Practice It” pointers suggest exercises to try after each section. Python for Everyone presents the essentials in digestible chunks, with separate notes that go deeper into good practices or language features when the reader is ready for the additional information. You will not find artificial over-simplifications that give an illusion of knowledge.

Sunday, May 12, 2013

PyPy

PyPy is a very compliant Python interpreter, almost a drop-in replacement for CPython 2.7.3. It's fast due to its integrated tracing JIT compiler. The current release — PyPy 2.0 — support x86 Linux, Mac OS/X, Windows. ARM support in 2.0 is alpha-level.

Website: http://pypy.org/


Tuesday, March 26, 2013

CheckBox of tkinter

Example of using tkinter.Checkbutton in Python. Also demonstrate how to get status of tkinter.Checkbutton.

tkinter.CheckBox
tkinter.CheckBox


#tkinter for Python 3.x
#Tkinter for Python 2.x

import tkinter

def quit():
    global tkTop
    tkTop.destroy()

def setCheckButtonText():
    if varCheckButton.get():
        varLabel.set("checked")
    else:
        varLabel.set("un-checked")  

tkTop = tkinter.Tk()
tkTop.geometry('300x200')

tkButtonQuit = tkinter.Button(
    tkTop,
    text="Quit",
    command=quit)
tkButtonQuit.pack()

varLabel = tkinter.StringVar()
tkLabel = tkinter.Label(textvariable=varLabel)
tkLabel.pack()

varCheckButton = tkinter.IntVar()
tkCheckButton = tkinter.Checkbutton(
    tkTop,
    text="CheckButton",
    variable=varCheckButton,
    command=setCheckButtonText)
tkCheckButton.pack(anchor=tkinter.CENTER)

tkinter.mainloop()


Monday, March 25, 2013

Read keyboard input in Python

char_in = 'a'
print(char_in)
while char_in not in ['Q', 'q']:
    print('Enter Q/q to quit:')
    char_in = input()
    print(char_in)

Read keyboard input in Python
Read keyboard input in Python


Sunday, March 24, 2013

List all built in functions in Python Shell

type the following command in Python Shell to List all built in functions:

>>> dir(__builtins__)

note: There are two leading and trailing underscore characters, "_".

List all built in functions in Python Shell with dir(__builtins__)
List all built in functions in Python Shell with dir(__builtins__)


Wednesday, March 20, 2013

Set font of tkinter.Label

Set font of tkinter.Label
Set font of tkinter.Label


#tkinter for Python 3.x
#Tkinter for Python 2.x

import tkinter

def quit():
    global tkTop
    tkTop.destroy()

def setTextSize(ev=None):
    global tkLabel
    global tkScale
    tkLabel.config(font="Helvetica -%d bold" %tkScale.get())

tkTop = tkinter.Tk()
tkTop.geometry('300x200')

tkButtonQuit = tkinter.Button(tkTop, text="Quit", command=quit)
tkButtonQuit.pack()

tkLabel = tkinter.Label(text="Hello Python")
tkLabel.pack()

tkScale = tkinter.Scale(tkTop, from_=1, to=40, orient=tkinter.HORIZONTAL, command=setTextSize)
tkScale.set(18)
tkScale.pack(anchor=tkinter.CENTER)

tkinter.mainloop()


Implement Scale bar of Tkinter

Scale bar of Tkinter
Scale bar of Tkinter


#tkinter for Python 3.x
#Tkinter for Python 2.x

import tkinter

def quit():
    global tkTop
    tkTop.destroy()

tkTop = tkinter.Tk()
tkTop.geometry('300x200')

tkButtonQuit = tkinter.Button(tkTop, text="Quit", command=quit)
tkButtonQuit.pack()

tkScale = tkinter.Scale(tkTop, from_=1, to=30, orient=tkinter.HORIZONTAL)
tkScale.set(18)
tkScale.pack(anchor=tkinter.CENTER)

tkinter.mainloop()


Define command to destroy window of Python

Define command to destroy window of Python
Define command to destroy window of Python


#tkinter for Python 3.x
#Tkinter for Python 2.x

import tkinter

def quit():
    global tkTop
    tkTop.destroy()

tkTop = tkinter.Tk()
tkTop.geometry('300x200')

tkButtonQuit = tkinter.Button(tkTop, text="Quit", command=quit)
tkButtonQuit.pack()

tkinter.mainloop()


Tuesday, March 19, 2013

Tkinter, set window size using geometry

set window size using geometry
set window size using geometry


#tkinter for Python 3.x
#Tkinter for Python 2.x

import tkinter

tkTop = tkinter.Tk()
tkTop.geometry('300x200')
tkButtonQuit = tkinter.Button(tkTop, text="Quit", command=tkTop.quit)
tkButtonQuit.pack()
tkinter.mainloop()


Simple example using tkinter Button with command

example using tkinter Button with command
example using tkinter Button with command


#tkinter for Python 3.x
#Tkinter for Python 2.x

import tkinter

tkTop = tkinter.Tk()
tkButtonQuit = tkinter.Button(tkTop, text="Quit", command=tkTop.quit)
tkButtonQuit.pack()
tkinter.mainloop()


Simple example using tkinter Label

Simple example using tkinter Label
Simple example using tkinter Label



#tkinter for Python 3.x
#Tkinter for Python 2.x

import tkinter

tkTop = tkinter.Tk()
tkLabel = tkinter.Label(tkTop, text="Hello python.beginner")
tkLabel.pack()
tkinter.mainloop()