1 / 64

Introduction to Python

Introduction to Python. A readable, dynamic, pleasant, flexible, fast and powerful language. Nowell Strite Manager of Tech Solutions @ PBS nowell@strite.org. Overview. Background Syntax Types / Operators / Control Flow Functions Classes Tools. What is Python.

sclafani
Télécharger la présentation

Introduction to Python

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Python • A readable, dynamic, pleasant, • flexible, fast and powerful language Nowell Strite Manager of Tech Solutions @ PBS nowell@strite.org

  2. Overview • Background • Syntax • Types / Operators / Control Flow • Functions • Classes • Tools

  3. What is Python • Multi-purpose (Web, GUI, Scripting, etc.) • Object Oriented • Interpreted • Strongly typed and Dynamically typed • Focus on readability and productivity

  4. Features • Batteries Included • Everything is an Object • Interactive Shell • Strong Introspection • Cross Platform • CPython, Jython, IronPython, PyPy

  5. Who Uses Python • Google • PBS • NASA • Library of Congress • the ONION • ...the list goes on...

  6. 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

  7. Syntax

  8. Hello World hello_world.py

  9. Indentation • Most languages don’t care about indentation • Most humans do • We tend to group similar things together

  10. Indentation The else here actually belongs to the 2nd if statement

  11. Indentation The else here actually belongs to the 2nd if statement

  12. Indentation I knew a coder like this

  13. Indentation You should always be explicit

  14. Indentation Text Python embraces indentation

  15. Comments

  16. Types

  17. Strings

  18. Numbers

  19. Null

  20. Lists

  21. Lists

  22. Dictionaries

  23. Dictionary Methods

  24. Booleans

  25. Operators

  26. Arithmetic

  27. String Manipulation

  28. Logical Comparison

  29. Identity Comparison

  30. Arithmetic Comparison

  31. Control Flow

  32. Conditionals

  33. For Loop

  34. Expanded For Loop

  35. While Loop

  36. List Comprehensions • Useful for replacing simple for-loops.

  37. Functions

  38. Basic Function

  39. Function Arguments

  40. Arbitrary Arguments

  41. Fibonacci

  42. Fibonacci Generator

  43. Classes

  44. Class Declaration

  45. Class Attributes • Attributes assigned at class declaration should always be immutable

  46. Class Methods

  47. Class Instantiation & Attribute Access

  48. Class Inheritance

  49. 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__

  50. Imports • Allows code isolation and re-use • Adds references to variables/classes/functions/etc. into current namespace

More Related