114
. . . . . . Προγραμματισμός Γλώσσες σεναρίων Προγραμματισμός GUI Finale Η χρήση της Python και της Perl ως γλώσσες διδασκαλίας προγραμματισμού Απόστολος Συρόπουλος Greek Molecular Computing Group Ξάνθη [email protected] 23 Ιανουαρίου 2013 Ξάνθη

Η χρήση της Python και της Perl ως γλώσσες διδασκαλίας προγραμματισμού

Embed Size (px)

DESCRIPTION

Proposing the use of Perl and Python as vehicles of teaching programming to high school students.

Citation preview

GUI

Finale

Python Perl

Greek Molecular Computing Group [email protected]

23 2013

.

.

.

.

.

.

GUI

Finale

GUI Finale

.

.

.

.

.

.

GUI

Finale

;

.

.

.

.

.

.

GUI

Finale

; ;

.

.

.

.

.

.

GUI

Finale

; ;

;

.

.

.

.

.

.

GUI

Finale

; ;

;

;

.

.

.

.

.

.

GUI

Finale

; ;

;

; :

;

.

.

.

.

.

.

GUI

Finale

;

.

.

.

.

.

.

GUI

Finale

; Computer programming is composing/authoring of a

process/procedure for doing something, but in incredible detail.

.

.

.

.

.

.

GUI

Finale

; Computer programming is composing/authoring of a

process/procedure for doing something, but in incredible detail. Programming is the art and science of translating a set of ideas into a programa list of instructions a computer can follow.

.

.

.

.

.

.

GUI

Finale

; Computer programming is composing/authoring of a

process/procedure for doing something, but in incredible detail. Programming is the art and science of translating a set of ideas into a programa list of instructions a computer can follow. Programming is planning how to solve a problem. No matter what method is usedpencil and paper, slide rule, adding machine, or computerproblem solving requires programming. Of course, how one programs depends on the device one uses in problem solving.

.

.

.

.

.

.

GUI

Finale

; Computer programming is composing/authoring of a

process/procedure for doing something, but in incredible detail. Programming is the art and science of translating a set of ideas into a programa list of instructions a computer can follow. Programming is planning how to solve a problem. No matter what method is usedpencil and paper, slide rule, adding machine, or computerproblem solving requires programming. Of course, how one programs depends on the device one uses in problem solving. A program is a list of instructions, together with any fixed information required to carry out those instructions. This applies to computers, of course, but also to any other subject that involves fixed instructions.. . . . . .

GUI

Finale

; Computer programming is composing/authoring of a

process/procedure for doing something, but in incredible detail. Programming is the art and science of translating a set of ideas into a programa list of instructions a computer can follow. Programming is planning how to solve a problem. No matter what method is usedpencil and paper, slide rule, adding machine, or computerproblem solving requires programming. Of course, how one programs depends on the device one uses in problem solving. A program is a list of instructions, together with any fixed information required to carry out those instructions. This applies to computers, of course, but also to any other subject that involves fixed instructions. !. . . . . .

GUI

Finale

;

.

.

.

.

.

.

GUI

Finale

; David Hilbert

.

.

.

.

.

.

.

GUI

Finale

; David Hilbert

. Kurt

Friedrich Gdel Hilbert !

.

.

.

.

.

.

GUI

Finale

; David Hilbert

. Kurt

Friedrich Gdel Hilbert ! Hilbert

.

.

.

.

.

.

GUI

Finale

; David Hilbert

. Kurt

Friedrich Gdel Hilbert ! Hilbert ,

.

.

.

.

.

.

GUI

Finale

; David Hilbert

. Kurt

Friedrich Gdel Hilbert ! Hilbert , (perspective)

.

.

.

.

.

.

GUI

Finale

; David Hilbert

. Kurt

Friedrich Gdel Hilbert ! Hilbert , (perspective) Form versus Function.

.

.

.

.

.

.

GUI

Finale

; David Hilbert

. Kurt

Friedrich Gdel Hilbert ! Hilbert , (perspective) Form versus Function.

(formal language).

.

.

.

.

.

.

GUI

Finale

(1997)

.

.

.

.

.

.

GUI

Finale

(1997) Brian Harvey: When I wrote the first edition of this

book, in 1984, it was controversial to suggest that not everyone has to learn to program.

.

.

.

.

.

.

GUI

Finale

(1997) Brian Harvey: When I wrote the first edition of this

book, in 1984, it was controversial to suggest that not everyone has to learn to program. I was accused of elitism, of wanting to keep

computers as a tool for the rich, while condemning poorer students to dead-end jobs.

.

.

.

.

.

.

GUI

Finale

(1997) Brian Harvey: When I wrote the first edition of this

book, in 1984, it was controversial to suggest that not everyone has to learn to program. I was accused of elitism, of wanting to keep

computers as a tool for the rich, while condemning poorer students to dead-end jobs. Today its more common that I have to fight the

opposite battle, trying to convince people why anyone should learn about computer programming.

.

.

.

.

.

.

GUI

Finale

(1997) Brian Harvey: When I wrote the first edition of this

book, in 1984, it was controversial to suggest that not everyone has to learn to program. I was accused of elitism, of wanting to keep

computers as a tool for the rich, while condemning poorer students to dead-end jobs. Today its more common that I have to fight the

opposite battle, trying to convince people why anyone should learn about computer programming. After all, there is all that great software out there;

instead of wasting time on programming, Im told, kids should learn to use Microsoft Word or Adobe Illustrator or Macromind Director.

.

.

.

.

.

.

GUI

Finale

(1997) .

.

.

.

.

.

.

GUI

Finale

(1997) . At the same time, kids whove grown up with

intricate and beautifully illustrated video games are frustrated by the relatively primitive results of their own first efforts at programming.

.

.

.

.

.

.

GUI

Finale

(1997) . At the same time, kids whove grown up with

intricate and beautifully illustrated video games are frustrated by the relatively primitive results of their own first efforts at programming. A decade ago it was thrilling to be able to draw a

square on a computer screen; today you can do that with two clicks of a mouse.

.

.

.

.

.

.

GUI

Finale

(1997) . At the same time, kids whove grown up with

intricate and beautifully illustrated video games are frustrated by the relatively primitive results of their own first efforts at programming. A decade ago it was thrilling to be able to draw a

square on a computer screen; today you can do that with two clicks of a mouse. ;

.

.

.

.

.

.

GUI

Finale

.

.

.

.

.

.

GUI

Finale

, ,

.

.

.

.

.

.

GUI

Finale

, ,

.

.

.

.

.

.

GUI

Finale

, ,

.

.

.

.

.

.

GUI

Finale

, ,

,

.

.

.

.

.

.

.

GUI

Finale

, ,

,

.

/ .

.

.

.

.

.

.

GUI

Finale

LOGO;

.

.

.

.

.

.

GUI

Finale

LOGO; LOGO

, , GeomLab (http://www.cs.ox.ac.uk/geomlab/home.html).

.

.

.

.

.

.

GUI

Finale

LOGO; LOGO

, , GeomLab (http://www.cs.ox.ac.uk/geomlab/home.html).

!

.

.

.

.

.

.

GUI

Finale

LOGO; LOGO

, , GeomLab (http://www.cs.ox.ac.uk/geomlab/home.html).

! , Koch,

.

.

.

.

.

.

.

GUI

Finale

LOGO; ()

.

.

.

.

.

.

GUI

Finale

LOGO; () :

to koch :depth :size if :depth = 0 [fd :size stop] koch :depth-1 :size/3 lt 60 koch :depth-1 :size/3 rt 120 koch :depth-1 :size/3 lt 60 koch :depth-1 :size/3 end

.

.

.

.

.

.

GUI

Finale

LOGO; () :

to koch :depth :size if :depth = 0 [fd :size stop] koch :depth-1 :size/3 lt 60 koch :depth-1 :size/3 rt 120 koch :depth-1 :size/3 lt 60 koch :depth-1 :size/3 end Koch.. . . . . .

GUI

Finale

LOGO; ()

.

.

.

.

.

.

GUI

Finale

LOGO; ()

, .. :

.

.

.

.

.

.

GUI

Finale

LOGO; ()

, .. :

.. . . . . .

GUI

Finale

scripting languages;

.

.

.

.

.

.

GUI

Finale

scripting languages; Unix

.

.

.

.

.

.

.

GUI

Finale

scripting languages; Unix

.

.

.

.

.

.

.

.

GUI

Finale

scripting languages; Unix

.

. Perl Python

.

.

.

.

.

.

.

GUI

Finale

scripting languages; Unix

.

. Perl Python

.

. : $x="string"; print "$x\n"; $x=34; print "$x\n";. . . . . .

GUI

Finale

scripting languages

.

.

.

.

.

.

GUI

Finale

scripting languages

.

.

.

.

.

.

.

GUI

Finale

scripting languages

. (bytecode).

.

.

.

.

.

.

GUI

Finale

scripting languages

. (bytecode). .

.

.

.

.

.

.

GUI

Finale

scripting languages

. (bytecode). .

.

.

.

.

.

.

.

GUI

Finale

scripting languages

. (bytecode). .

. .

.

.

.

.

.

.

GUI

Finale

scripting languages

. (bytecode). .

. . (array,

..).

.

.

.

.

.

.

GUI

Finale

scripting languages

. (bytecode). .

. . (array,

..). Rapid prototyping.

.

.

.

.

.

.

GUI

Finale

scripting languages

.

.

.

.

.

.

GUI

Finale

scripting languages H Perl Larry Wall.

.

.

.

.

.

.

GUI

Finale

scripting languages H Perl Larry Wall. H Python Guido van Rossum.

.

.

.

.

.

.

GUI

Finale

scripting languages H Perl Larry Wall. H Python Guido van Rossum. H Ruby Yukihiro Matz Matsumoto.

.

.

.

.

.

.

GUI

Finale

scripting languages H Perl Larry Wall. H Python Guido van Rossum. H Ruby Yukihiro Matz Matsumoto. H JavaScript

Brendan Eich Netscape Mocha.

.

.

.

.

.

.

GUI

Finale

scripting languages H Perl Larry Wall. H Python Guido van Rossum. H Ruby Yukihiro Matz Matsumoto. H JavaScript

Brendan Eich Netscape Mocha. PHP Rasmus Lerdorf.

.

.

.

.

.

.

GUI

Finale

scripting languages H Perl Larry Wall. H Python Guido van Rossum. H Ruby Yukihiro Matz Matsumoto. H JavaScript

Brendan Eich Netscape Mocha. PHP Rasmus Lerdorf. Tcl John Ousterhout.

.

.

.

.

.

.

GUI

Finale

scripting languages H Perl Larry Wall. H Python Guido van Rossum. H Ruby Yukihiro Matz Matsumoto. H JavaScript

Brendan Eich Netscape Mocha. PHP Rasmus Lerdorf. Tcl John Ousterhout. AWK Alfred Aho, Peter Weinberger Brian

Kernighan.

.

.

.

.

.

.

GUI

Finale

scripting languages H Perl Larry Wall. H Python Guido van Rossum. H Ruby Yukihiro Matz Matsumoto. H JavaScript

Brendan Eich Netscape Mocha. PHP Rasmus Lerdorf. Tcl John Ousterhout. AWK Alfred Aho, Peter Weinberger Brian

Kernighan. Unix (.. bash, tcsh ..).

.

.

.

.

.

.

GUI

Finale

scripting languages H Perl Larry Wall. H Python Guido van Rossum. H Ruby Yukihiro Matz Matsumoto. H JavaScript

Brendan Eich Netscape Mocha. PHP Rasmus Lerdorf. Tcl John Ousterhout. AWK Alfred Aho, Peter Weinberger Brian

Kernighan. Unix (.. bash, tcsh ..). Scala Martin Odersky

.. . . . . .

GUI

Finale

Perl

.

.

.

.

.

.

GUI

Finale

Perl#!/usr/perl5/5.14.0/bin/perl -w @A = (); while($x=) { push(@A,$x); } $sum = 0; $i = 0; foreach $k (@A) { $sum += $k; $i++; } print $sum/$i;

.

.

.

.

.

.

GUI

Finale

Python

.

.

.

.

.

.

GUI

Finale

Python#!/opt/gnu/python3/bin/python from array import * A = array('f',[]) while 1: try: x = input() except EOFError: break A.append(float(x)) sum = 0 i = 0 for k in A: sum += k i += 1 print sum/i. . . . . .

GUI

Finale

Ruby

.

.

.

.

.

.

GUI

Finale

Ruby#!/usr/bin/ruby A = Array.new while true begin x = gets.chomp.to_f rescue break end A.push x end sum = 0; i = 0 A.each do |k| sum += k; i+=1 end puts sum/i. . . . . .

GUI

Finale

GUI;

.

.

.

.

.

.

GUI

Finale

GUI;

.

.

.

.

.

.

.

GUI

Finale

GUI;

. GUI

GUI .

.

.

.

.

.

.

GUI

Finale

GUI;

. GUI

GUI .

GUI !

.

.

.

.

.

.

GUI

Finale

GUI;

. GUI

GUI .

GUI ! GUI:

.

.

.

.

.

.

GUI

Finale

GUI;

. GUI

GUI .

GUI ! GUI: wxWidgets.

.

.

.

.

.

.

GUI

Finale

GUI;

. GUI

GUI .

GUI ! GUI: wxWidgets. Qt.

.

.

.

.

.

.

GUI

Finale

GUI;

. GUI

GUI .

GUI ! GUI: wxWidgets. Qt. Gimp GTK+.

.

.

.

.

.

.

GUI

Finale

GUI;

. GUI

GUI .

GUI ! GUI:

wxWidgets. Qt. Gimp GTK+. Tk Tcl.

.

.

.

.

.

.

GUI

Finale

Tk Python

.

.

.

.

.

.

GUI

Finale

Tk Python#!/usr/bin/ruby from tkinter import * top = Tk() F = Frame(top) F.pack() lHello = Label(F,text=" ") lHello.pack() bQuit = Button(F,text="",command=F.quit) bQuit.pack() top.mainloop()

.

.

.

.

.

.

GUI

Finale

Tk Python#!/usr/bin/ruby from tkinter import * top = Tk() F = Frame(top) F.pack() lHello = Label(F,text=" ") lHello.pack() bQuit = Button(F,text="",command=F.quit) bQuit.pack() top.mainloop()

.

.

.

.

.

.

GUI

Finale

pygame

.

.

.

.

.

.

GUI

Finale

pygame (modules)

.

.

.

.

.

.

.

GUI

Finale

pygame (modules)

.

.

.

.

.

.

.

.

GUI

Finale

pygame (modules)

.

. X

, Y .

.

.

.

.

.

.

GUI

Finale

pygame (modules)

.

. X

, Y . ,

.

.

.

.

.

.

.

GUI

Finale

pygame (modules)

.

. X

, Y . ,

.

.

.

.

.

.

.

.

GUI

Finale

.

.

.

.

.

.

GUI

Finale

import sys, pygame pygame.init() size = width, height = 640, 480 speed = [1, 1]; color = 128, 255, 0 screen = pygame.display.set_mode(size) ball = pygame.image.load("ball.gif") ballrect = ball.get_rect() while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() ballrect = ballrect.move(speed) if ballrect.left < 0 or ballrect.right > width: speed[0] = -speed[0] if ballrect.top < 0 or ballrect.right > height: speed[1] = -speed[1] screen.fill(color); screen.blit(ball, ballrect) pygame.display.flip(). . . . . .

GUI

Finale

.

.

.

.

.

.

GUI

Finale

.

.

.

.

.

.

GUI

Finale

GTK+

.

.

.

.

.

.

GUI

Finale

GTK+ GTK+ GIMP

GUI .

.

.

.

.

.

.

GUI

Finale

GTK+ GTK+ GIMP

GUI . GTK+

C/C++, Perl Python, .

.

.

.

.

.

.

GUI

Finale

GTK+ GTK+ GIMP

GUI . GTK+

C/C++, Perl Python, . glade .

.

.

.

.

.

.

GUI

Finale

GTK+ GTK+ GIMP

GUI . GTK+

C/C++, Perl Python, . glade . ,

.

.

.

.

.

.

.

GUI

Finale

GTK+ GTK+ GIMP

GUI . GTK+

C/C++, Perl Python, . glade . ,

. GTK+

GNOME.

.

.

.

.

.

.

GUI

Finale

Gtk2-Perl

.

.

.

.

.

.

GUI

Finale

Gtk2-Perl#!/opt/gnu/perl5/5.14.0/bin/perl use utf8; use Gtk2 -init; use strict; my $quit = sub { exit }; my $window = Gtk2::Window->new; $window->signal_connect('delete_event', $quit); $window->set_position('center'); $window->set_border_width(8); $window->set_title(' !'); $window->set_default_size(200, 100); my $label = Gtk2::Label->new(' !'); my $button = Gtk2::Button->new_from_stock('gtk-quit'); $button->signal_connect('clicked', $quit); my $vbox = Gtk2::VBox->new; $vbox->set_spacing(8); $vbox->pack_start($label, 1, 1, 0); $vbox->pack_start($button, 0, 0, 0); $window->add($vbox); $window->show_all; Gtk2->main;. . . . . .

GUI

Finale

Gtk2-Perl

.

.

.

.

.

.

GUI

Finale

Gtk2-Perl

.

.

.

.

.

.

GUI

Finale

Gtk2-Perl

:my $label = Gtk2::Label->new(); $label->set_markup( " !");. . . . . .

GUI

Finale

Finale!

.

.

.

.

.

.

GUI

Finale

Finale!

.

.

.

.

.

.

GUI

Finale

Finale!

.

.

.

.

.

.

.

GUI

Finale

Finale!

.

.

.

.

.

.

.

.

GUI

Finale

Finale!

.

.

.

.

.

.

.

.

.

GUI

Finale

Finale!

.

.

.

!

.

.

.

.

.

.