Académique Documents
Professionnel Documents
Culture Documents
:
-1
-2
-3
-4
-5
-6
-7
-8
-9
-11
-11
-12 Modules Function
-13 ()String
2
-14
-15 | List
Tuples -16
- -17 | Dictionary
-18 if
-19 else elif
-21 while
-21 For
-22 break
-23 continue
-24 Pass
-25 Function
-26 Class
-27 Inheritance
-1 :
.
3
.
:
. 3 - .
7107/2/72
-2 :
,
,
-3 :
www.ar-python.com
-4:
- (:)Python Language
( )OOP
.
.
:
-1 (.)Windows,Linux,Mac
-2 .
-3 (.)GUI Programming
-4 .
:
PROGRAM : .program
:
, , .
| Python Official Website
( )Documentation Html , PdfPython Documenation
-5 :
,
,
.
:9
Python Shell -1 .
: IDLE GUI -2 .
: Text Editor -3
.py
IDE:
: PyScripter -1
: Eclipse -2 PyDev
Netbeans -3 ,,
: python tools for visual studio -4
.
: Eric IDE -5 .
10
-6
11
Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
-7
( ):
,
( )Hello word :
)'print('Hello word
12
Hello word
-8
13
;
:
-9
,
,
14
import sys
import keyword
print ("Python version: ",
sys.version_info)
print ("Python keywords: ",
keyword.kwlist)
Python version:
(3, 2, 'final', 0)
-11
.),, , (,
15
print(2+2)
print(4-2)
print (18/3)
print(18/7)
print(18.5/6.7)
print(9%4)
print(8%4)
print(8.75%5)
print(6*6)
print(7*7*7)
print(8**3)
print(-10**3)
4
2
6.0
2.5714285714285716
2.761194029850746
1
0
3.75
36
343
512
-1000
16
-11
#
x=15
x+10
)print(x
y=4
)print(x+y
#
m=1.5
n=3.5
)print(m+n
#
"h="me
"l="you
)print(h
)print(l
:
17
15
19
5.0
me
you
Global:
global e
e=10
)print(e
18
:
19
print(pow(3,4))
print(abs(-12))
print(abs(6))
#-------------import math
print(math.floor(17.6))
print(math.sqrt(81))
#Module.function
.
:
#Use variable
t=math.sqrt
print(t(9))
20
-13 (:)String
" ".. '' .
:
" a="Ali
'b='Mohammed
)print(a
)print(b
)print(a+b
)" 'print("HI 'Moustafa
:
Ali
Mohammed
Ali Mohammed
'HI 'Moustafa
:
)(Str
21
)mm=str(44
)print("the number is " + mm
:
the number is 44
:
'!str = 'Hello World
#
#
#
#
)(str
)](str[0
)](str[2:5
)](str[2:
)(str * 2
#
(str + "TEST") #
:
22
print
print
print
print
print
print
Hello World!
H
llo
llo World!
Hello World!Hello World!
Hello World!TEST
: -14
23
5 :
-1
-2
-3 | List
Tuple -4
-5 | Dictionary
-1 | :List
][
.
24
)print (list
print
print
print
print
(list[0])
(list[1:3])
#
(list[2:])
#
(smalllist * 2) #
(list + smalllist)
25
:Tuples -2
Tuples
.
)print (tuple
#
)]print (tuple[0
#
)]print (tuple[1:3
#
)]print (tuple[2:
#
)print (tinytuple * 2
#
)print (tuple + tinytuple
26
-3 | :Dictionary
-.
)]'print (dict['code
#
)print (dict
#
))(print (dict.keys
#
print (dict.values()) #
john
6734
{'dept': 'sales', 'code': 6734, 'ali':
}''john
]'['dept', 'code', 'ali
]'['sales', 6734, 'john
27
-15 : if
.
x=4
if x==4:
)print(x
28
6 O
.Y
29
-17 : while
.
i = 4
while i < 9:
)print(i
i = i+2
x I 9
4
6
8
:
.
30
-18 :For
:
Python
P
y
t
h
o
n
31
: break -19
For,While
H
Current Letter : P
Current Letter : y
Current Letter : t
32
-21 : continue
Continue ,
While , For.
Python
H
P
y
t
o
n
33
:
:
:
:
:
Letter
Letter
Letter
Letter
Letter
Current
Current
Current
Current
Current
:
Else .
34
-21 : Pass
(, )null operation
.
35
-22 : Function
Function Def .
Function myname str
.
Function
def myname(str):
)print(str
#Call function
)'myname('moustafa
moustafa
36
Function
def num(x,y):
)print(x+y
)num(3,4
37
-23 :Class
) (oop Clases
Class Class :
class example:
def myname(self,name):
)print(name
)(res=example
)'res.myname ('Moustafa
38
res
Function
:
Moustafa
39
: 2
Function
Class
(,,,)
class num1:
def add(self,x,y):
)print(x+y
def sub(self,x,y):
)print(x-y
def div(self,x,y):
)print(x/y
def mul(self,x,y):
)print(x*y
)(result=num1
)(2,2
)(4,2
)(2,2
)(4,2
result.add
result.div
result.mul
result.sub
4
2
4
2
41
: Inheritance -24
Class
. Class
class Parent:
def myMethod2(self):
print (' parent ')
class Child(Parent):
def myMethod(self):
print (' child ')
c = Child()
c.myMethod2()
c.myMethod()
42
parent
child
43
License
http://creativecommons.org/licenses/by-nc-nd/3.0
44
45