0% found this document useful (0 votes)
89 views

Introduction To Python: A Readable, Dynamic, Pleasant, Flexible, Fast and Powerful Language

This document provides an introduction to the Python programming language. It covers Python's background and features, including that it is multi-purpose, object oriented, interpreted, strongly and dynamically typed. It also discusses Python's syntax, types, operators, control flow, functions, classes, imports, error handling, documentation tools, and frameworks. The document concludes by mentioning additional Python concepts to explore further and thanking the audience.

Uploaded by

Venu Gadadasu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views

Introduction To Python: A Readable, Dynamic, Pleasant, Flexible, Fast and Powerful Language

This document provides an introduction to the Python programming language. It covers Python's background and features, including that it is multi-purpose, object oriented, interpreted, strongly and dynamically typed. It also discusses Python's syntax, types, operators, control flow, functions, classes, imports, error handling, documentation tools, and frameworks. The document concludes by mentioning additional Python concepts to explore further and thanking the audience.

Uploaded by

Venu Gadadasu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 64

Introduction to Python

A readable, dynamic, pleasant,


flexible, fast and powerful language

Nowell Strite
Manager of Tech Solutions @ PBS
[email protected]
Overview
• Background
• Syntax
• Types / Operators / Control Flow
• Functions
• Classes
• Tools
What is Python

• Multi-purpose (Web, GUI, Scripting, etc.)


• Object Oriented
• Interpreted
• Strongly typed and Dynamically typed
• Focus on readability and productivity
Features

• Batteries Included
• Everything is an Object
• Interactive Shell
• Strong Introspection
• Cross Platform
• CPython, Jython, IronPython, PyPy
Who Uses Python
• Google
• PBS
• NASA
• Library of Congress
• the ONION
• ...the list goes on...
Releases
• Created in 1989 by Guido Van Rossum
• Python 1.0 released in 1994
• Python 2.0 released in 2000
• Python 3.0 released in 2008
• Python 2.7 is the recommended version
• 3.0 adoption will take a few years
Syntax
Hello World

hello_world.py
Indentation

• Most languages don’t care about


indentation
• Most humans do
• We tend to group similar things together
Indentation

The else here actually belongs to the 2nd if statement


Indentation

The else here actually belongs to the 2nd if statement


Indentation

I knew a coder like this


Indentation

You should always be explicit


Indentation

Text

Python embraces indentation


Comments
Types
Strings
Numbers
Null
Lists
Lists
Dictionaries
Dictionary Methods
Booleans
Operators
Arithmetic
String Manipulation
Logical Comparison
Identity Comparison
Arithmetic Comparison
Control Flow
Conditionals
For Loop
Expanded For Loop
While Loop
List Comprehensions
• Useful for replacing simple for-loops.
Functions
Basic Function
Function Arguments
Arbitrary Arguments
Fibonacci
Fibonacci Generator
Classes
Class Declaration
Class Attributes
• Attributes assigned at class declaration
should always be immutable
Class Methods
Class Instantiation &
Attribute Access
Class Inheritance
Python’s Way
• No interfaces
• No real private attributes/functions
• Private attributes start (but do not end)
with double underscores.
• Special class methods start and end with
double underscores.
• __init__, __doc__, __cmp__, __str__
Imports

• Allows code isolation and re-use


• Adds references to
variables/classes/functions/etc. into current
namespace
Imports
More Imports
Error Handling
Documentation
Docstrings
Tools
Web Frameworks
• Django
• Flask
• Pylons
• TurboGears
• Zope
• Grok
IDEs

• Emacs
• Vim
• Komodo
• PyCharm
• Eclipse (PyDev)
Package Management
Resources

• http://python.org/
• http://diveintopython.org/
• http://djangoproject.com/
Example
Going Further

• Decorators
• Context Managers
• Lambda functions
• Generators
• ...
Questions?
Thanks!

You might also like