Post on 30-Dec-2015
Embed Size (px)
DESCRIPTIONPython programming. Introduction to the JES environment and basics of Python. Python. The programming language we will be using is called Python http://www.python.org It’s used by companies like Google, Industrial Light & Magic, Nextel, and others - PowerPoint PPT Presentation
Python programmingIntroduction to the JES environment and basics of Python
PythonThe programming language we will be using is called Pythonhttp://www.python.orgIts used by companies like Google, Industrial Light & Magic, Nextel, and othersThe kind of Python were using is called Jython (Java-based Python)http://www.jython.orgWell be using a specific tool to make Python programming easier, called JES (Jython Environment for Students).http://coweb.cc.gatech.edu/mediaComp-teach/26
JES - Jython Environment for StudentsProgram area- A simple editor for programsCommand area Interaction with Jython
>>> 5 + 38>>> spamspam>>> spamspam>>> spam and more spamspam and more spam>>> spam + spamspamspamPython interaction through commandsAnything you type in command area is evaluated and its value is displayed Example:
>>> print 5 + 38>>> print spamspam>>> spam + spamspamspam>>> print spam + spamSpamspam
print displays the value of an expression
In many cases it makes no difference whether you use print - the result gets displayed anyway.
Note: no quotes!
Command Area EditingUp/down arrows walk through command historyYou can edit the line at the bottomJust put the cursor at the end of the line before hitting Return/Enter.
Variables are names for dataExample:a= 3b= -1c = 2x = 0f = a*x*x + b*x + c
Variables -more examplesVariables of other typesnewsItem = Youve got spam!Variables keep their value for the duration of a program or until they get a new value through a new assignmenta = 3b = a *2 + 5a = 0Up to this point the value of a is still 3, but then it changes to 0
Types of dataIntegernum = -3Floating point numberanswer = 62.49Characterletter = 5Stringnote = lol jkjk
Python functionsPython has a lot of built-in functions for general mathematical manipulation, eg:sqrt(4) - computes the square root of 4ord(A) - computes the ASCII code for character A (i.e., a numeric code)str(4) produces a string corresponding to a numberExample: print (-b+sqrt(b*b - 4*a*c))/2*a
Special JES-Python functionsJES defines some special functions for media computation
Functions in generalF(a,b)4aF(4, a)side-effects
Example: showInformation()showInformation(message)messagePops up a new window displaying the message textshowInformation(message): message: the message to show to the user Opens a message dialog to the user showing information
Exploring more functionsThe 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?
ReadingChapters 1, and Sections 2.1-2.4 from Introduction to Computing and Programming in Python (up to page 22)
*Do show this live lots of examples, live installation.*URL to look at what companies use Python is in the book.*********