Show Menu

Jython Cheat Sheet by

Study Guide
jython

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.

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

Glas­s-Box
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)
capitalize
startwith
endswith
find, rfind
upper, lower
swapcase
title
isalpha, isdigit

Func­tions with Strings and Lists
len(aS­tri­ng)­,(a­List)
max, min(aS­tring)
max, min(aList)

List Methods (list.m­et­hod)
append
remove
sort
reverse
count
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
file.c­lo­se()
data = file.r­ead() Now you can use string methods on data
data.m­et­hod()

Modu­les
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 os.li­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

Modem
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.

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

Ethe­rnet
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.

Inte­rnet
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.

ISP
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.

POP
Post Office Protocol Used to retrieve email from a mail server

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

Big O Estimates

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

Chapter 11-2

FTP
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

HTTP
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

HTML
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):
file.w­rit­e(s­tr(­get­Sam­ple­(s)­)+"­\n")
file.c­lose()

Steg­ano­gra­phy
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
<!D­OCTYPE HTML>
<ht­ml>
<he­ad>
<ti­tle­>The Simplest Possible Web Page</­tit­le>
</h­ead>
<bo­dy>
<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“ />
</b­ody>
</h­tml>

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

Query
A request for inform­ation from a database.

SQL
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
//media.cheatography.com/storage/thumb/azamaryk_jython.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.