Show Menu

Jython Cheat Sheet by

Study Guide

Chapter 9 and 10

Top-Down Design
Breaking down of a system to gain insight to its compos­itional sub-sy­stems.

Bott­om-Down Design
Piecing together of systems to give rise to more complex systems, this making the original sub-sy­stems of the emergent system.

Device, system or object which can be viewed in terms of its input, output and transfer charac­ter­istics without knowing what is inside.

Opposite of Black-Box. Inner components or logic are available for inspec­tion.

Triple Quotes
Use Triple quotes when a strings spans multiple lines.

String Methods (strin­g.m­eth­od)
find, rfind
upper, lower
isalpha, isdigit

Func­tions with Strings and Lists
max, min(aS­tring)
max, min(aList)

List Methods (list.m­et­hod)
Strings are immutable; lists are mutable

Opening Files for Reading and Writing and Reading into a Variable
file = open("p­rac­tic­e.t­xt",­"­wt") wt is writing and rt is reading
file.w­ri­te(­"a string­"\n) \n makes a new line
data = file.r­ead() Now you can use string methods on data

The OS Module offers a number of powerful capabi­lities for dealing with files, e.g., renaming files, finding out when a file was last modified, and so on.
We start accessing the OS module by typing:
import os
The function that knows about direct­ories is listd­ir(), used as­std­ir()
listdir takes a path to a directory as input.
Random Module
import random
for i in range(­1,10):
print random.ra­ndom()
math knows about sin() and sqrt()

Chapter 11

a combined device for modulation and demodu­lation, for example, between the digital data of a computer and the analog signal of a telephone line.

formatted unit of data carried by a packet mode computer network.

a system for connecting a number of computer systems to form a local area network, with protocols to control the passing of inform­ation and to avoid simult­aneous transm­ission by two or more systems.

The Internet is a global system of interc­onn­ected computer networks that use the standard Internet protocol suite (TCP/IP) to link several billion devices worldwide.

Internet Service Provider

IP Address
a unique string of numbers separated by periods that identifies each computer using the Internet Protocol to commun­icate over a network.

Domain Names
the part of a network address that identifies it as belonging to a particular domain.

Post Office Protocol Used to retrieve email from a mail server

Simple Mail Transfer Protocol Internet standard for electronic mail (e-mail) transm­ission

Big O Estimates

Array Access (Selecting a character from a string)
Binary Search of a Sorted Collection
Linear Search
Better Sorts (Quick Sort, Merge Sort)
O(n log n)
Slower Sorts (Bubble, Insertion, Selection)
Traveling Salesmen (EX of NP-Com­plete problem) (Intra­ctable Problem)
Halting Problem - Unsolvable (Proven by Alan Turing, 1936)

Chapter 11-2

The File Transfer Protocol standard network protocol used to transfer computer files from one host to another host over a TCP-based network, such as the Internet

URL(Web Address when used with HTTP)
Uniform Resource Locator Specific character string that consti­tutes a reference to a resource

Hypertext Transfer Protocol Appli­cation protocol for distri­buted, collab­ora­tive, hypermedia inform­ation systems. HTTP is the foundation of data commun­ication for the World Wide Web

Hypertext Markup Language Standard language in the making of a web page

Sound to Text
def soundT­oTe­xt(­sou­nd,­fil­ena­me):
file = open(f­ile­nam­e,"w­t")
for s in getSam­ple­s(s­ound):

First: Make sure that all red values are even.
Second: For every pixel where the message picture is black, add one to the red value at the corres­ponding x,y.
def encode­(msgPic ,original ):
for pxl in getPix­els­(or­iginal ):
if (getRe­d(pxl) % 2) == 1:
setRe­d(pxl , getRed­(pxl) - 1)
for x in range(0, getWid­th(­ori­ginal )):
for y in range(0, getHei­ght­(or­iginal )):
msgPxl = getPix­el(­msgPic ,x,y)
origPxl = getPix­el(­ori­ginal ,x,y)
if (dista­nce­(ge­tCo­lor­(ms­gPx­l),­black) < 100.0):
setRe­d(o­rigPxl , getRed­(or­igPxl )+1)

Chapter 12

Simple WebPage
<ti­tle­>The Simplest Possible Web Page</­tit­le>
<h1­>A Simple Headin­g</­h1>
<p>This is a paragraph in the simplest <br \>
possible Web page.<­/p>
<img src="me­dia­sou­rce­s/f­low­er1.jpg“ />

A structured set of data held in a computer, especially one that is accessible in various ways.

A request for inform­ation from a database.

Structured Query Language
Specia­l-p­urpose progra­mming language designed for managing data held in a relational database management system.

Hexa­decimal is base 16
0,1,2,­3,4­,5,­6,7­,8,­9,A­,B,­C,D­,E,F,10 (16 base 10)
#FF0000 is Red
255 for red (FF), 0 for green, 0 for blue
#0000FF is Blue
0 for red, 0 for green, 255 for blue
#000000 is black
0 for red, 0 for green, 0 for blue
#FFFFFF is white
255 for red, 255 for green, 255 for blue

Chapter 14

Jython is first translated into Java, which is both compiled and interp­reted, every time a program is run. Thus one reason Photoshop operations are so much faster than our picture functions is that Photos­hop’s code has already been compiled and is ready to run at the click of a button.

There are some practical issues that determine the relative speeds of different computers. Some are: the clock speed of the processor, the number of cores of the processor, the amount of cache memory on board the processor (or nearby), the amount and speed of RAM, the size and speed of the hard disk, the system bus width and speed.

Download the Jython Cheat Sheet

2 Pages

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!



No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.