Chapter 9 and 10
Top-Down Design
Breaking down of a system to gain insight to its compositional sub-systems.
Bottom-Down Design
Piecing together of systems to give rise to more complex systems, this making the original sub-systems of the emergent system.
Black-Box
Device, system or object which can be viewed in terms of its input, output and transfer characteristics without knowing what is inside.
Glass-Box
Opposite of Black-Box. Inner components or logic are available for inspection.
Triple Quotes
Use Triple quotes when a strings spans multiple lines.
String Methods (string.method)
capitalize
startwith
endswith
find, rfind
upper, lower
swapcase
title
isalpha, isdigit
Functions with Strings and Lists
len(aString),(aList)
max, min(aString)
max, min(aList)
List Methods (list.method)
append
remove
sort
reverse
count
Strings are immutable; lists are mutable
Opening Files for Reading and Writing and Reading into a Variable
file = open("practice.txt","wt") wt is writing and rt is reading
file.write("a string"\n) \n makes a new line
file.close()
data = file.read() Now you can use string methods on data
data.method()
Modules
The OS Module offers a number of powerful capabilities 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 directories is listdir()
, used as os.listdir()
listdir takes a path to a directory as input.
Random Module
import random
for i in range(1,10):
print random.random()
math knows about sin() and sqrt() |
|
|
Chapter 11
Modem
a combined device for modulation and demodulation, 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.
Ethernet
a system for connecting a number of computer systems to form a local area network, with protocols to control the passing of information and to avoid simultaneous transmission by two or more systems.
Internet
The Internet is a global system of interconnected 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 communicate 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) transmission |
Big O Estimates
Array Access (Selecting a character from a string) |
O(1) |
Binary Search of a Sorted Collection |
O(logsub2n) |
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-Complete problem) (Intractable 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 constitutes a reference to a resource
HTTP
Hypertext Transfer Protocol Application protocol for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web
HTML
Hypertext Markup Language Standard language in the making of a web page
Sound to Text
def soundToText(sound,filename):
file = open(filename,"wt")
for s in getSamples(sound):
file.write(str(getSample(s))+"\n")
file.close()
Steganography
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 corresponding x,y.
def encode(msgPic ,original ):
for pxl in getPixels(original ):
if (getRed(pxl) % 2) == 1:
setRed(pxl , getRed(pxl) - 1)
for x in range(0, getWidth(original )):
for y in range(0, getHeight(original )):
msgPxl = getPixel(msgPic ,x,y)
origPxl = getPixel(original ,x,y)
if (distance(getColor(msgPxl),black) < 100.0):
setRed(origPxl , getRed(origPxl )+1)
|
|
|
Chapter 12
Simple WebPage
<!DOCTYPE HTML>
<html>
<head>
<title>The Simplest Possible Web Page</title>
</head>
<body>
<h1>A Simple Heading</h1>
<p>This is a paragraph in the simplest <br \>
possible Web page.</p>
<img src="mediasources/flower1.jpg“ />
</body>
</html>
Database
A structured set of data held in a computer, especially one that is accessible in various ways.
Query
A request for information from a database.
SQL
Structured Query Language
Special-purpose programming language designed for managing data held in a relational database management system.
Hexadecimal 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 interpreted, every time a program is run. Thus one reason Photoshop operations are so much faster than our picture functions is that Photoshop’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. |
|
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment