17 Pages

rec3_Jan26

Course: COMPUTERSC 1315, Spring 2011
School: Harvard
Rating:
 
 
 
 
 

Word Count: 1044

Document Preview

3 Workshop January 26, 2012 Summary of Workshop Review of conditionals Ranges/lists For Loop Intro For Loop Practice Problems Conditionals + For Loops Pictures! simple picture problem Notes for students Piazza checkup We have established many resources (office hours, workshop, piazza) for help. Please take advantage of them. If one of these channels does not seem appropriate, you may email your TA. Mini...

Register Now

Unformatted Document Excerpt

Coursehero >> Massachusetts >> Harvard >> COMPUTERSC 1315

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
3 Workshop January 26, 2012 Summary of Workshop Review of conditionals Ranges/lists For Loop Intro For Loop Practice Problems Conditionals + For Loops Pictures! simple picture problem Notes for students Piazza checkup We have established many resources (office hours, workshop, piazza) for help. Please take advantage of them. If one of these channels does not seem appropriate, you may email your TA. Mini Project 1 (MP1) was due January 25th (Wed) at 8pm Jan 27: First QUIZ tomorrow!! hw01 is released and due next Friday Review: Conditionals if Tells JES to check IF condition is true, then perform commands underneath it. JES will run through EVERY if statement elif ("else if...") otherwise, if the statement under elif is true, perform the commands underneath it. if the condition is met underneath the "elif", JES will be done (mutually exclusive) else: the "catchall" for JES. this is a statement that will perform the commands underneath it no matter what Conditional practice Function Name: dataType() Parameters: x a variable representing one of 4 data types. Return: a string representing the data type Description: Write a function that takes in a parameter that is 1 of the 4 data types, asks which data type it is, and returns it as a string. E.g. if you entered 3 as a parameter, "integer" should be returned. Hint: use the function type() to determine what the data type is. Test Cases: >>>dataType('hi') >>>dataType([3,3,3]) >>> 'string' >>> 'list' Lists Remember our 4 data types? str, int, float, and list. Lis ts a re a d a ta typ e th a t h o ld m ultip le ite m s b e twe e n b ra c ke ts , no t p a re nth e s is . e .g . [0 , 'a ', 2 5 5 , 'g re a t'] P ic ture a p p lic a tio n: lis ts a re h o w we s to re a ll th e p ixe ls o f a p ic ture in a lis t T o g e t th e p ixe ls s to re d in a lis t us e g e tP ixe ls () S h o w e xa m p le o f a lis t th a t's c re a te d c a lling g e tP ixe ls o f a p ic ture Lists continued range() is another function that creates a list. It has 3 parameters (3rd is optional) range(start, stop1, step) Try these out in JES: range(5) range(3,10) You can also create a list simply using the [] notation. You can also use this notation to add items to the new list or already created list. Intro to For Loops Iteration -For loops are great for repetitious events (e.g. drawing a 20 sided polygon with turtle commands). The simple things you need to know to use for loops: -how to use ranges : range(start,end-1,steps) -being able to trace through for loops Here is an example: def forLoops(): people = ["Kelsey", "Yusuf", "Kristin"] for item in people: print item Example Problem: Program should print out numbers from 1 to 4 (inclusive) and then return "the end". def anotherLoopExample (): toProcess = range (1,5) #(1,2,3,4) for val in toProcess: print val # why can't I use return val? return"the end" # explain why is return okay here. For Loop In Class Activity def forLoop(): vals = [3, 4, 5] temp = 0 for cur in vals: temp = temp + cur print temp (a) After running this code what is the value of the variable temp? (b) How many times is temp printed? (c) How many elements are in the collection being looped over? (d) What variable is considered the loop variable? (e) True/False: It is not necessary to initialize the variable "temp". (f) If print temp were indented under the for loop, how many times would temp be printed? Practice Problem Function Name: doubleOrNothing Parameters: list a list of numbers Return Value: None Description: Write a function that doubles each item in the list and then prints the new value for the item. For example, if the input list was [1,2,3] then the function would print 2, 4, 6. Combining for loops & conditionals Function Name: countBs Parameters: list Return value: number of Bs in list Test Cases: >>> list = [ 65, 90, 85, 100, 87, 82, 82] >>> countBs(list) 4 lets you loop over a collection of items and check each of the items against a specific condition Description: Write a function that counts the number of grades in a list that are greater than 80 and less than 90 Pictures Digital pictures are composed of pixels (individual squares that light up with a particular color) The human eye sees the pixels as one continuous image, but digitization allows us to manipulate pictures w/code Change pictures by changing the pixels Can change color, brightness, saturation, etc (this is what Photoshop, GIMP, etc do behind the scenes) Effects like sepia tone, posterize (limited colors) possible in JES! Things to remember with pictures The pixels in a picture are not numbered 1 to the end. it is similar to range() in that it begins at 0 and ends at 1 minus the length of the picture. e.g. a 200x200 picture has pixels 0199. Pictures Color JES uses the RGB system It consists of 3 color channels: Red, Green, Blue Each channel can have a value 0255 (0off, 255brightest) Over 16.5 million possible colors! Basic colors (r,g,b): Black: (0,0,0) all color channels off White: (255,255,255) all color channels max Pure Red (255,0,0) only red channel maxed Pure Green (0,255,0) Pure Blue (0,0,255) Cyan(0,255,255) Yellow(255,255,0) Magenta(255,0,255) Gray colors (x,x,x) where x is the same value All other colors are combinations of numbers in channels Pictures & for loops example Trace through the following and draw a picture on paper. TA's will explain the new functions and variables as you go. def changeColor(): pic=makeEmptyPicture(2,2, black) for pix in getPixels(pic): print getColor(pix) setColor(pix,white) print get color(pix) PICTURE WORKSHEET!!! Work in groups Group Quiz! Pair up with a partner or two and answer the following question: Function Name: decreaseRed Parameters: 1. pic a picture object to be edited Return Value: None. The picture will be edited directly Description: Write a function that takes in a picture and decreases the blue channel value for each pixel by half. For example, if a pixel ahs RGB values (204, 20, 206), after the function is run the new RGB values should be (102,20,206).
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Harvard - COMPUTERSC - 1315
Workshop 4 February 2nd, 2012Summary of Workshop- Go over Quiz answers - Picture Worksheet (if not done last week with the class) - One function: solving it with multiple solutions - How to load pictures into JES - Review how to present pictures on JES
University of Malaya - FACULTY OF - WXGE6320
WXGE6320: Web DevelopmentIntroduction to Web Development & Scripting XHTMLSimple View of Web DevelopmentSimple View of Client Side Web DevelopmentSimple View of Server-Side Web DevelopmentThe Inherent Trade-offs Client-side No control end user envi
University of Malaya - FACULTY OF - WXGE6320
Chapter 7 - JavaScript: Introduction to ScriptingOutline7.1 7.2 7.3 7.4 7.5 7.6 7.7 Introduction Simple Program: Printing a Line of Text in a Web Page Obtaining User Input with prompt Dialogs 7.3.1 Dynamic Welcome Page 7.3.2 Adding Integers Memory Conce
University of Malaya - FACULTY OF - WXGE6320
1.Consider the following relations: EMPLOYEE(EMPNO, ENAME, BDATE, ADDRESS, GENDER, DNO, SALARY) DEPARTMENT(DNUMBER, DNAME, MANAGERNUM) DEPENDENT(DEPNAME,ENO, DEPSEX,DEPDATE,RELATIONSHIP) PROJECTS(PNO, PNAME, LOCATION, DNO) WORKS_ON (ENO,PNO, HOURS) Use S
University of Malaya - FACULTY OF - WXGE6320
A Cognitive Theory of Multimedia Learning:Implications for Design PrinciplesFacts! Research on educational technologies has a disappointing history.Example 1In 1922, the famous inventor Thomas Edison proclaimed that "the motion picture is destined t
University of Malaya - FACULTY OF - WXGE6320
Microsoft Active Server Pages Introduction to Active Server Pages Microsoft version of server-side JavaScript Exists at the processing tier and executes according to client requests Supports JavaScript (Jscript), VBScript Interpreters also available fo
University of Malaya - FACULTY OF - WXGE6320
ALA Soft is a leading company in the fields of Information Systems design and Implementation. Our objective is to provide our clients with high quality software plus the sufficient tools to optimize our software and gain satisfaction. ALA Soft IT Engineer
University of Malaya - FACULTY OF - WXGE6320
Author : Choong Yeow Wei. Title Year : Designing an Expert System for Investment Analysis. : 1992 Degree : Master of Computer Science. Many complex problems including financial investment planning require intelligent systems that integrate many intelligen
University of Malaya - FACULTY OF - WXGE6320
This assignment is keyed to Access. You will be creating several tables, 1 query and 1 form in Access. You will also create a simple Access query and create reports for these queries. The database you will be creating will be for a library. Books and subj
University of Malaya - FACULTY OF - WXGE6320
Assignment 3 / Design a database for the registration of the Master in Information Technology courses in the Faculty of Computer Science & Information Technology. The system must have forms to help in the insertion, deletion and update of students' inform
University of Malaya - FACULTY OF - WXGE6320
Expert SystemsIntroductionExpert systems have developed from a branch of computer science known as artificial intelligence (AI). AI is primarily concerned with knowledge representation, problem solving, learning, robotics, and the development of compute
University of Malaya - FACULTY OF - WXGE6320
Augmented Reality 1Definition of Augmented RealityVirtual Environments (VE): Completely replaces the real world Augmented Reality (AR): User sees real environment; combines virtual with realSupplements reality, instead of completely replacing it Photo
University of Malaya - FACULTY OF - WXGE6320
Chapter 6 - Cascading Style SheetsTM (CSS)Outline6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 6.10 6.11 6.12 Introduction Inline Styles Embedded Style Sheets Conflicting Styles Linking External Style Sheets W3C CSS Validation Service Positioning Elements Backgro
University of Malaya - FACULTY OF - WXGE6320
Collision Detection for Virtual Reality ApplicationPart 1Collision Detection? Determine if two virtual objects in the virtual world / environment intersect each other. If they do what will happen? Collision detection is the process of determining whe
University of Malaya - FACULTY OF - WXGE6320
Collision DetectionPart 21Sphere-Sphere CollisionA sphere is represented using its center and its radiusdIntersection if d is less than the sum of their two radius2How About 2 MOVING spheres?2 spheres move during a time step from one point to ano
University of Malaya - FACULTY OF - WXGE6320
Collision Detection for Virtual Reality ApplicationPart 1Collision Detection? Determine if two virtual objects in the virtual world / environment intersect each other. If they do what will happen? Collision detection is the process of determining whe
University of Malaya - FACULTY OF - WXGE6320
Digital Image and Video Processing Assignment 2: Image EnhancementBasic features of the GUI is given as belowImage File Select Blurring Technique [ Drop down list box ]BrowseSelect Sharpening Technique [ Drop down list box ]Image Input Execute >Imag
University of Malaya - FACULTY OF - WXGE6320
Multimedia Application DesignDesign for InteractivityDesign Rules for Graphic and Screen Design Practice restraint (especially good advice for designers in the memory-intensive and bandwidthhungry world of multimedia) Concentrate on proportion Achieve
University of Malaya - FACULTY OF - WXGE6320
Digital Image FundamentalsLecture 2 Ex. Using Sensor ArrayImage AcquisitionSampling & Quantization To convert the continuous sensed data into digital form. Digitizing the coordinate values is called sampling Digitizing the amplitude values is cal
University of Malaya - FACULTY OF - WXGE6320
Dijkstra's AlgorithmDijkstra's algorithm sometimes called the shortest-path algorithm or forward algorithm, is centralized, static algorithm, although it can be made adaptive by executing it have information regarding link costs among the network nodes.
University of Malaya - FACULTY OF - WXGE6320
REPORT DIJKSTRA'S ALGORITHMDONE BY: MERIN PUTHUPARAMPILTOPICS1. INTRODUCTION 2. DESCRIPTION OF THE ALGORITHM 3. PSEUDO-CODE OF THE ALGORITHM 4. EXAMPLE 5. PROOF OF THE DIJKSTRA'S ALGORITHM 6. EFFICIENCY 7. DIS-ADVANTAGES 8. RELATED ALGORITHMS 9. APPLIC
University of Malaya - FACULTY OF - WXGE6320
XHTML is a combination of HTML and XML (EXtensible Markup Language). XHTML consists of all the elements in HTML 4.01 combined with the syntax of XML . The Most Important Differences: XHTML is not very different from the HTML 4.01 standard. So, bringing yo
University of Malaya - FACULTY OF - WXGE6320
Dynamic HTML1DHTML DHTML = Dynamic HTML It allows you to build rich client interfaces and to modify them dynamically It is not a W3C, IEEE, ISO or anything else standard DHTML consists of HTML/XHTML, CSS, DOM JavaScript (or ECMAScript) There is no DH
University of Malaya - FACULTY OF - WXGE6320
Extensible Markup LanguageXML Introduction New eXtensible Markup Language: XML Can use XML to define new languages Distributes easily on the Web Can mix different types of data togetherBasic XML RulesTechnical details Always need end tags Speci
University of Malaya - FACULTY OF - WXGE6320
Homework 1 and 2 1. Execute a multimedia application at http:/barbie.everythinggirl.com/. Based on your own judgment provide a review about its multimedia user interface design around 500 words. (5% score should be ready by 5 January 2007) 2. Find any sui
University of Malaya - FACULTY OF - WXGE6320
IntroductionThe expert system : Is a series of programs to solve problems and issues in the area requested to establishment of an expert system. It notes that called the system and not just a program because it includes the components of a solution to th
University of Malaya - FACULTY OF - WXGE6320
Human Factors in Virtual EnvironmentsIntroductionVirtual environments are envisioned as being systems that will enhance the communication between humans and computers. If virtual systems are to be effective and well received by their users:considerable
University of Malaya - FACULTY OF - WXGE6320
Hypermedia, Learning and Adaptive HypermediaWhat is Hypermedia? hypertext deals with the associative linking between texts, hypermedia extends the hypertext ability to also include other types of media such as image, graphics, audio and simulation. Wor
University of Malaya - FACULTY OF - WXGE6320
Image EnhancementPart 1 1Image Enhancement Used to emphasize and sharpen image features for display and analysis. enhance otherwise hidden information Filter important image features Discard unimportant image features Enhancement method are applica
University of Malaya - FACULTY OF - WXGE6320
Image EnhancementPart 2Arithmetic/Logic operations (e.g. subtraction, addition) perform on pixel by pixel basis between two or more images Except NOT operation which performs only on a single image Logic operation performs on graylevel images:Enhanceme
University of Malaya - FACULTY OF - WXGE6320
Image EnhancementPart 3 Frequency Domain Filtering Image Representation in Frequency Domain Images can be represented in ways other than arrays of pixels. One way is by using the Fourier Transform. Image Representation in Frequency Domain FT Th
University of Malaya - FACULTY OF - WXGE6320
Image Segmentation HomeworkTry out the seg.m file (download seg.zip from student centre)Explain the programming steps involved, in wordsMatlab exercise:Detect edges in lena.bmp picture using sobel, prewitt and canny filter/detector mask. Which mask de
University of Malaya - FACULTY OF - WXGE6320
IMAGE SEGMENTATIONPart 1Introduction Segmentationsubdivides an image into its constituents regions or objects. purpose of image segmentation is to partition an image into meaningful regions (that represents objects or meaningful parts of objects ) wit
University of Malaya - FACULTY OF - WXGE6320
Image SegmentationPart 2 Thresholding and Regionbased SegmentationIntroductionThe simplest property that pixels in a region can share is intensity. So, a natural way to segment such regions is through thresholding, the separation of light and dark regi
University of Malaya - FACULTY OF - WXGE6320
Virtual RealityInput and Output DevicesBasic ComponentsInput Devices Concerns trackingwith interfaces for:users and users navigating through the virtual environment and interacting with the virtual objectsTrackers Three-Dimensional TypesPosition
University of Malaya - FACULTY OF - WXGE6320
Research Methods / Research Foundations in Computer ACM SIGMM (Special Interest Group of ACM on Multimedia )Retreat Report on Future Directions in Multimedia ResearchACM MMThe ACM Multimedia Special Interest Group was created ten years ago. Since tha
University of Malaya - FACULTY OF - WXGE6320
Integrating Educational Technology into TeachingChapter 1 Educational Technology in Context: The Big PictureWhat You Need to KnowDefinition of Integrating Educational TechnologyT h e p ro c e s s o f d e te rm ining wh ic h electronic tools and which
University of Malaya - FACULTY OF - WXGE6320
Integrating Educational Technology into TeachingChapter 2 Planning & Implementation for Effective Technology IntegrationLevels of Planning School & District Level Teacher LevelPlanning Steps Coordinate School & District Planning Involve Teachers & Ot
University of Malaya - FACULTY OF - WXGE6320
Integrating Educational Technology into TeachingChapter 3 Learning Theories and Integration ModelsPast Perceptions Tutor Tool TuteeDivergent ViewsLearning is constructed knowledge Learning is transmitted knowledgeConstructivistsObjectivistsTeachin
University of Malaya - FACULTY OF - WXGE6320
Integrating Educational Technology into TeachingChapter 4 Integrating Instructional Software into Teaching & LearningINSTRUCTIONAL SOFTWAREPrograms developed for the sole purpose of delivering instruction or supporting learning activitiesInstructional
University of Malaya - FACULTY OF - WXGE6320
Interaction Design StageInteraction Design Concern with: 1. Content navigational and access path. 2. Interaction methods and controls in each screen. 3. Media treatments in each screen.Guidelines for designing good interactionBased on the following cr
University of Malaya - FACULTY OF - WXGE6320
Intro to Web Programming & Web ScriptingAnd Getting Started with HTMLAcronyms HTML - HyperText Markup Language CSS - Cascading Style Sheets (Markup Language) XML - eXtensible Markup Language XHTMLWeb Languages1. Markup Languages 2. Scripting Language
University of Malaya - FACULTY OF - WXGE6320
Chapter 3 - Photoshop Elements: Creating Web GraphicsOutline 3.1 3.2 3.3 3.4 Introduction Image Basics Vector and Raster Graphics Toolbox 3.4.1 Selection Tools 3.4.2 Painting Tools 3.4.3 Shape Tools Layers Screen Captures File Formats: GIF, JPEG and PNG
University of Malaya - FACULTY OF - WXGE6320
CardLayout.java / This program displays a customer's personal information in a business card public class CardLayout cfw_ public static void main(String[] args) cfw_ int count; / count is a counter for printing "*" 50 times / Printing spaces in the top Sy
University of Malaya - FACULTY OF - WXGE6320
Chapter 7 - JavaScript: Introduction to ScriptingOutline7.1 7.2 7.3 7.4 7.5 7.6 7.7 Introduction Simple Program: Printing a Line of Text in a Web Page Obtaining User Input with prompt Dialogs 7.3.1 Dynamic Welcome Page 7.3.2 Adding Integers Memory Conce
University of Malaya - FACULTY OF - WXGE6320
Chapter 8 - JavaScript: Control Statements IOutline8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 Introduction Algorithms Pseudocode Control Structures if Selection Statement if.else Selection Statement while Repetition Statement Formulating Algorithms: Case Study 1 (
University of Malaya - FACULTY OF - WXGE6320
Chapter 9 - JavaScript: Control Statements IIOutline9.1 9.2 9.3 9.4 9.5 9.6 9.7 9.8 9.9 9.10 9.11 Introduction Essentials of Counter-Controlled Repetition f o r Repetition Statement Examples Using the f o r Statement s w i t c h Multiple-Selection State
University of Malaya - FACULTY OF - WXGE6320
Chapter 10 - JavaScript: FunctionsOutline10.1 10.2 10.3 10.4 10.5 10.6 10.7 10.8 10.9 10.10 10.11 10.12 Introduction Program Modules in JavaScript ProgrammerDefined Functions Function Definitions RandomNumber Generation Example: Game of Chance Another E
University of Malaya - FACULTY OF - WXGE6320
Chapter 7 - JavaScript: Introduction to ScriptingOutline7.1 7.2 7.3 7.4 7.5 7.6 7.7 Introduction Simple Program: Printing a Line of Text in a Web Page Obtaining User Input with prompt Dialogs 7.3.1 Dynamic Welcome Page 7.3.2 Adding Integers Memory Conce
University of Malaya - FACULTY OF - WXGE6320
Markup LanguageQ1/ What is a markup language? Markup language is a set of codes or tags that surrounds content and tells a person or program what that content is (its structure) and/or what it should look like (its format). Markup tags have a distinct sy
University of Malaya - FACULTY OF - WXGE6320
Math Teacher Expert SystemIntroductionExpert Systems: are computer programs that are derived from the Artificial Intelligence. The obvious extension of storing knowledge inside a computer program is to make use of that knowledge to solve practical probl
University of Malaya - FACULTY OF - WXGE6320
phone A phone is a 'unit sound' of a language in the sense that it is the minimal sound by which two words can differ. For example, the English word feed contains three phones since each can be independently substituted to form a different word. In the IP
University of Malaya - FACULTY OF - WXGE6320
PHP Array Functions PHP Array Introduction The array functions allow you to manipulate arrays. PHP supports both simple and multi-dimensional arrays. There are also specific functions for populating arrays from database queries. Installation The array fun
University of Malaya - FACULTY OF - WXGE6320
Presentation DesignWRET1103Some key visual display principles (Lewis and Rieman, 1994)The `clustering' principleorganise screen into visually separate blocks based on logical grouping Aim to give title to each blockThe `visibility reflects usefulness
University of Malaya - FACULTY OF - WXGE6320
WRET3310: Quiz 1J XHTML, JavaScriptsAnswer ALL Questions If you manage to produce the requirement output, you'll get 1 mark. You have 45 minutes on this quiz. Spend 10 minutes on every questions. Save your work as .html files named after the question e
University of Malaya - FACULTY OF - WXGE6320
QUIZ 2 WEB APPLICATION DEVELOPMENT (40 Minutes) - 5% Answer All Questions 1. Answer True or False for each of the following statements:i) ii)iii) iv)v)vi) vii) viii) ix) x)The <!ELEMENT list (item*)> defines element list as containing one or more ite
University of Malaya - FACULTY OF - WXGE6320
WRET2101Representation and Description Representation & DescriptionThe results of segmentation is a set of regions. Regions have then to be represented and described.RepresentationTwo main ways of representing a region:1. external characteristic
University of Malaya - FACULTY OF - WXGE6320
Fastest Route from CS Dept to Einstein's HouseShortest PathsDijkstra's algorithm Bellman-Ford algorithmPrinceton University COS 226 Algorithms and Data Structures Spring 2004 Kevin Wayne http:/www.Princeton.EDU/~cos2262Shortest Path ProblemShortest
University of Malaya - FACULTY OF - WXGE6320
Speech InterfaceSpeech Overview VoiceUser Interface How does it work? Synthesis(TTS) Recognition (SR)Speech Synthesis Textto Speechdatabase Dynamic PromptHow Speech Synthesis Works? Textparsingnumbers, symbols, pauses Sentences, Natural P
University of Malaya - FACULTY OF - WXGE6320
SynchronizationSynchronization Synchronizationmultimedia. People paying for the localization project do not want to have to re-shoot expensive video. Instead, they ask you to use the same characters, just put in a different sound. Unfortunately, if we
University of Malaya - FACULTY OF - WXGE6320
2007/2008 Tutorial 1 Answer Q1 : I) II) III) IV) Entities: Departments, Employees, Supervisor, Projects Assigned (Employee-Department), Has (Department-Supervisor), Works-On (Employee-Project), The only attributes indicated are the names of the department