39
How To Python* Medhat dawoud Software Junior Developer [email protected] http://med7at.wordpress.com * Program with python October 12,2010 1

How to python

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: How to python

How To Python*Medhat dawoud

Software Junior Developer

[email protected]://med7at.wordpress.com

* Program with pythonOctober 12,2010 1

Page 2: How to python

2

Python?

Father Guido Van Rossum

Birth-year 1989

Born at Amsterdam

October 12,2010

Page 3: How to python

3

Python’s Father Guido Van Rossum

is Netherlands, who write the python programming language as a successor to the ABC programming language, in his week ends , and call it python Relative to the a British television comedy sketch on the BBC…Called “Monty Python's Flying Circus”

October 12,2010

Page 4: How to python

4

Python?Platform independent

Interpreter Language

Script Language

Supports OOPObject Oriented Programming

October 12,2010

Page 5: How to python

5

Why Python ? Easy Syntax Easy Grammar Easy Data Structure Many Packages

Very ReadableVery FlexibleUsually Short Code

Easy to Manage CodeEasy to Work Together

October 12,2010

Page 6: How to python

6

Get Python!

http://www.python.org

DOWNLOAD

Recommended Version 2.5.X <=

On Windows

October 12,2010

Page 7: How to python

7

Get Python!On Debian Linux

~# apt-get install python

~$ sudo apt-get install python

October 12,2010

Page 8: How to python

8

Run Python! ~$ python

October 12,2010

Page 9: How to python

9

Run Python! ~# apt-get install ipython ~# ipython

October 12,2010

Page 10: How to python

10

Python SyntaxUse python as simple calculator

>>> 1 + 2>>> 6 * 8>>> 6.0 * 8>>> 2 ^ 10>>> 2 ** 10>>> _ / 2>>> __ / 4>>> _

October 12,2010

Page 11: How to python

11

Python SyntaxPrint the “Hello world!”

>>> print “Hello World!”

>>> print(“Hello World!”)

October 12,2010

Page 12: How to python

12

Python Syntax Multiline Text

Single Quote

INDENTATION!!

October 12,2010

Page 13: How to python

13

Python Syntax

Indentation is also Syntax!!!

October 12,2010

Page 14: How to python

14

Python Syntax

You MUST keep the same indentation!

October 12,2010

Page 15: How to python

15

Python VariablesType Example

Number (integer, long, float …) 3, 3.141592, 31415928808L

String, Unicode “English”, u”한글” , u”Español”

Tuple (‘First’, ‘Second’, ‘Third’)

List [‘First’, ‘Second’, ‘Third’]

Dictionary {‘First’: 1, ‘Second’: 2, ‘Third’: 3}

But you don’t have to care!

October 12,2010

Page 16: How to python

16

Python Variables

Dynamic Typing

October 12,2010

Page 17: How to python

17

Python Controls

if

for

while

try, except

October 12,2010

Page 18: How to python

18

if

“a is three”

October 12,2010

Page 19: How to python

19

for

October 12,2010

Page 20: How to python

20

While

October 12,2010

Page 21: How to python

21

Try, Except

October 12,2010

Page 22: How to python

22

Number

7

0

7.0

0.75

5+5jOctober 12,2010

Page 23: How to python

23

String

October 12,2010

Page 24: How to python

24

String

October 12,2010

Page 25: How to python

25

List, Tuple

October 12,2010

Page 26: How to python

26

List, Tuple

October 12,2010

Page 27: How to python

27

Dictionary

October 12,2010

Page 28: How to python

28

Dictionary

October 12,2010

Page 29: How to python

29

Dictionary

October 12,2010

Page 30: How to python

30

Simple input

October 12,2010

Page 31: How to python

31

Do It Yourself #1

Your program should do the following1. Calculate the 224

2. Save the result to “result”3. Print the “result”

October 12,2010

Page 32: How to python

32

Do It Yourself #2

Your program should do the following1. Print out the even numbers between 1 to 1000, without line breaks2. Print out the 1000 / n When n is between -100 to 100

October 12,2010

Page 33: How to python

33

Do It Yourself #3

Your program should do the following1. Let given=“we are so friend!”2. Using slicing, concatenating, indexing, and methods, make following result

- “we are friend!”- “are WE so friend”- “so friend we are”

October 12,2010

Page 34: How to python

34

Do It Yourself #4

Your program should do the following1. Let given=range(100)2. Using the given, get the following

- Even number between 0~99- Odd number between 0~99- Multiplier of 3 between 0~50, 70~99- List starts from 99 and ends at 1

October 12,2010

Page 35: How to python

35

Do It Yourself #5Your program should do the following

1. Get the input Name and Age2. Save the Name and Age to dictionary3. If input is empty Change the input mode to search4. On search mode Print the age of given name

October 12,2010

Page 36: How to python

36

SummaryNow you know…

How to Install and Run PythonHow to Use Python as CalculatorBasic Python Syntax

(indentation, quote, multiline text…)

Python Data Structure (string, number, list, dictionary, tuple…)

Basic Input, Output to the terminal(input, raw_input, print)

October 12,2010

Page 37: How to python

37

You have just learned

of python!

October 12,2010

50%

Page 38: How to python

38October 12,2010

Page 39: How to python

39October 12,2010

Thanks