Installing and Developing Programs in Python. Installing Python is pre-installed on most Unix systems, including Linux and MAC OS X The pre-installed.

Slides:



Advertisements
Similar presentations
Learn Python in three hours
Advertisements

Linux+ Guide to Linux Certification, Second Edition
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Guide To UNIX Using Linux Third Edition
How to install the Zelle graphics package
CS0007: Introduction to Computer Programming Setting Up Java.
© 2010 IBM Corporation IBM Experience Modeler - Theme Editor Installing Python Image Library Presenter’s Name - Presenter’s Title DD Month Year.
Introduction to Python: Slides Referenced in Homework 0 CSE-391: Artificial Intelligence University of Pennsylvania Matt Huenerfauth January 2005.
PYTHON: LESSON 1 Catherine and Annie. WHAT IS PYTHON ANYWAY?  Python is a programming language.  But what’s a programming language?  It’s a language.
Introduction to Python Kris Kneubuhler SE NPUG July 17 th 2014.
Chapter 1: Python Basics CSCI-UA 0002 – Introduction to Computer Programming Mr. Joel Kemp.
Examples taken from: nltk.sourceforge.net/tutorial/introduction/index.html Natural Language Toolkit.
Servlets Environment Setup. Agenda:  Setting up Java Development Kit  Setting up Web Server: Tomcat  Setting up CLASSPATH.
UNIX command line. In this module you will learn: What is the computer shell What is the command line interface (or Terminal) What is the filesystem tree.
Topics Introduction Hardware and Software How Computers Store Data
Introduction to Shell Script Programming
The Python interpreter CSE 140 University of Washington Michael Ernst.
Introduction to Python By Neil Cook Twitter: njcuk Slides/Notes:
Introduction to Programming Workshop 1 PHYS1101 Discovery Skills in Physics Dr. Nigel Dipper Room 125d
Python 0 Some material adapted from Upenn cmpe391 slides and other sources.
CSC 215 : Procedural Programming with C C Compilers.
© 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures for Java William H. Ford William R. Topp Appendix E The EZJava.
August 29, 2005ICP: Chapter 1: Introduction to Python Programming 1 Introduction to Computer Programming Chapter 1: Introduction to Python Programming.
Python From the book “Think Python”
Ch 1. A Python Q&A Session Spring Why do people use Python? Software quality Developer productivity Program portability Support libraries Component.
Shell Programming. Introducing UNIX Shells  Shell is also a programming language and provides various features like variables, branching, looping and.
Pattern Recognition Software CS855 Week 1. Matlab Commercial Very fast matrix operations Many open source functions Portability limited Free Interpreted.
July 2011CMSC 341 CVS/Ant 1 CMSC 341 Java Packages Ant CVS Project Submission.
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
UNIX/LINUX SHELLS.  “A Unix shell is a command-line interpreter or shell that provides a traditional user interface for the Unix operating system and.
Python I Some material adapted from Upenn cmpe391 slides and other sources.
9/2/ CS171 -Math & Computer Science Department at Emory University.
Eclipse 3.1 IDE Overview.
Created by Harry H. Cheng,  2009 McGraw-Hill, Inc. All rights reserved. C for Engineers and Scientists: An Interpretive Approach Chapter 2: Getting Started.
You Need an Interpreter!. Closing the GAP Thus far, we’ve been struggling to speak to computers in “their” language, maybe its time we spoke to them in.
Python module distribution. Modules in Python Modules are everywhere.
Installing and Developing Programs in Python. Installing Python is pre-installed on most Unix systems, including Linux and MAC OS X The pre-installed.
CPS120: Introduction to Computer Science Compiling a C++ Program From The Command Line.
©2012 Paula Matuszek CSC 9010: Text Mining Applications Lab 2 Dr. Paula Matuszek (610)
Python I Some material adapted from Upenn cmpe391 slides and other sources.
Exploring Spyder: An IDE for scientific computing
Linux+ Guide to Linux Certification, Second Edition Chapter 4 Exploring Linux Filesystems.
Haskell Basics CSCE 314 Spring CSCE 314 – Programming Studio Using GHC and GHCi Log in to unix.cse.tamu.edu (or some other server) From a shell.
Xi Wang Yang Zhang. 1. Easy to learn 2. Clean and readable codes 3. A lot of useful packages, especially for web scraping and text mining 4. Growing popularity.
Object Oriented Programming COP3330 / CGS5409.  Compiling with g++  Using Makefiles  Debugging.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
See Winter 2016CISC101 - Prof. McLeod1.
PROGRAMMING USING PYTHON LANGUAGE ASSIGNMENT 1. INSTALLATION OF RASPBERRY NOOB First prepare the SD card provided in the kit by loading an Operating System.
Debugging using By: Samuel Ashby. What is debugging?  A bug is an error in either a program or the hardware itself.  Debugging is first locating and.
 CSC 215 : Procedural Programming with C C Compilers.
Presented By P.SRIVIDYA 085D1A0552 Programming Language.
Programming C++ in Linux by various IDEs and editors by: Danial Khashabi Master: Dr.B.Taheri November 2008.
How to Get Started With Python
Python Programming Unit -1.
Development Environment
Python’s Modules Noah Black.
ITCS-3190.
Introduction Python is an interpreted, object-oriented and high-level programming language, which is different from a compiled one like C/C++/Java. Its.
The Linux Operating System
Introduction to computing
Prepared by Kimberly Sayre and Jinbo Bi
Data Analysis using Python-I
Do you know this browser?...
Python I Some material adapted from Upenn cmpe391 slides and other sources.
EMSE 6574 – Programming for Analytics: Python 101 – Python Enviornments Joel Klein.
12th Computer Science – Unit 5
Chapter 1: Programming Basics, Python History and Program Components
Video Notes.
The Python interpreter
Installations for Course
Presentation transcript:

Installing and Developing Programs in Python

Installing Python is pre-installed on most Unix systems, including Linux and MAC OS X The pre-installed version may not be the most recent Two “latest versions” –2.7 released 7/10 & 3.2 released 10/10 –Python 3 is a non-backward compatible version which you should use for CS2021 Download from

Running Interactively on UNIX On Unix… % python >>> Python prompts with ‘>>>’. To exit Python (not Idle): –In Unix, type CONTROL-D –In Windows, type CONTROL-Z + –Evaluate exit()

Running Programs on UNIX Call python program via the python interpreter % python fact.py Make a python file directly executable by –Adding the appropriate path to your python interpreter as the first line of your file #!/usr/bin/python –Making the file executable % chmod a+x fact.py –Invoking file from Unix command line % fact.py

Python IDEs There are many Integrated Development Environments and Package Management Systems –IDLE –Emacs –Anaconda / Spyder –Enthought Canopy –Komodo –PyCharm –Eclipse + PyDev –TextMate

IDLE Development Environment IDLE is the “official” IDE distributed with PythonIDLE Preinstalled on MAC OS X Written in Python with the Tkinter GUI packageTkinter Multi-window text editor with syntax highlighting, auto-completion, smart indent and other features Python shell with syntax highlighting, line recall, … Integrated debugger with stepping, persis- tent breakpoints, and call stack visi- bility

Developing Python in Emacs Emacs python-mode.el has good support for editing Python, by default for.py files Features: syntax completion, symbol help, eldoc, and inferior interpreter shell, etc. Configuring emacs for python –

Anaconda Anaconda is the leading Python distribution for supporting SciPy for large-scale data processing, predictive analytics, and scientific computing Download Anaconda: Quickstart: da-Quickstart.pdf da-Quickstart.pdf

Installing and Running 3 rd Party Libs Power of Python is in 3 rd Party Packages. Python has several alternatives for installing 3 rd party packages. PyPI - the Python Package Index is a repository of software for the Python programming language. There are currently packages. How to Get and Install Packages: To use a package from the PyPI index either use shell command $ pip install package-namepip or explicitly download, unpack, and "python setup.py install" it.

Python Package Terminology “Programs are composed of modules. Modules contain statements. Statements contain expressions. Expressions create and process objects.” module the basic unit of code reusability in Python: a block of code imported by some other code. Three types of modules concern us here: pure Python modules, extension modules, and packages. pure Python module a module written in Python and contained in a single.py file (and possibly associated.pyc and/or.pyo files). Sometimes referred to as a “pure module.” extension module a module written in the low-level language of the Python implementation package a module that contains other modules; typically contained in a directory in the filesystem and distinguished from other directories by the presence of a file __init__.py.

Using the Module System: import and from Clients of module (.py file) that use import get a module with attributes, while clients that use from get copies of the file’s names. Generally, you will prefer to use import. Python programs are composed of multiple module files linked together by import statements, and each module has attributes -- a collection of variables—call it a namespace. #file threenames.py a = 'dead' # Define three attributes b = 'parrot # to export to other files c = 'sketch' print(a, b, c) % python threenames.py # run from the command line here dead parrot sketch % python >>> import threenames # Grab the whole module: it runs here too dead parrot sketch >>> >>> threenames.b, threenames.c # but now we can access module attributes ('parrot', 'sketch') >>> >>> from threenames import a, b, c # Copy multiple names out of module >>> b, c ('parrot', 'sketch')” “>>> dir(threenames) ['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'a', 'b', 'c']”

- A natural language processing toolkit bash-3.2$ pip install nltk Requirement already satisfied bash-3.2$ python Python |Anaconda (x86_64)| (default, May , 17:04:42) [GCC (Apple Inc. build 5577)] on darwin >>> import nltk >>> sentence = """At eight o'clock on Thursday morning... Arthur didn't feel very good.""" >>> tokens = nltk.word_tokenize(sentence) >>> tokens ['At', 'eight', "o'clock", 'on', 'Thursday', 'morning', 'Arthur', 'did', "n't", 'feel', 'very', 'good', '.'] >>> tagged = nltk.pos_tag(tokens) >>> tagged[0:6] [('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'), ('Thursday', 'NNP'), ('morning', 'NN')]

>>> from nltk.book import * *** Introductory Examples for the NLTK Book *** Loading text1,..., text9 and sent1,..., sent9 Type the name of the text or sentence to view it. >>> text1 >>> type(text1) >>> help(text1.concordance) Help on method concordance in module nltk.text: concordance(self, word, width=79, lines=25) method of nltk.text.Text instance Print a concordance for ``word`` with the specified context window. Word matching is not case-sensitive. :seealso: ``ConcordanceIndex`` >>> text1.concordance("monstrous") Displaying 11 of 11 matches: ong the former, one was of a most monstrous size. …

>>> from nltk.corpus import reuters >>> help(reuters.categories) Help on method categories in module nltk.corpus.reader.api: categories(self, fileids=None) method of nltk.corpus.reader.plaintext.CategorizedPlaintextCorpusReader instance Return a list of the categories that are defined for this corpus, or for the file(s) if it is given. >>> reuters.categories() [u'acq', u'alum', u'barley', u'bop', u'carcass', u'castor-oil', u'cocoa', u'coconut', u'coconut-oil', u'coffee', u'copper', u'copra-cake', u'corn', u'cotton', u'cotton-oil', u'cpi', u'cpu', u'crude', u'dfl', u'dlr', u'dmk', u'earn', u'fuel', u'gas', u'gnp', u'gold', u'grain', u'groundnut', u'groundnut-oil', u'heat', u'hog', u'housing', u'income', u'instal-debt', u'interest', u'ipi', u'iron-steel', u'jet', u'jobs', u'l-cattle', u'lead', u'lei', u'lin-oil', u'livestock', u'lumber', u'meal-feed', u'money-fx', u'money-supply', u'naphtha', u'nat-gas', u'nickel', u'nkr', u'nzdlr', u'oat', u'oilseed', u'orange', u'palladium', u'palm-oil', u'palmkernel', u'pet-chem', u'platinum', u'potato', u'propane', u'rand', u'rape-oil', u'rapeseed', u'reserves', u'retail', u'rice', u'rubber', u'rye', u'ship', u'silver', u'sorghum', u'soy-meal', u'soy-oil', u'soybean', u'strategic-metal', u'sugar', u'sun-meal', u'sun-oil', u'sunseed', u'tea', u'tin', u'trade', u'veg-oil', u'wheat', u'wpi', u'yen', u'zinc'] >>>