Академический Документы
Профессиональный Документы
Культура Документы
..
&
[1]
:
,
:
:
:
,
,
,
,
,
,
:
,
,
:
, ...
, MSc
,
: /....
()
, ' '
..
' ' .. ,
.
.. ,
.
'
( 2015-16)
'
( 2016-17)
*
1.
2.
3.
4.
5.
6.
8.
9.
10.
11.
12
13.
API
14.
(- )
*
(- )
*
(- )
*
(- )
,
.
,
,
[3]
- '
.
,
.
, ,
.
,
, ,
.
, ,
.
,
. ,
,
Python, ,
.
[4]
- '
1.
...........................12
1.1
.......... 12
1.2
................. 13
1.2.1
-
.......................................................................................... 16
1.3
/ ......................................... 16
1.3.1
/ ................................. 17
1.4
.................................................................................................. 17
1.5
......................................................................................... 18
1.5.1
1: ..................................... 18
1.5.2
2:
, . ........................ 18
2.
1.5.3
3: ....... 19
1.5.4
4: ............................................................................. 19
1.6
............................................................................................. 20
1.7
- ............................................................................. 20
...................24
2.1
/ ......................................... 24
2.1.1
.................................................................. 24
2.1.2
................................................................................ 25
2.2
..................................................................................................... 25
2.2.1
....................................................... 26
2.2.2
............................................................. 26
2.2.3
................................ 27
2.2.4
................ 28
2.2.5
:
............................................................................. 28
2.3
.................................................... 28
2.3.1
.......................................................................... 29
.............................................................................................................. 30
....................................................................................... 31
[5]
- '
3.
.............................34
3.1
..................................................................................................... 35
3.1.1
Linux .................................. 35
3.1.2
3.2
............................................................. 37
3.2.1
................................................................................ 37
3.2.2
........................................................................................ 38
3.2.3
38
3.2.4
3.1 ........................................................................................ 40
3.2.5
3.2 ........................................................................................ 40
3.2.6
...................................................... 41
3.3
, , .................. 42
3.3.1
3.3. ...................... 43
3.3.2
................................................................................. 44
3.4
() ................................................... 44
3.5
................................................ 46
3.5.1
3.6
, ......... 47
3.6.1
........................................................ 47
3.6.2
............................................ 47
............................................................................................ 48
......................................................................................................... 49
........................................................................................................ 49
4.
.......................................................................52
4.1
- .............................. 53
4.1.1
.......................................................................................... 53
4.1.2
if () ....................................................................... 53
4.1.3
4.1.4
4.2
............................................................................................... 61
4.2.1
....................................... 61
4.2.2
............................................................................................ 62
4.2.3
......................................................................... 63
4.2.4
................................................................................... 63
[6]
- '
4.2.5
4.3
................................................................. 64
.................................................... 67
4.3.1
1 .............................................................................. 67
4.3.2
2 .............................................................................. 67
4.3.3
3 .............................................................................. 67
4.3.4
4 .............................................................................. 67
4.3.5
5 .............................................................................. 67
4.3.6
6 .............................................................................. 68
4.3.7
7 .............................................................................. 68
4.3.8
8 .............................................................................. 68
4.3.9
9 .............................................................................. 68
4.3.10
10 ............................................................................ 68
........................................................................................... 68
...................................................................................... 68
........................................................................................................ 69
5.
.........................................................................72
5.1
............................................... 72
5.2
(str) ................................................................................... 73
5.3
.......................................................................... 76
5.3.1
1 ...................................... 77
5.3.2
2 ...................................... 77
5.3.3
3 .............................................. 78
5.3.4
4 .............................................. 78
5.3.5
5 .............................................. 80
5.3.6
6 .............................................. 80
5.4
...................................................................................................... 81
5.5
....................................................................................................... 82
5.6
.................................................................................................... 82
5.7
........................................................................................................ 83
5.8
...................................................................... 85
5.8.1
1: ............................ 85
5.8.2
2 .............................................................................. 85
5.8.3
3 .............................................................................. 85
5.8.4
4 .............................................................................. 85
5.8.5
5 .............................................................................. 85
[7]
- '
5.8.6
6 .............................................................................. 85
5.8.7
7: .................................. 86
5.8.8
8: ...... 86
5.8.9
9: ....................................... 87
5.8.10
10 ............................................................................ 87
5.8.11
11 ............................................................................ 87
5.8.12
12 ............................................................................ 87
5.8.13
13 ............................................................................ 87
.............................................................................................................. 87
...................................................................................... 88
........................................................................................................ 88
6.
..................................................................92
6.1
................................................. 92
6.2
................................................................................. 93
6.3
............................................................................ 94
6.4
....................................................................... 96
6.4.1
1: .............................. 96
6.4.2
2 .............................................................................. 96
6.4.3
3 .............................................................................. 97
6.4.4
4 .............................................................................. 97
6.4.5
5 .............................................................................. 97
6.4.6
6 .............................................................................. 97
6.4.7
7 .............................................................................. 97
6.4.8
8 .............................................................................. 97
6.4.9
9 .............................................................................. 97
........................................................................................................ 98
7.
.....................................................................102
7.1
................................................................................................. 102
7.1.1
7.2
...................................................... 104
.................................................................. 105
7.2.1
1 ............................................................................ 105
7.2.2
2 ............................................................................ 106
7.3
............................................................. 107
7.4
.................................................................... 108
............................................................................................... 108
[8]
- '
............................................................................................................ 109
.................................................................................... 109
- ....................................................................................... 109
8.
API ........112
8.1
................................................................................................. 112
8.2
- ...................... 112
8.2.1
.................................................. 114
8.3
8.4
................................................. 117
8.4.1
1 ............................................................................ 117
8.4.2
2 ............................................................................ 117
8.4.3
3 ............................................................................ 118
8.4.4
4: ............................... 118
8.4.5
5: .......................... 118
8.4.6
118
6:
................................................................................................................... 119
[9]
- '
[ 10 ]
- '
[ 11 ]
- '
1.
:
,
- (, ).
: , , ,
, , .
:
,
,
.
,
,
,
.
1.1
.
,
.
, , , .
,
. :
, ,
,
.
.
.
. .
.
[ 12 ]
- '
. , ()
.
.
.
.
.
.
.
.
,
.
.
1
.
,
( ) .
.
1.2
() .
( Top Down), ( -Bottom Up), (Mixed)
.
(Top Down problem solving) .
:
1. .
2.
, .
3. ,
.
.
[ 13 ]
- '
.
.
" ".
:
(1) .
(2) .
(3) .
.
.
(1) , :
(1.1) .
(1.2) ,
.
(1.3) "".
(2) ,
:
(2.1) .
(2.2) .
(2.3) .
(3) ,
:
(3.1)
.
(3.2) .
(1.1) :
(1.1.1)
.
(1.1.2) .
(1.1.3)
.
(1.2),
:
(1.2.1) .
(1.2.2) .
[ 14 ]
- '
(1.2.3)
.
,
.
.
,
.
,
.
, :
.
.
. ,
.
1.1.
.
,
.
[ 15 ]
- '
1.2.1
.
,
:
( ).
.
.
: ,
;
.
, .
.
:
;
.
.
.
: ;
;
,
.
;
.
.
(
) .
, . ,
. ,
,
, .
1.3
.
:
[ 16 ]
- '
,
. ,
.
(diagramming techniques),
.
, ,
(flow chart).
(coding),
.
.
.
,
.
Python.
.. ..
/
1.3.1
,
.
, ,
, ,
.
,
.
4.4
.. ..,
.. .. :
.. .. ..
1.4
[ 17 ]
- '
1.5
1.5.1
1:
:
:
;
;
;
;
;
,
.
.
:
.
1.
100 .
10 .
9 .
, ;
2.
.
; (>0)
, ;
1.5.2
2:
, .
5 .
:
. :
, ,
,
.
.
.
.
:
.
[ 18 ]
- '
wiki
(http://eclass.sch.gr/).
:
.
:
(http://www.0-18.gr).
,
http://www.0-18.gr/gia-paidia/nea/syntagi-gia-asfali-ploigisi-sto-internet (
16/07/2015).
, ,
, (http://www.saferinternet.gr,
16/07/2015).
:
(http://internet-safety.sch.gr/, 16/07/2015).
1.5.3
3:
quiz :
1.
.
( Cmaptool http://cmaptools.en.softonic.com/) .
2.
,
( ) :
, , ..
3.
, .
.
.
,
.
1.5.4
4:
.
, ,
( , ,
..) ,
20 25 C .
,
.
[ 19 ]
- '
.
,
.
;
;
:
,
;
:
.
1.6
1.3
..
1.7
,
( 21 ) , 9:
,
, ...,
(..), 2015.
Computer Science Unplugged: http://www.csunplugged.org (
12/07/2015).
: http://games.thinkingmyself.com/ ( 12/07/2015).
. O
Wolfram Demonstrations
Project, Stephen Wolfram.
/
, , ,
.
Wolfram CDF Player ( ).
(on-line) -browser.
http://demonstrations.wolfram.com/topics.html?Algorithms#123
15/07/2015)
:
http://www.teaching-materials.org/algorithms/ ( 05/01/2015).
[ 20 ]
- '
- .
(
05/07/2015) http://photodentro.edu.gr/lor/subject-search?locale=el
on-line https://www.gliffy.com
( 15/07/2015).
( Cmap-tool
http://cmaptools.en.softonic.com/, 15/07/2015).
[ 21 ]
- '
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
......................
..
..
..
..
[ 22 ]
- '
[ 23 ]
- '
2.
:
(, ).
,
, ,
.
2.1
,
.
()
(Waterfall model)
(Spiral model).
2.1.1
:
.
[ 24 ]
- '
2.1.2
,
...
.
,
,
" " (program development life cycle-PDLC).
,
:
.
.
.
.
.
:
) , .., , -
) , . ., , 17,
' , 18,
.
2.2
1960
.
[ 25 ]
- '
,
(programming paradigms).
:
(imperative programming).
(declarative programing).
2.2.1
,
, .
,
Cobol, Fortran, Pascal, C ..
2.2.1.1
,
goto, (
- unstructured programming).
(structured
programming), (blocks)
,
if-then-else.
(procedural programming)
, ,
, (procedures). Pascal, 1970.
(object-oriented programming)
, ,
,
.
2.2.2
- '
(Structured Query Language) ,
(RDBMS-Relational Database
Management System).
2.2.3
, ,
.
(parallel programming),
.
(event-driven programming).
, .
(events),
.
Microsoft Visual-Basic.
(visual programming). ,
,
.
(icon-based
languages), (diagram languages)
(form based languages).
Authorware Adobe,
Kodu Microsoft Alice
MIT Scratch.
(script programming)
,
.
,
.
(modular programming),
.
,
... ,
. (module)
.
,
. , ,
, .
(top down design).
[ 27 ]
- '
:
, ., , 7, 3 (7.3)
.
2.2.4
Pascal.
.
Visual Basic (http://www.microsoft.com). ,
.
C++. C. ,
.
Java. .
Python (http://python.org/about/).
, , .
Prolog (Programming in Logic). .
2.2.5
1.
, .
2. ,
.
3.
,
.
(multiparadigm
environments).
. , : Object Pascal Apple Computer, Delphi Borland 2006, C, C#, C++, Java, Eiffel, Kodu
Microsoft, AppInventor, Greenfoot.
2.3
(Object-oriented programming - OOP).
(Class),
(Objects),
(Properties) (Methods).
'
" " ., .
11 11.1 11.2.
[ 28 ]
- '
1
:
: , , ,
: ,
,
1" : : ", : 10000,
: 4, : 0 km/h, 2" :
: , : 4000, : 2, : 0 km/h. ,
1
2, .
. ,
.
2
:
: ,
: ,
1 .
, .
. ,
.
2.3.1
(.. www.sploder.com)
:
3
, 2
. 2
.
. ,
(terrains) .
:
1: , .
(
).
[ 29 ]
- '
2: .
.
.
;
.
; v
;
3:
;
; ;
4: :
;
;
;
;
,
;
;
;
;
,
,
;
5:
.
[ 30 ]
- '
, ., , 7,
3 (7.3)
, .., , -
, . ., , 17. '
18. .
[ 31 ]
- '
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
.
[ 32 ]
- '
[ 33 ]
- '
3.
:
Python
Python
Python,
, , ,
Python
.
,
, , , , ,
, , ,
.
Python.
,
, , ,
, . ,
, .
C++, Java, Perl, Ruby,
Processing.
,
.
-
"",
.
Python,
,
,
. Python
, ,
.
[ 34 ]
- '
,
,
.
Python,
,
- , ,
.
,
.
, .
.
.
, .
, .
,
.
3.1
Python, .
, :
Python
.
Python
()
.
2.7.10 Python.
To IDLE (Integrated
Development Environment) Python ,
,
, S Windows, Linux,
MAC OS X.
3.1.1
Linux
Linux Python
o. ,
(Software Centre)
( UBUNTU).
[ 35 ]
- '
3.1.2
IDLE
Python https://www.python.org/.
(2.7.10),
Windows ,
.
. :
Python IDLE ( 3.1).
3.1: IDLE
IDLE ,
. ,
,
>>>.
T Python Shell,
(
>>>)
.
:
: , !.
print,
()
.
- '
3.2
3.2.1
"_" .
,
(
barcode reader).
. Python
.
Python ,
(booleans) ( strings)
Python : (integers),
(floating point) (complex
numbers) (
' ).
3, (
).
3.14 28.2E-5, E 10,
( floats ).
, 28.2.3E-5 28.2 * 10-5.
, (-2+3j).
(boolean) , True ()
False () .
. " ".
,
Unicode.
, ' !
" !", .
.
(). 34 + 56 3.14*8.
[ 37 ]
- '
3.2.2
.
.
,
. .
.
.
. , ,
supermarket. .
"" , ,
..
.
.
. bit (0,1)
.
bits
. ,
,
, .
Python
, .
,
(, ,
, ..).
3.2.3
,
. Python
.
,
. , onoma1, onoma_2, timi, mesi_timi, embado ..
Python ,
.
= .
. To =
,
. =234
234 ( )
.
[ 38 ]
- '
print (
print a 234).
:
>>>x = 10
# 10 x
>>>print x
# x
10
>>>x=x+15
# x 15
x
>>>print x
25
>>>x=x *0.1
# x 0.1
x.
>>>print x
2.5
>>>print x*100
250.0
>>>onoma =
onoma
>>>print onoma
>>> metavliti1=metavliti2=metavliti3=15
# 15
>>>x, y=10, 18
>>>print x,y
10 20
>>>x, y, z = 10, 20,
z.
# 10 x, 20 y
>>>print x,y,z
10 20
>>>print + z
[ 39 ]
- '
3.2.4
3.1
x 12
y 20.
x (2)
( ) 12 ().
y (3) ( )
20 ().
, x ( B(2)) y
y ( (3)) x.
.
Python,
x, y
.
,
(
).
3.2.5
3.2
Python:
(
#).
arithmos, 1.234 (
).
arithmos_tetragwno,
arithmos.
arithmos,
arithmos_tetragwno.
logikh, True.
paixnidia, 10.
paixnidia,
(paixnidia == 8, paixnidia > 8, paixnidia == 8 or paixnidia ==
10, paixnidia ==9 and paixnidia == 10).
.
>>> #
>>> arithmos = 1.234
>>> arithmos_tetragwno = arithmos ** 2
>>> print arithmos, arithmos_tetragwno
: 1.234 1.522756
>>> logikh = True
>>> print logikh
: True
>>> paixnidia = 10
[ 40 ]
- '
>>> paixnidia == 8
False
>>> paixnidia == 8 or paixnidia == 10
True
>>> not paixnidia == 8
True
>>> paixnidia >= 8
True
>>> paixnidia != 8
True
>>> paixnidia <= 8
False
>>>
not, or and
.
,
.
3.2.6
,
.
.
Python.
x = 45
x = 45.5
print x
print x + x
[ 41 ]
- '
x= ""
y = ""
print "", y, "", x
print "", x + y
x = 12
print x + 3
x = 26
x = y = z = 23
print x, y, z
x = y = ""
print x, y
x , y, z = "","", 2
print x, y, z
print x, y * z
x , y = 8, 12
print x, y
a = 010
print a
a = 0xA
print a
3.3
, ,
,
Python.
(Arithmetic operations): +, -, *, /, **, %
: ==, !=, <, >, <=, >=
: not, or, and,
[ 42 ]
- '
3.3.1
P and Q
P or Q
Not P
TRUE
TRUE
TRUE
TRUE
FALSE
TRUE
FALSE
FALSE
TRUE
FALSE
FALSE
TRUE
FALSE
TRUE
TRUE
FALSE
FALSE
FALSE
FALSE
TRUE
3.3.
.
Python.
.
Python.
2+3
3560 130
5*3+2
5 * (3 + 2)
5 * (3 + 2) / 10
3 * 3.75 / 1.5
5 ** 2
3 ** 4
.......
:
,
Python;
.
.................................................................................................................................
.................................................................................................................................
.................................................................................................................................
[ 43 ]
- '
Python;
;
.
.................................................................................................................................
.................................................................................................................................
.................................................................................................................................
3.3.2
Python.
print, , : print _, print , print
, print onoma_ ()
=, :
_= .
,
,
.
_= input()
x = input(" : " )
raw_input:
name = raw_input( : )
raw_input
input . input
.
,
, #.
.
3.4
()
Python
.
Python, :
float()
.
int()
abs()
pow(a,b)
H divmod(x,y) x/y
[ 44 ]
- '
>>> float (10)
10.0
>>> int(5.678)
5
>>> abs(-45)
45
>>> divmod (10,3)
(3, 1)
>>> pow (2,3)
8
#
input()
int()
a=int(input( :))
# 2345.10
>>> print a
2345
Python.
Python (math module)
.
(module)
. ,
: >>> import math.
,
. (dot notation).
sqrt().
>>>import math
>>> riza=math.sqrt(2)
>>> print riza
1.41421356237
[ 45 ]
- '
>>> math.sqrt(3)
1.7320508075688772
>>> x=math.pi
>>> print x
3.14159265359
()
python,
.
project
.
.
.
3.5
Python. ,
( #)
.
, Python
.
( ,
).
3.5.1
3.4: Python
10 15. = (*)/2.
Python.
Python
#
10
BASH = 10
15
YPSOS = 15
(*)/2
- '
:,
:
TO EMBA :
75
Python,
.
,
.
.
3.6
3.6.1
,
(CPU) .
:
(compilers)
(interpreters).
,
.
, . ,
(source code),
, (executable).
,
.
Python
. :
(interactive mode) (script mode).
, Python
:
>>> 15 + 1
16
, >>>, (prompt)
. 15 + 1,
,
16. ,
, .
3.6.2
:
[ 47 ]
- '
, Python
. ,
( ).
,
. :
print
print SyntaxError: EOL
while scanning string literal.
,
.
. : ,
..
,
. ,
,
, . :
, .
, :
. Python
.
Print
print.
.
( ,
).
_ - .
.
(),{},[].
,
Python .
,
.
Python ( 2 3),
.
Python;
;
Python;
(boolean) ;
Python
;
[ 48 ]
- '
;
Python;
;
;
. ., o , . (2013)
Python, , .
, ., (2010), Taspython. Python B, .
Python , TasPython.
Downey, A. (2012) Think Python, How to think like a computer scientist, O
Reilly. http://www.greenteapress.com/thinkPython/.
.
Swaroop, C., H. (2013) A byte of Python,
http://www.swaroopch.com/notes/Python/ Creative Commons
Attributions ShareAlike 4.0 International License.
Ubuntu. http://ubuntu-gr.org/
.
,
( 21 ) , 9:
,
, ...,
(..), 2015.
Python, https://www.Python.org/
( 10/07/2015)
Python, http://www.Pythonschool.net/ (
09/07/2015)
, http://el.wikipedia.org/wiki/Python ( 4/07/2015)
[ 49 ]
- '
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
[ 50 ]
- '
[ 51 ]
- '
4.
:
,
, , .
Python.
Python.
.
, , , , .
Python.
,
.
, ,
. ,
:
:
.
(, , barcode, )
( , usb flash memory, DVD)
.
input(), .
: .
(, , ),
, , .
,
, ,
.
:
,
. /
, .
,
Python print.
[ 52 ]
- '
4.1
4.1.1
,
.
4.1.1.1 :
(Ohm)
V =220 Volt R= 25 ohm.
#
V = 220
R = 25
I=V/R
print (" H :", I, " A")
4.1.2
if ()
,
, if (AN)
.
if ,
if if.
If < >:
# if
#
#
a=int(input(' '))
if a<=0:
a=(-1)*a
print a
,
ifelse (AN). (TRUE)
if, ( FALSE)
else.
[ 53 ]
- '
_ :
if < >:
#
else:
#
: , ,
( )
. .
Python
elif. :
if <>:
<>
elif <2>:
<_2>
else:
<_3>
4.1.2.1
: _
.
18 ,
.
Python
age
A age >= 18 T
print("
")
else:
print("
")
_
[ 54 ]
- '
4.1.2.2 : -
) .
;
6, 10, 12, 15, 18,
20;
25;
.
) ,
.
#
test = input(' :')
if test<=20:
# if
if test>= 18:
print ' '
# 18 <= test <= 20
else:
if test >= 15:
print ' !'
# 15<= test < 18`
else:
if test >= 10:
print" . "
# 10<=<15
else:
print " .
"
# <10
else:
# test >20
print " "
[ 55 ]
- '
4.1.2.3 : - ,
32 ,
, 16
,
.
temperature = int(input(" ;
"))
if temperature >= 32:
print(" ")
elif temperature <= 16:
print("
")
else:
print(" ")
print("")
4.1.2.4 :
.
(for while)
,
. :
,
.
,
.
[ 56 ]
- '
,
.
. , for while
, Python.
for .
range().
for onoma_metavlitis in range (, , ):
1
2
..
: For
(5)
!
range
H range() Python, ,
,
.
range (, , ),
, , .
, ,
. .
4.1.3.2
range
Python . :
range(10) : [0,1,2,3,4,5,6,7,8,9].
range(1, 8) : [1,2,3,4,5,7]
range(0, 35, 5) : [0,5,10,15,20,25,30]
range(8, -1, -1) [8, 7, 6, 5, 4, 3, 2, 1, 0]
[ 57 ]
- '
4.1.3.3 : for
for
) Python
.
Python
Sum 0
sum = 0
i 1 5
for i in range(5):
x = int(input(" : " ))
Sum Sum+x
sum = x + sum
_
Sum
) Python
1+2+3+...+100
Python
Sum 0
sum = 0
i 1 100
Sum Sum+i
sum = sum + i
_
Sum
print(sum)
) Python
:
1+1*2+1*2*3++1*2*3**
[ 58 ]
- '
4.1.4
while ( <> )
O while ,
,
.
While _ <>:
1
2
.
1: ,
. .
2: while
,
.
4.1.4.1 : while
while
) , while,
2.
Python
Sum 0
sum = 0
I 1
i=1
#
#
[ 59 ]
- '
I<=100
Sum Sum+i
I i+1
_
sum = sum + i
i= i + 1
Sum
print(sum)
) while
. ,
'' ''.
# quiz
print (" ; " )
print ("1. ")
print ("2. ")
print ("3. ")
print ("4. ")
metriti = 0
reply = 0
while reply != 3:
reply = input ("
; ")
if reply != 3:
[ 60 ]
- '
print(" . ")
metriti = metriti + 1
print (" M ", metriti, " ")
4.1.4.3 :
.
thenum = random.randint(1,100)
print " 1 100."
print " ;"
guess = 0
while guess != thenum:
guess=input(" : ")
if guess>thenum:
print " "
if guess<thenum:
print " "
if guess==thenum:
print " !
4.2
.
.
.
4.2.1
.
, .
(calling) .
int()
range.
def (
define ),
[ 61 ]
- '
(:). :
def tragouda ():
print('! ! !
')
#
tragouda() #
tragouda() #
tragouda
. tragouda
, '
. ,
. ,
.
epanalave_tragouda(),
tragouda .
.
epanalave_tragouda(), 4 .
def epanalave_tragouda():
tragouda()
tragouda()
#
epanalave_tragouda()
def epanalave_4fores():
epanalave_tragouda()
epanalave_tragouda()
#
epanalave_4fores()
4.2.2
Python.
, :
[ 62 ]
- '
>>> def print2():
print ********
print ********
print ********
print ********
>>> print2()
********
********
>>> print2()
********
********
, print
.
.
, ..
_, end_def .. ,
, .
4.2.3
Python :
def
< > ( [ {
} ] ):
[ return <> ]
[ ] .
.
.
4.2.4
, , add times3
:
def add(arg1, arg2):
result = arg1+arg2
28
return result
def times3(arg):
28.5
ginomeno = 3*arg
>>> times3(10)
return ginomeno
30
[ 63 ]
- '
,
.
>>> times3(2.5)
7.5
>>> times3(python)
python python python
>>> times3( times3( 9 ) )
9 9 9 9 9 9 9 9 9
>>> times3(add(add(ab,ba), ))
abba abba abba
, , .
4.2.5
,
,
.
,
.
.
. :
,
.
, math.pi
.
, math.pow, ,
.
def ginomeno (a,b):
x=a*b
return x
print (ginomeno(5,10))
: Python (call-byvalue), ,
[ 64 ]
- '
- ,
:
def increment(a, b):
a=a+1
b=b+1
return a+b
#
z=1
w=2
q = increment( z, w )
print z, w, q
1 2 5
z, w
( ) increment,
q.
.
4.2.5.1 - 1
Python
.
printPython3, Python (3)
. printPython9,
Python (9) .
def printPython3():
def printPython9():
print Python
print Python
print Python
print Python
print Python
print Python
print Python
print Python
print Python
print Python
print Python
print Python
printPython9
;
[ 65 ]
- '
21
Python, printPython3() printPython9().
4.2.5.2 - 2 ( )
Python
def printPython3():
def printPython12():
for i in range(3):
def printPython100():
for i in range(12):
print Python
print Python
for i in range(100):
print Python
printPython
Python
:
def printPython( ____ ):
>>> printPython(3)
for i in range( N ):
>>> printPython(9)
print Python
>>> printPython(21)
>>> printPython(100)
;
;
4.2.5.3 - 3 ( )
4.2.5.4 - 4
Python
. :
#
def add(arg1, arg2):
result = arg1+arg2
return result
def times3(arg):
result = 3*arg
return result
#
add(10, 18)
add(10, 18.5)
add(Python , 3.4)
[ 66 ]
- '
times3(100)
times3(2.5)
times3(Python)
, .
4.3
4.3.1
Python
.
.
4.3.2
Python r
(2*r), (2**r)
(*r2).
, (
: ).
4.3.3
Python +=0,
A .
4.3.4
R1 R2.
R .
: .
R=R1+R2.
1/R=(1/R1)+(1/R2).
Python :
R1 R2
o ( 1
2 ) R1 R2
(
) R
R1, R2,
R.
4.3.5
Python
1+2+3+4+ 2000.
[ 67 ]
- '
4.3.6
Python
(o
.. 131, 797).
4.3.7
Python
Fibonacci.
4.3.8
Python
pow.
4.3.9
Python
50 500
3.
4.3.10 10
,
! .
!= 1, = 0
!=1*2*3*.(-1)*, >0
, >=0
.
;
if..else;
for,
.
H range(1, 40, 5) ;
for while;
while;
Python;
;
., ., o ., . (2013),
Python, , .
[ 68 ]
- '
, ., (2010), Taspython. Python B, .
Python , TasPython.
Downey, A. (2012) Think Python, How to think like a computer scientist, O
Reilly. http://www.greenteapress.com/thinkPython/.
.
Swaroop, C., H. (2013) A byte of Python,
http://www.swaroopch.com/notes/Python/ Creative Commons
Attributions ShareAlike 4.0 International License.
Ubuntu. http://ubuntu-gr.org/
.
,
( 21 ) , 9:
,
, ...,
(..), 2015.
Python, https://www.Python.org/
( 10/07/2015)
Python, http://www.Pythonschool.net/ (
09/07/2015)
Tutorial Python
Python (
03/07/2015),
https://docs.Python.org/2/tutorial/controlflow.html
[ 69 ]
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
[ 70 ]
- '
[ 71 ]
- '
5.
:
,
.
,
. Python
, , .
,
Python.
Python,
.
(tuple)
.
, .
5.1
,
.
,
.
,
.
,
.
. Python (tuples),
.
[ 72 ]
- '
. ,
.
,
.
python.
,
, , .. python
,
.
(str)
, .
, . ., , 17, '
, 14 16 .
5.2
(str)
,
,
Unicode. .
5.2.1.1 1 :
.
.
Python
a
b
a = " "
b = " "
z=a+b
z a b.
d=a*2
d a * 2.
print a
a, b, z, d
[ 73 ]
print b
- '
len()
b
print z
o b
b[1]
b[11 :
print d
15]
len(b)
15
b[1]
b[11 : 15]
python str
.
, .
python 0. len
.
>>> word = python
>>> python[0]
:.
word[:]
,
.
>>> s = Monty Python
>>> s[len(s)-1]
>>> s[0:5]
Monty
>>> s[-1]
>>> s[6:len(s)]
Python
>>> s[0:len(s)]
Monty Python
,
.
. s
: .
[ 74 ]
- '
>>> word = s
>>> a in python
>>> python.upper()
False
True
PYTHON
>>> y in python
>>> word.find(y)
True
True
>>>
monty
word
==
True
(Help)
.
: word.capitalize(), word.upper(), word.lower().
str ,
(immutable).
. word[0] = p ,
.
:
+ .
Python
, :
>>> def times( a, b ):
return a * b
>>> times( 2, 3 )
6
>>> times( python#, 3 )
python#python#python#
[ 75 ]
- '
;
Python + Python + Python = 3 * Python .
,
(lazy evaluation).
. times(
Python, Java ); ;
5.3
Python .
.
:
>>> fruits = [apple, orange]
>>> list2 = [50,60,70,80]
,
.
, .
daysofweek=
["","","","","","",""]
.
,
in len.
:
>>> list1 = [10,20,30,40]
>>> len(list1)
Apple
>>> [1,0]*4
True
-
None, ,
array = [None]*N.
: .
(immutable), .
>>>
a
[5,8,13,21,34]
>>> s[len(s)-1]
n
[ 76 ]
- '
>>> a[2]
13
>>> s = Monty
Python
>>> s[-1]
n
>>> a[2] = 0
>>> s[0:5]
>>> s[0:len(s)]
>>> print( a )
Monty
Monty Python
>>> s[6:len(s)]
>>> a[1:4]
Python
[8, 0, 21]
5.3.1
.
.
Python. ;
daysofweek=
["","","","","","",""]
>>> print " ", daysofweek[6]
:
;
:
: ..
5.3.2
.
. .
Python.
- '
z[0] = 45
print (z)
............
a = [x,y]
print (a)
print (a [1][2])
......
5.3.3
.
, print. ;
. ;
. ;
listX = [1, 2, 3]
listY = listX
print 'listX =', listX, 'list =', listY
listX[1] = 5000
print 'listX =', listX, 'list =', listY
[ 78 ]
- '
listY[2] = 100
print 'listX =', listX, 'list =', listY
..
.
.
:
append:
extend:
sort:
pop/del/remove: .
>>> a=[5,8,13,21,34]
>>> a.append(55)
>>> a.pop(2)
>>> print( a )
13
>>> a.extend( [ 1, 2, 3 ]
>>> a.pop()
55
>>> print( a )
>>> print( a )
: Python,
>>> a = [5,8,13,21,34]
>>> b = a[ : ]
>>> d = a
>>> a.pop()
# a d
34
>>> d.pop()
21
[ 79 ]
- '
>>> a[0]=a[1]=6
>>> print( a )
[6, 6, 13]
>>> print( d )
[6, 6, 13]
>>> print( b )
# b
.
, .
: :
append(X) , insert (i, x)
x i , pop(i)
i .
5.3.6
.
.
sqlist=[ ]
for x in range(1,11):
sqlist.append(x*x)
print sqlist
[ 80 ]
- '
5.4
Python
.
.
0.
, Python None.
.
>>> def newArray(size):
>>> a = newArray(5)
array = [ ]
for i in range(0,size):
>>> print( a )
array.append( 0 )
[0, 1, 0, 1, 0]
return array
Python,
0 1.
"" -
: a = 5*[0].
append +.
,
,
Python:
Python
for item in array :
print item
N = len(array)
for i in range(0, N):
print array[i]
i 0 N1
array[i]
_
Python
.
, :
>>> matrix = [ [1, 2, 3], [4,5,6], [7,8,9] ]
>>> print( matrix[0] )
[1, 2, 3]
>>> print( matrix[0][2] )
3
[ 81 ]
- '
,
.
;
append.
Python
for i in range(0,3):
i 0 2
j 0 2
a.append( [ ] )
a[i][j] 0
for j in range(0,3):
a[i].append(0)
_
. a[i, j] Python
a[ i ][ j ].
.. a[2] .
,
Python.
append pop, ()
() .
.
5.5
Python
.
.
(, ,
).
>>> myset = set( [ 1 ,2, 3, 1, 2, 3, 1, 2, 3, 8])
>>> myset
set( [8, 1, 2, 3] )
>>> myset.intersection( set( [1, 2, 90] ) )
set( [1, 2] )
5.6
(immutable),
(tuple).
.
, , , , ,
..
.
:
[ 82 ]
- '
>>> rec[1:3]
(b, 120)
(a, b, 120, r)
>>> rec[2]
120
( apple, 120 )
(built-in) Python.
.
(array)
.
Version[python] = 3.4.
,
-
. .
-
.
:
>>> dictionary = { :2, :4, :8, :16 }
>>> list(dictionary.keys() )
[A, , , ]
>>> dictionary []
8
>>> len(dictionary )
4
>>> del dictionary []
>>> del dictionary []
>>> print( dictionary )
[ 83 ]
- '
{:4, :16}
>>> dictionary [] = 32
>>> print( dictionary )
{:4, :32, :16}
>>> in dictionary
True
(del),
in.
,
[]= { : }.
,
.
. .. 1 :
Python
,
.
graph = { A: [B, C, D],
B: [D]
C: [D]
D: [B, C] }
[ 84 ]
- '
5.8
5.8.1
1:
1000,
:
)
)
)
)
) ,
.
.
5.8.2
,
push (), pop () .
5.8.3
,
enqueue (), dequeue () .
5.8.4
,
0.
.
5.8.5
100
,
. .
5.8.6
ISBN. ISSN.
000
ISBN ISSN.
: (str)
, .. ISBN, ISBN
.
[ 85 ]
- '
5.8.7
7:
.
.
0
. ,
.. 4, 6, 10, 145 100, 98, 10.
.
., .. 4, 6, 10, 10, 98, 100, 145.
5.8.8
8:
,
,
.
[ 86 ]
- '
5.8.9
9:
Python
,
abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz,
.
5.8.10 10
(
.. , RADAR)
.
5.8.11 11
.
.
sqlist=[ ]
for x in range(1,11):
sqlist.append(x*x)
print sqlist
5.8.12 12
Python
.
5.8.13 13
Python
end
. (:
).
s.
;
Python;
Python
;
-
;
;
;
[ 87 ]
- '
, ., (2010), Taspython. Python B, .
Python , TasPython.
Downey, A. (2012) Think Python, How to think like a computer scientist, O
Reilly. http://www.greenteapress.com/thinkPython/.
.
Swaroop, C., H. (2013) A byte of Python,
http://www.swaroopch.com/notes/Python/ Creative Commons
Attributions ShareAlike 4.0 International License.
Ubuntu. http://ubuntu-gr.org/
.
,
( 21 ) , 9:
,
, ...,
(..), 2015.
Python, https://www.Python.org/
( 10/07/2015)
Python, http://www.Pythonschool.net/ (
09/07/2015)
[ 88 ]
- '
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
[ 89 ]
- '
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
..
.....
[ 90 ]
[ 91 ]
- '
6.
:
.
- ,
.
, ,
.
6.1
, .
.
.
,
:
( , ) = ( , mod )
,
, 100 36:
( 100, 36 ) = ( 36, 28 ) = ( 28, 8 ) = ( 8, 4 ) = ( 4, 0 ) =
4
= 0. Python
:
Python
def times( a, b ) :
// , //
while b > 0 :
a, b = b, a % b
return a
> 0
mod
[ 92 ]
- '
_
// //
.
python , .
,
, .
6.2
.
, , ..
. ,
,
.
:
( 1.0)
Python
def linearSearch( array,
key ) :
_
// , //
found = False
for item in array :
if item == key :
found = True
_
_
return found
// //
_
1.0
.
,
.
/position.
[ 93 ]
- '
: 1
.
, 2.0 .
( 2.0)
Python
_
// , //
pos = 1
i1
i1
pos = i
< 0
i <= N
[ i ] =
i=i+1
_
ii+1
return pos
_
// //
_
Python ,
for ,
.
3.0
def linearSearch( array, key ) :
for item in array :
if item == key :
return True
return False
,
.
6.3
,
[ 94 ]
- '
. , ,
.
.
, ,
. (
) .
(selection sort). :
1:
.
2:
.
1:
.
Python :
(Selection Sort) 1.0
Python
// , //
N = len( array )
i 0 N1
for i in range(0, N) :
_(i, N)
A[ i ],
A[]
_
// //
_
.
Python
// , , //
[ 95 ]
- '
pos = start
i 1
A[ i ] < A[]
pos = i
_
_
// //
return pos
_
, 7 ,
:
i=0
0
0
1
8
2
8
3
4
4
2
5
0
6
0
6.4
i=1
i=2
2
0
5
4
3
0
2
20
20
32
32
38
38
54
54
54
60
60
90
90
98
98
4
3
98
8
90
0
6
38
8
9
8
5
i=6
2
9
32
8
5
i=5
i=4
20
0
3
i=3
0
6
60
0
6.4.1
1:
,
python.
6.4.2
,
. ;
[ 96 ]
- '
3
6.4.3
:
( 3600, _____ ) = ( 1100, _____ ) = (_____,_____ ) =
(_____, 100 ) =
(_____,_____ ) = 100
.
4
6.4.4
.
5
6.4.5
.
6
6.4.6
.
7
6.4.7
. ,
,
,
. ,
.
8
6.4.8
.
9
6.4.9
,
.
;
[ 97 ]
- '
,
( 21 ) , 9:
,
, ...,
(..), 2015.
Python, https://www.Python.org/
( 10/07/2015)
[ 98 ]
- '
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
[ 99 ]
- '
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
[ 100 ]
[ 101 ]
- '
7.
(8 )
:
(.. ) (open, close,
read, write) Python.
-
, , , ,
, , ,
:
, DVD (flash
memory).
: .
: .
: .
:
.
:
.
7.1
( )
,
.
.
.
,
.
, DVD_ROM,
(flash memory).
Python.
,
,
.
open()
[ 102 ]
- '
.
.
X = open (_, )
# open() Python
. :
(words.txt),
.
()
. (w
, r ).
# .
.
,
. open()
.
( ,
)
a
b
(
)
r+
.
Python
, .
read(), readline() write() .
[ 103 ]
- '
open() .
, ,
.
, .
,
( "r").
,
close(), .
7.1.1
, 'w'
:
>>> keimeno = open('output.txt', 'w')
# output.txt w
keimeno, print keimeno
:
>>> print keimeno
<open file 'output.txt', mode 'w' at 0xb7eb2410>
,
. .
write() .
>>> line1 = " ! \n"
# line1 !.
>>> keimeno.write(line1)
# line1 . \n
write .
# keimeno
write .
>>> line2 = "Pythonistas.\n"
>>> keimeno.write(line2)
.
>>> keimeno.close()
[ 104 ]
- '
write . ,
, .
str:
>>> x = 52
>>> keimeno.write(str(x)).
for
.
>>> keimeno = open('output.txt', r)
open() "r",
.
read() readline().
, ,
:
>>> keimeno.readline()
7.2
7.2.1
song.txt.
, .
for i in range(telos);
song=open("song.txt", "w")
telos=int(input(" "))
# .
for i in range(telos):
print (" ",i+1, )
x = raw_input(" " )
x=x + '\n'
song.write(x)
song.close()
[ 105 ]
- '
song=open("song.txt", "r")
for line in song:
print(line)
a=line
song.close()
7.2.2
hmerologio_2015.txt
2015
calendar.
) .
IDLE Python.
. hmerologio_2015.txt
. ;
.
) ,
hmerologio_2016 2016
.
import calendar
# calendar
hmerologio=open("hmerologio_2015.txt", "w")
# hmerologio_2015
hmerologio.
hmerologio.write ("
Python:\n\n")
# .
a= calendar.TextCalendar(calendar.SUNDAY).formatyear(2015, 2, 1, 1, 2)
# a 2015,
.
hmerologio.write(a)
(
) , hmerologio
[ 106 ]
- '
hmerologio.write("\n\nPython: ...\n... .\n(
l)")
#
hmerologio.close()
# .
#
hmerologio=open("hmerologio_2015.txt","r")
# r
contents=hmerologio.read()
# read() contents,
print contents
# ( 2015) . H
.
hmerologio.close()
# , close()
7.3
( ),
,
. ,
, Python .
os
( os operating system). os.getcwd
:
>>> import os
>>> cwd = os.getcwd()
>>> print cwd /home/dinsdale
cwd current working directory.
/home/dinsdale, home
dinsdale.
[ 107 ]
- '
7.4
.
.
)
my_list = [i**2 for i in range(1,11)]
# 1 - 10
f = open("output.txt", "w")
for item in my_list:
f.write(str(item) + "\n")
f.close()
)
f = open("bg.txt")
f.closed
# False
f.close()
f.closed
# True
C)
>>> logfile = open('test.log', 'w')
>>> logfile.write('test succeeded')
>>> logfile.close()
>>> print file('test.log').read()
test succeeded
>>> logfile = open('test.log', 'a')
>>> logfile.write('line 2')
>>> logfile.close()
>>> print file('test.log').read()
test succeededline 2
D)
g = open(' new_file ', 'w')
g.write('A new file begins' )
g.write(' ... today!\n')
[ 108 ]
- '
g.close( )
E)
f = open('input_file.txt')
for line in f :
print(line )
1) ;
2)
Python,
;
3) ;
4) ;
5) ;
6) ;
. ., o , . (2013)
Python, , .
, ., (2010), Taspython. Python B, .
Python , TasPython.
Downey, A. (2012) Think Python, How to think like a computer scientist, O
Reilly. http://www.greenteapress.com/thinkPython/.
.
Swaroop, C., H. (2013) A byte of Python,
http://www.swaroopch.com/notes/Python/ Creative Commons
Attributions ShareAlike 4.0 International License.
Ubuntu. http://ubuntu-gr.org/
.
.
-
,
( 21 ) , 9:
,
, ...,
(..), 2015.
[ 109 ]
- '
Python, https://www.Python.org/
( 10/07/2015)
Berkeley, (2015), http://python.berkeley.edu/.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
[ 110 ]
- '
API
[ 111 ]
- '
8. API
(13 )
:
, Application Program Interfaces (APIs)
.
8.1
Python
,
.
,
Python .
Application
Programming Interfaces (APIs) .
APIs Python
matplotlib, SeaBorn Matplotlib
ggplot
ggplot2 R.
Tkinter,
Python (GUI).
APIs
, - (web crawler/spider)
.
,
API,
.
, ,
API.
.
8.2
- '
(user interface), .
.
" - (...)"
, ,
. ( Association for Computer Machinery).
,
,
,
-.
...
(Usability).
ISO 9241,
.
:
()
(
).
-
(SAVE)
(DELETE) ,
.
,
.
.
.
, .
.
,
,
.
. ;
[ 113 ]
- '
. ()
,
.
,
( )
(
).
.
8.2.1
,
'
.
. ,
, ,
.
.
,
..
.
.
. Shneiderman (Shneiderman and
Plaisant, 2005) :
1. (consistency)
:
1) .
2) .
3) .
4) .
5) .
6) .
7) .
2. (shortcut)
1) .
2) .
3) .
3. (informative feedback)
.
[ 114 ]
- '
4.
5.
6.
7.
8.
..
.
"" -
( 72)
:
, ,
;
;
QWERTY
;
(Norman 1990):
.
, ,
.
,
.
,
.
,
.
.
.
.
8.3
Python.
import Tkinter as tk
import tkMessageBox
[ 115 ]
- '
def showInformationBox():
tkMessageBox.showinfo("Info","Nice Done")
def showOkCancelBox():
tkMessageBox.askokcancel("okCancel","Remove all System Files?")
def showWarningBox():
tkMessageBox.showwarning("warning","This is a warning")
def showErrorBox():
tkMessageBox.showerror("error","Critical System Error #00000")
root = tk.Tk()
root.title("Computer Science")
message = tk.Label( root, text = "Introduction to Computer Science" )
message.pack()
message2 = tk.Label( root, text = "This is my first program" )
message2.pack()
buttonA = tk.Button( root, text = "Click here for Information", command =
showInformationBox)
buttonA.pack()
buttonB = tk.Button( root, text = "Click here for Verification", command =
showOkCancelBox)
buttonB.pack()
buttonC = tk.Button( root, text = "Click here for Warning", command =
showWarningBox)
buttonC.pack()
buttonD = tk.Button( root, text = "Click here for Error Message", command =
showErrorBox)
buttonD.pack()
root.mainloop()
[ 116 ]
- '
root = tk.Tk()
root.title("Computer Science")
Computer Science.,
.
(Label)
. ..
buttonA = tk.Button( root, text = "Click here for Information", command =
showInformationBox)
-
buttonA. Click here for Information,
root
showInformationBox .
,
,
.
pack
root.mainLoop() .
Tkinter
Python.
8.4
8.4.1
Beautiful Soup
http://www.crummy.com/software/BeautifulSoup/
8.4.2
matplotlib http://matplotlib.org/examples. ,
, ,
, ..
,
[ 117 ]
- '
8.4.3
matplotlib,
Python
,
,
:
8.4.4
4:
,
Beautiful Soup.
Python, Yahoo Finance Scraper.
http://www.Pythoncentral.io/Python-beautiful-soup-example-yahoo-financescraper/
/ ,
scrapy, Python lxml
http://docs.Python-guide.org/en/latest/scenarios/scrape/
8.4.5
5:
7 ( ) Tkinter,
testRectangle.py.
8.4.6
6:
,
Python.
http://www.pygame.org project
. .
projects
.
[ 118 ]
- '
;
;
;
;
Application Programming
Interfaces (APIs).
Python.
. (2000) , .
.
Ben Shneiderman and Catherine Plaisant. Designing the User Interface. Pearson
Education, Boston, 4th edition, 2005
Donald A. Norman. The Design of Everyday Things. Doubleday/Currency, New
York, NY, 1990. First published as The Psychology of Everyday Things.
(2005),
,
.
http://cgi.di.uoa.gr/~ys08/EAM_simeiwseis.pdf ( 2015)
Levitin, Anany (2007), The Design & Analysis of Algorithms. Pearson Education.
Swaroop, C., H. (2013) A byte of Python,
http://www.swaroopch.com/notes/Python/ Creative Commons
Attributions ShareAlike 4.0 International License.
Ubuntu. http://ubuntu-gr.org/
.
,
( 21 ) , 9:
,
, ...,
(..), 2015
Python,
https://pypi.Python.org/pypi
http://matplotlib.org/users/pyplot_tutorial.html
http://stanford.edu/~mwaskom/software/seaborn/
https://pypi.Python.org/pypi/ggplot
http://blog.yhathq.com/posts/ggplot-for-Python.html
[ 119 ]
- '
http://bokeh.pydata.org/
Python for Data Analysis
http://dl.e-book-free.com/2013/07/Python_for_data_analysis.pdf
Python Scientific Lecture Notes
http://scipy-lectures.github.io/
Google Python
https://code.google.com/p/google-visualization-Python/
Python Beautiful Soup Example: Yahoo Finance Scraper
http://www.Pythoncentral.io/Python-beautiful-soup-example-yahoo-financescraper/
Beautiful Soup
http://www.crummy.com/software/BeautifulSoup/
http://www.gregreda.com/2013/03/03/web-scraping-101-with-Python/
http://scrapy.org/
Tkinter Python
http://www.Python-course.eu/Python_tkinter.php
https://wiki.Python.org/moin/TkInter
[ 120 ]