Download presentation
Presentation is loading. Please wait.
Published byDouglas Garrison Modified over 6 years ago
1
Introduction to the JES environment and basics of Python
Python programming Introduction to the JES environment and basics of Python Do show this live – lots of examples, live installation.
2
Python The programming language we will be using is called Python
It’s used by companies like Google, Industrial Light & Magic, Nextel, and others The kind of Python we’re using is called Jython (Java-based Python) We’ll be using a specific tool to make Python programming easier, called JES (Jython Environment for Students). JES 4.3 available as free download: URL to look at what companies use Python is in the book.
3
JES - Jython Environment for Students
Program area - A simple editor for programs Command area Interaction with Jython
4
Python interaction through commands
Anything you type in command area is evaluated and its value is displayed Example: >>> 8 >>> ‘spam’ ‘spam’ >>> “spam” >>> “spam and more spam” ‘spam and more spam’ >>> ‘spam’ + ‘spam’ ‘spamspam’ prompt
5
print displays the value of an expression
In many cases it makes no difference whether you use print - the result gets displayed anyway. >>> print 5 + 3 8 >>> print ‘spam’ spam >>> ‘spam’ + ‘spam’ ‘spamspam’ >>> print ‘spam’ + ‘spam’ Spamspam Note: no quotes!
6
Command Area Editing Up/down arrows walk through command history
You can edit the line at the bottom Just put the cursor at the end of the line before hitting Return/Enter.
7
Variables are names for data
Example: a= 3 b= -1 c = 2 x = 0 f = a*x*x + b*x + c
8
Variables -more examples
Variables of other types newsItem = “You’ve got spam!” Variables keep their value for the duration of a program or until they get a new value through a new assignment a = 3 b = a *2 + 5 a = 0 Up to this point the value of a is still 3, but then it changes to 0
9
Types of data Integer Floating point number Character String num = -3
answer = 62.49 Character letter = ‘5’ String note = “lol jkjk”
10
Python functions Python has a lot of built-in functions for general mathematical manipulation, eg: sqrt(4) - computes the square root of 4 ord(‘A’) - computes the ASCII code for character ‘A’ (i.e., a numeric code) str(4) – produces a string corresponding to a number Example: print (-b+sqrt(b*b - 4*a*c))/2*a
11
Special JES-Python functions
JES defines some special functions for media computation
12
Functions in general 4 ‘a’ F(a,b) side-effects F(4, ‘a’)
13
Example: sqrt() 4 sqrt(a) side-effects 2
14
Example: showInformation()
showInformation(message): message: the message to show to the user Opens a message dialog to the user showing information message showInformation(message) Pops up a new window displaying the message text
15
Exploring more functions
The JES Functions menu has functions arranged by type - check them out! Can you find a function that inputs a number? Can you find under what category pickAFile() is listed?
16
Reading Chapters 1, and Sections from “Introduction to Computing and Programming in Python” (up to page 22)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.