Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multimedia Summer Camp

Similar presentations


Presentation on theme: "Multimedia Summer Camp"— Presentation transcript:

1 Multimedia Summer Camp
Jython Environment for Students

2 Python Python – a programming language
Used for years by people without formal computer science training Jython – a particular form of Python to enable cross-platform multimedia JES – Jython Environment for Students, which is a tool to develop Jython programs

3 JES A text editor for editing your programs
A window where you can command the computer using Jython functions

4 Functions To be able to call the function pickAndShow in the command window, you need to Save the program to a file Click Load button to parse functions

5 JES Commands print Example
Display a readable representation of whatever follows Example print 10 print “This is a string” print 5 + 7 print 3.0/2.0 print 3/2

6 JES Commands Common mistakes
All JES commands are case senstive. So Print, PRINT, and pRiNt will not work. The results of expressions 3/2 and 3.0/2.0 are different. print 3/ #You will get 1 print 3.0/2.0 #You will get 1.5

7 JES Commands pickAFile()
Allows you to pick a file from your disk through a popup window. The name of the chosen file is returned as a string File name consists of three parts: path: a sequence of folders containing the file base file name: the name of the file file extension: the type of the file

8 JES Commands Example: print PickAFile()
C:\zdong\temp\camp\work\soccer.jpg C:\zdong\temp\camp\work\ is the path soccer is the base file name jpg is the file extension \ is the path delimiter

9 JES Commands pickAFile is actually a function.
A function is a “box” that accepts input values, performs some calculations, and returns or outputs the results. The pair of parenthesis () following the function name is used to enclose input values. That’s why () is needed when pickAFile is called.

10 JES Commands makePicture( a_JPEG_file_name ) Example
Create a picture from a JPEG file, which has the file extension jpg. It requires one input value: a JPEG file name Example print makePicture( pickAFile() )

11 JES Commands show( picture ) Example:
Display the given picture in a popup window The picture must be created from the function makePicture. Example: show( makePicture( pickAFile() ) )

12 JES Commands Naming your data Example:
Values can be stored in a name and be retrieved later Using = to name data Example: myvalue = 12 Values are substituted for the names when the expression is evaluated. print myvalue #use print to check value

13 JES Commands Examples: result = 3 + 9 filename = “alice.jpg”
An alternative way to the statement: show( makePicture( pickAFile() ) ) filename = pickAFile() picture = makePicture( filename ) show(picture)

14 JES Commands Tips for = Don’t read = as “equals”, read it as “Becomes a name for” myvalue = 12 thus means “myvalue becomes a name for 12”. name can be reused: myvalue = 12 myvalue = 5 + 9 myvalue = “filename”

15 Functions We can also name a sequence of commands, and then just use the name to execute the sequence of commands. Such a name is called function. A Jython program is a collection of one or more functions that perform a useful task.

16 Functions def - indicates the beginning of the function definition
pickAndShow - the name of the function () - all input values should be placed in the pair of parenthesis : - indicates a block of commands is required A block is a sequence of commands with the same indentation.


Download ppt "Multimedia Summer Camp"

Similar presentations


Ads by Google