Upload
medhat-dawoud
View
2.012
Download
0
Embed Size (px)
DESCRIPTION
Citation preview
How To Python*Medhat dawoud
Software Junior Developer
[email protected]://med7at.wordpress.com
* Program with pythonOctober 12,2010 1
2
Python?
Father Guido Van Rossum
Birth-year 1989
Born at Amsterdam
October 12,2010
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
4
Python?Platform independent
Interpreter Language
Script Language
Supports OOPObject Oriented Programming
October 12,2010
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
6
Get Python!
http://www.python.org
DOWNLOAD
Recommended Version 2.5.X <=
On Windows
October 12,2010
7
Get Python!On Debian Linux
~# apt-get install python
~$ sudo apt-get install python
October 12,2010
8
Run Python! ~$ python
October 12,2010
9
Run Python! ~# apt-get install ipython ~# ipython
October 12,2010
10
Python SyntaxUse python as simple calculator
>>> 1 + 2>>> 6 * 8>>> 6.0 * 8>>> 2 ^ 10>>> 2 ** 10>>> _ / 2>>> __ / 4>>> _
October 12,2010
11
Python SyntaxPrint the “Hello world!”
>>> print “Hello World!”
>>> print(“Hello World!”)
October 12,2010
12
Python Syntax Multiline Text
Single Quote
INDENTATION!!
October 12,2010
13
Python Syntax
Indentation is also Syntax!!!
October 12,2010
14
Python Syntax
You MUST keep the same indentation!
October 12,2010
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
16
Python Variables
Dynamic Typing
October 12,2010
17
Python Controls
if
for
while
try, except
October 12,2010
18
if
“a is three”
October 12,2010
19
for
October 12,2010
20
While
October 12,2010
21
Try, Except
October 12,2010
22
Number
7
0
7.0
0.75
5+5jOctober 12,2010
23
String
October 12,2010
24
String
October 12,2010
25
List, Tuple
October 12,2010
26
List, Tuple
October 12,2010
27
Dictionary
October 12,2010
28
Dictionary
October 12,2010
29
Dictionary
October 12,2010
30
Simple input
October 12,2010
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
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
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
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
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
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
37
You have just learned
of python!
October 12,2010
50%
38October 12,2010
39October 12,2010
Thanks