“Interpretive” language (vs compiled)



Yüklə 441 Kb.
tarix07.11.2018
ölçüsü441 Kb.
#78906



“Interpretive” language (vs. compiled)

  • “Interpretive” language (vs. compiled)

    • So is HTML, JavaScript.
  • Python supports file I/O. JavaScript doesn’t

  • Python is a serious web programming language used by Google, ILM, etc.



Jython is a “dialect” of Python



http://code.google.com/p/mediacomp-jes/

  • http://code.google.com/p/mediacomp-jes/

  • http://code.google.com/p/mediacomp-jes/downloads/list



Select JES from “Programs”

  • Select JES from “Programs”

  • Click on the black part of the UI

  • after the command prompt >>>



print 5 + 9

  • print 5 + 9

  • print “Hello”

  • x = 5 + 9

  • print x

  • message = “Hello There”

  • print message



print 5 + 9

  • print 5 + 9

  • print “Hello”

  • x = 5 + 9

  • print x

  • message = “Hello There”

  • print message

  • Note: Python is case sensitive.

  • “Print” and “Message” won’t work.



pickAFile()

  • pickAFile()



pickAFile()

  • pickAFile()

  • print pickAFile()



pickAFile()

  • pickAFile()

  • print pickAFile()

  • file = pickAFile()



pickAFile()

  • pickAFile()

  • print pickAFile()

  • file = pickAFile()

  • print file



pickAFile()

  • pickAFile()

  • print pickAFile()

  • file = pickAFile()

  • print file

  • pict=makePicture(file) # interpret as picture



pickAFile()

  • pickAFile()

  • print pickAFile()

  • file = pickAFile()

  • print file

  • pict=makePicture(file) # interpret as picture

  • show(pict) # display as picture





show(makePicture(pickAFile()))

  • show(makePicture(pickAFile()))



show(makePicture(pickAFile()))

  • show(makePicture(pickAFile()))

  • Now lets save it as a Python Program:

  • displayPict.py



show(makePicture(pickAFile()))

  • show(makePicture(pickAFile()))

  • Now lets save it as a Python Program:

  • displayPict.py

  • And run it:

  • open it

  • and load it



show(makePicture(pickAFile()))

  • show(makePicture(pickAFile()))

  • Now lets save it as a Python Program:

  • displayPict.py

  • And run it:

  • open it

  • and load it



file = pickAFile()

  • file = pickAFile()

  • print file

  • sound=makeSound(file) # interpret as sound

  • play(sound) # lets listen to it

  • All together: play(makeSound(pickAFile()))

  • Save as a Python program and run it



def myFunction(): colon

  • def myFunction(): colon



def myFunction(): colon



def myFunction(): colon



def myFunction(): colon

  • def myFunction(): colon

  • parentheses

  • function name

  • “def” instead of “function()”



def myFunction(): colon

  • def myFunction(): colon

  • parentheses

  • function name

  • “def” instead of “function()”

  • The function must be called somewhere



def myFunction():



def myFunction():

  • def myFunction():

  • block of commands

  • Note indentation!



Indentation is critical in Python

  • Indentation is critical in Python

  • Indentation associates these commands with this function

  • Indentation separates commands from other functions



def pickAndShow():

  • def pickAndShow():

  • file = pickAFile()

  • myPict = makePicture(file)

  • show(myPict)

  • pickAndShow() # somewhere we have to

  • call the function



Yüklə 441 Kb.

Dostları ilə paylaş:




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə