Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Python

Similar presentations


Presentation on theme: "Introduction to Python"— Presentation transcript:

1 Introduction to Python

2 What is Python (1)? It’s one of the most popular dynamic programming languages It’s a general purpose programming language It’s used for just about everything It’s syntax looks similar to C or Pascal with a few exceptions It’s dynamically typed It’s interpreted

3 What is Python (2)? It is object-oriented
There is an extensive standard library with over 100 modules and growing Regular expressions, mathematical functions, operating system calls, network programming and just about everything else There are many 3rd party modules too supplying GUI toolkits and interfaces to relational databases

4 Who uses Python? Google has millions of lines of Python code
It’s probably more popular than ASP.NET or PHP. Yahoo maps and groups Industrial Light & Magic And the list goes on

5 Python Variables In this regard, Python is truly object-oriented
Every variable is an object Variables can be used before they are declared Numbers are of two types (integers and floating point numbers) myInt = 7 myFloat = 7.0 String are defined with either single or double quotes myString = “hello”

6 Notes about the Examples
Note that many of the examples in these slides were used from

7 Python Expressions They work the same as expressions in most other languages although you cannot mix operators between numbers and strings

8 Python Lists Python implements arrays as lists
They can contain any type of variables They are easy to iterate Elements can be accessed via an index

9 Python Strings There are a number of functions that operate on strings
Strings also have methods like index, count, upper, lower and so on As in JavaScript + is the strong concatenation operator

10 Python Blocks Here, Python differs from other languages
Indentation is used to define code blocks instead of braces

11 Python Loops Like most languages, there are for and while loops

12 Python Functions Python functions are defined using the def keyword
Functions can have zero, one, or many arguments Functions can return a value

13 Python Functions (Calling)
Call a function by specifying the function name, followed by () Arguments appear between the () Example to call the function declared in the previous slide Python also works with a variable number of arguments

14 Python Modules Modules are Python files that implement one or more functions One modules imports another module via the import keyword You can create your own modules by creating a new .py file with the module name.

15 Python Exception Handling
Exceptions happen you a statement tries to do the impossible Python uses the try syntax to handle exceptions

16 They Python Standard Library
The following link documents the Python standard library

17 Some Interesting Python Constructs (1)
Sets are lists with no duplicate entries They operate on the notion of set theory There are many set methods like intersection, symmetric_difference and difference

18

19


Download ppt "Introduction to Python"

Similar presentations


Ads by Google