# Rules and constraints in software construction PROGRAMMING STYLES

Save this PDF as:

Size: px
Start display at page:

## Transcription

1

2

3 Rules and constraints in software construction PROGRAMMING STYLES

4 Programming Styles Ways of expressing tasks Exist and recur at all scales Frozen in Programming Languages

5 Why Are Styles Important? Basic frames of reference for solutions Like scaffolding Common vocabularies It s a cultural thing Some better than others Depending on many objectives

6 Programming Styles How do you teach this?

7 Raymond Queneau

8 Queneau s Exercises in Style Metaphor Surprises Dream Prognostication Hesitation Precision Negativities Asides Anagrams Logical analysis Past Present (99)

9 Queneau s Styles Constraints A Void (La Disparition) by Georges Perec No letter e

10 Exercises in Programming Style The story: Term Frequency given a text file, output a list of the 25 most frequently-occurring words, ordered by decreasing frequency

11 Exercises in Programming Style The story: Pride and Prejudice Term Frequency given a text file, output a list of the 25 most frequently-occurring words, ordered by decreasing frequency TF mr elizabeth very darcy such mrs much more bennet bingley jane miss one know before herself though well never - 220

12 @cristalopes #style1 name STYLE #1

13

14 # the global list of [word, frequency] pairs word_freqs = [] # the list of stop words with open('../stop_words.txt') as f: stop_words = f.read().split(',') stop_words.extend(list(string.ascii_lowercase))

15 for line in open(sys.argv[1]): for c in line:

16 Style #1 constraints No abstractions No use of library #style1 name

17 Style #1 constraints No abstractions No use of library functions Monolithic #style1 name

18 @cristalopes #style2 name STYLE #2

19 import re, sys, collections stopwords = set(open('../stop_words.txt').read().split(',')) words = re.findall('[a-z]{2,}', open(sys.argv[1]).read().lower()) counts = collections.counter(w for w in words if w not in stopwords) for (w, c) in counts.most_common(25): print w, '-', c Credit: Laurie Tratt, Kings College London

20 import re, sys, collections stopwords=set(open('../stop_words.txt').read().split(',')) words = re.findall('[a-z]{2,}', open(sys.argv[1]).read().lower()) counts = collections.counter(w for w in words \ if w not in stopwords) for (w, c) in counts.most_common(25): print w, '-', c

21 import re, string, sys stops = set(open("../stop_words.txt").read().split(",") + list(string.ascii_lowercase)) words = [x.lower() for x in re.split("[^a-za-z]+", open(sys.argv[1]).read()) if len(x) > 0 and x.lower() not in stops] unique_words = list(set(words)) unique_words.sort(lambda x,y:cmp(words.count(y), words.count(x))) print "\n".join(["%s - %s" % (x, words.count(x)) for x in unique_words[:25]])

22 Style #2 constraints As few lines of code as #style2 name

23 Style #2 constraints As few lines of code as possible Code Golf #style2 name

24 Style #2 constraints As few lines of code as possible Try Hard #style2 name

25 @cristalopes #style3 name STYLE #3

26

27 data=[] words=[] freqs=[] def frequencies(): def read_file(path): def sort(): def filter_normalize(): def scan(): def rem_stop_words(): # # Main # read_file(sys.argv[1]) filter_normalize() scan() rem_stop_words() frequencies() sort() for tf in word_freqs[0:25]: print tf[0], ' - ', tf[1]

28 Style #3 constraints Procedural abstractions maybe input, no output Shared state Larger problem solved by applying procedures, one after the other, changing the shared #style3 name

29 Style #3 constraints Procedural abstractions maybe input, no output Shared state Series of commands Cook Book #style3 name

30 @cristalopes #style4 name STYLE #4

31

32 def read_file(path): return... def filter(str_data): return... def normalize(str_data): return... def scan(str_data): return... def sort(word_freqs): # # Main # return... return... wfreqs=st(fq(r(sc(n(fc(rf(sys.argv[1]))))))) for tf in wfreqs[0:25]: print tf[0], ' - ', tf[1] def rem_stop_words(wordl): return... def frequencies(wordl):

33 Style #4 constraints Function abstractions f: Input Output No shared state Function composition f º #style4 name

34 Style #4 constraints Function abstractions f: Input Output No shared state Function composition f º g Pipeline #style4 name

35 @cristalopes #style5 name STYLE #5

36

37 def read_file(path, func):... return func(, normalize) def filter_chars(data, func):... return func(, scan) def normalize(data, func):... return func(,remove_stops) def scan(data, func):... return func(, frequencies) # Main w_freqs=read_file(sys.argv[1], filter_chars) for tf in w_freqs[0:25]: print tf[0], ' - ', tf[1] def remove_stops(data, func):... return func(, sort) Etc.

38 Style #5 constraints Functions take one additional parameter, f called at the end given what would normally be the return value plus the next #style5 name

39 Kick forward #style5 name Style #5 constraints Functions take one additional parameter, f called at the end given what would normally be the return value plus the next function

40 @cristalopes #style6 name STYLE #6

41

42 class TFExercise(): def info(self): class DataStorageManager(TFExercise): def is_stop_word(self, word): def info(self): class WordFreqManager(TFExercise): def inc_count(self, word): def sorted(self): def info(self): class WordFreqController(TFExercise): def words(self): def run(self): def info(self): class StopWordManager(TFExercise): # Main WordFreqController(sys.argv[1]).run()

43 Style #6 constraints Things, things and more things! Capsules of data and procedures Data is never accessed directly Capsules can reappropriate procedures from other #style6 name

44 Kingdom of Nouns #style6 name Style #6 constraints Things, things and more things! Capsules of data and procedures Data is never accessed directly Capsules can reappropriate procedures from other capsules

45 @cristalopes #style7 name STYLE #7

46

47 class DataStorageManager(): def dispatch(self, message): def dispatch(self, message): class WordFrequencyController(): def dispatch(self, message): class StopWordManager(): def dispatch(self, message): class WordFrequencyManager(): # Main wfcntrl = WordFrequencyController() wfcntrl.dispatch([ init,sys.argv[1]]) wfcntrl.dispatch([ run ])

48 Style #7 constraints (Similar to #6) Capsules receive messages via single receiving #style7 name

49 Style #7 constraints (Similar to #6) Capsules receive messages via single receiving procedure Letterbox #style7 name

50 @cristalopes #style8 name STYLE #8

51

52 # Main splits = map(split_words, partition(read_file(sys.argv[1]), 200)) splits.insert(0, []) word_freqs = sort(reduce(count_words, splits)) for tf in word_freqs[0:25]: print tf[0], ' - ', tf[1]

53 def split_words(data_str) """ Takes a string (many lines), filters, normalizes to lower case, scans for words, and filters the stop words. Returns a list of pairs (word, 1), so [(w1, 1), (w2, 1),..., (wn, 1)] """... result = [] words = _rem_stop_words(_scan(_normalize(_filter(data_str)))) for w in words: result.append((w, 1)) return result

54 def count_words(pairs_list_1, pairs_list_2) """ Takes two lists of pairs of the form [(w1, 1),...] and returns a list of pairs [(w1, frequency),...], where frequency is the sum of all occurrences """ mapping = dict((k, v) for k, v in pairs_list_1) for p in pairs_list_2: if p[0] in mapping: mapping[p[0]] += p[1] else: mapping[p[0]] = 1 return mapping.items()

55 Style #8 constraints Two key abstractions: map(f, chunks) and reduce(g, #style8 name

56 Style #8 constraints Two key abstractions: map(f, chunks) and reduce(g, results) Map-Reduce #style8 name

57 @cristalopes #style9 name STYLE #9

58

59 # Main connection = sqlite3.connect(':memory:') create_db_schema(connection) load_file_into_database(sys.argv[1], connection) # Now, let's query c = connection.cursor() c.execute("select value, COUNT(*) as C FROM words GROUP BY value ORDER BY C DESC") for i in range(25): row = c.fetchone() if row!= None: print row[0] + ' - ' + str(row[1]) connection.close()

60 def create_db_schema(connection): c = connection.cursor() c.execute('''create TABLE documents(id PRIMARY KEY AUTOINCREMENT, name)''' c.execute('''create TABLE words(id, doc_id, value)''') c.execute('''create TABLE characters(id, word_id, value)''') connection.commit() c.close()

61 # Now let's add data to the database # Add the document itself to the database c = connection.cursor() c.execute("insert INTO documents (name) VALUES (?)", (path_to_f c.execute("select id from documents WHERE name=?", (path_to_fil doc_id = c.fetchone()[0] # Add the words to the database c.execute("select MAX(id) FROM words") row = c.fetchone() word_id = row[0] if word_id == None: word_id = 0 for w in words: c.execute("insert INTO words VALUES (?,?,?)", (word_id, d # Add the characters to the database char_id = 0 for char in w: c.execute("insert INTO characters VALUES (?,?,?)", (c char_id += 1 word_id += 1 connection.commit() c.close()

62 Style #9 constraints Entities and relations between them Query engine Declarative #style9 name

63 Style #9 constraints Entities and relations between them Query engine Declarative queries Persistent Tables #style9 name

64 Take Home Many ways of solving problems Know them, assess them What are you trying to optimize? Constraints are important for communication Make them explicit Don t be hostage of one way of doing things

65 @cristalopes

### Tutorial 2: Validating Documents with DTDs

1. One way to create a valid document is to design a document type definition, or DTD, for the document. 2. As shown in the accompanying figure, the external subset would define some basic rules for all

### CSCI 2101 Java Style Guide

CSCI 2101 Java Style Guide Fall 2017 This document describes the required style guidelines for writing Java code in CSCI 2101. Guidelines are provided for four areas of style: identifiers, indentation,

### Declaration Syntax. Declarations. Declarators. Declaration Specifiers. Declaration Examples. Declaration Examples. Declarators include:

Declarations Based on slides from K. N. King Declaration Syntax General form of a declaration: declaration-specifiers declarators ; Declaration specifiers describe the properties of the variables or functions

### Information Retrieval

Information Retrieval Suan Lee - Information Retrieval - 05 Index Compression 1 05 Index Compression - Information Retrieval - 05 Index Compression 2 Last lecture index construction Sort-based indexing

### Alastair Burt Andreas Eisele Christian Federmann Torsten Marek Ulrich Schäfer. October 6th, Universität des Saarlandes. Introduction to Python

Outline Alastair Burt Andreas Eisele Christian Federmann Torsten Marek Ulrich Schäfer Universität des Saarlandes October 6th, 2009 Outline Outline Today s Topics: 1 More Examples 2 Cool Stuff 3 Text Processing

### Final Exam Practice. Partial credit will be awarded.

Please note that this problem set is intended for practice, and does not fully represent the entire scope covered in the final exam, neither the range of the types of problems that may be included in the

### Introduction to Computer Science Midterm 3 Fall, Points

Introduction to Computer Science Fall, 2001 100 Points Notes 1. Tear off this sheet and use it to keep your answers covered at all times. 2. Turn the exam over and write your name next to the staple. Do

### An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type.

Data Structures Introduction An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type. Representation of a large number of homogeneous

### Chapter 4. In this chapter, you will learn:

Chapter Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel 1 In this chapter, you will learn: The main characteristics of entity

### 2.4 Choose method names carefully

2.4 Choose method names carefully We ve already discussed how to name a class in Section 1.1. Now it s time to name methods properly. I m suggesting this simple rule of thumb: builders are nouns, manipulators

### Course Text. Course Description. Course Objectives. StraighterLine Introduction to Programming in C++

Introduction to Programming in C++ Course Text Programming in C++, Zyante, Fall 2013 edition. Course book provided along with the course. Course Description This course introduces programming in C++ and

### Writing Beautiful Code. Anand Chitipothu

Writing Beautiful Code Anand Chitipothu quality without a name A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained

### Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 ARRAYS

Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 1 ARRAYS Arrays 2 Arrays Structures of related data items Static entity (same size

### ANSWERS. Birkbeck (University of London) Software and Programming 1 In-class Test Feb Student Name Student Number. Answer all questions

Birkbeck (University of London) Software and Programming 1 In-class Test 1.1 9 Feb 2017 Student Name Student Number Answer all questions 1. Consider the following sequence of Java statements: int m = 3;

### Documentation of the UJAC print module's XML tag set.

Documentation of the UJAC print module's XML tag set. tag Changes the document font by adding the 'bold' attribute to the current font. tag Prints a barcode. type: The barcode type, supported

### PRACTICE MIDTERM EXAM #2

This practice exam is based on the actual midterm exam from Cynthia s Spring 2014 class. It did not include a classes problem (which you should expect this quarter), and the memory/pointers problem covered

### AP Computer Science A

2017 AP Computer Science A Scoring Guidelines College Board, Advanced Placement Program, AP, AP Central, and the acorn logo are registered trademarks of the College Board. AP Central is the official online

### CS Introduction to Computational and Data Science. Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017

CS 133 - Introduction to Computational and Data Science Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017 Introduction to Python II In the previous class, you have

### AP Computer Science A

2017 AP Computer Science A Sample Student Responses and Scoring Commentary Inside: RR Free Response Question 1 RR Scoring Guideline RR Student Samples RR Scoring Commentary 2017 The College Board. College

### AP Computer Science A

2017 AP Computer Science A Sample Student Responses and Scoring Commentary Inside: RR Free Response Question 3 RR Scoring Guideline RR Student Samples RR Scoring Commentary 2017 The College Board. College

### Document Imaging User Guide

Release 4.9 IMAGING TECHNOLOGY GROUP Document Imaging Systems Document Imaging User Guide IMAGING TECHNOLOGY GROUP IMIGIT tm Document Imaging User Guide Release 4.91 March 2007 Imaging Technology Group

### Structure and Interpretation of Computer Programs

CS 61A Summer 2016 Structure and Interpretation of Computer Programs Midterm Solutions INSTRUCTIONS You have 2 hours and 50 minutes to complete the exam. The exam is closed book, closed notes, closed computer,

### This book is about using Visual Basic for Applications (VBA), which is a

In This Chapter Describing Access Discovering VBA Seeing where VBA lurks Understanding how VBA works Chapter 1 Where VBA Fits In This book is about using Visual Basic for Applications (VBA), which is a

### CS 115 Exam 3, Fall 2016, Sections 1-4

, Sections 1-4 Your name: Rules You may use one handwritten 8.5 x 11 cheat sheet (front and back). This is the only resource you may consult during this exam. Explain/show work if you want to receive partial

### CS143 Final Fall 2009

CS143 Final Fall 2009 Please read all instructions (including these) carefully. There are 4 questions on the exam, all with multiple parts. You have 2 hours to work on the exam. The exam is closed book,

### Creating Custom Financial Statements Using

Creating Custom Financial Statements Using Steve Collins Sage 50 Solution Provider scollins@iqacct.com 918-851-9713 www.iqaccountingsolutions.com Financial Statement Design Sage 50 Accounting s built in

### APCS Semester #1 Final Exam Practice Problems

Name: Date: Per: AP Computer Science, Mr. Ferraro APCS Semester #1 Final Exam Practice Problems The problems here are to get you thinking about topics we ve visited thus far in preparation for the semester

### This is CS50. Harvard University Fall Quiz 0 Answer Key

Quiz 0 Answer Key Answers other than the below may be possible. Binary Bulbs. 0. Bit- Sized Questions. 1. Because 0 is non- negative, we need to set aside one pattern of bits (000) for it, which leaves

### Creating tables of contents

Creating tables of contents A table of contents (TOC) can list the contents of a book, magazine, or other publication; display a list of illustrations, advertisers, or photo credits; or include other information

### EE 352 Homework 1 Redekopp Name:

EE 352 Homework 1 Redekopp Name: Note: Attach all work to receive full credit Score: Pseudo-Instructions 1.) (11 pts.) Expand/convert each of the following pseudo-instructions to an actual MIPS instruction

### Microsoft Word. Part 2. Hanging Indent

Microsoft Word Part 2 Hanging Indent 1 The hanging indent feature indents each line except the first line by the amount specified in the By field in the Paragraph option under the format option, as shown

### Object oriented lab /second year / review/lecturer: yasmin maki

1) Examples of method (function): Note: the declaration of any method is : method name ( parameters list ).. Method body.. Access modifier : public,protected, private. Return

### CS Exam 2 Name: Your Grading TA: This exam has 7 pages including the title page. Please check to make sure all pages are included.

CS1301 - Exam 2 Name: Your Grading TA: Instructions: Please write clearly. What I cannot read, I will not grade. Show all your work in detail. I give partial credit. This exam has 7 pages including the

### 1) Introduction to SQL

1) Introduction to SQL a) Database language enables users to: i) Create the database and relation structure; ii) Perform insertion, modification and deletion of data from the relationship; and iii) Perform

### Final Examination, Semester 1, 2015 COMP10001 Foundations of Computing

Student Number The University of Melbourne Department of Computing and Information Systems Final Examination, Semester 1, 2015 COMP10001 Foundations of Computing Reading Time: 15 minutes. Writing Time:

### Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Lecture 30 April 4, 2018 I/O & Histogram Demo Chapters 28 HW7: Chat Server Announcements No penalty for late submission by tomorrow (which is a HARD deadline!)

### Chapter 6: Information Retrieval and Web Search. An introduction

Chapter 6: Information Retrieval and Web Search An introduction Introduction n Text mining refers to data mining using text documents as data. n Most text mining tasks use Information Retrieval (IR) methods

### Lecture 5 C Programming Language

Lecture 5 C Programming Language Summary of Lecture 5 Pointers Pointers and Arrays Function arguments Dynamic memory allocation Pointers to functions 2D arrays Addresses and Pointers Every object in the

### Pointers and scanf() Steven R. Bagley

Pointers and scanf() Steven R. Bagley Recap Programs are a series of statements Defined in functions Can call functions to alter program flow if statement can determine whether code gets run Loops can

### A Simple Search Engine

A Simple Search Engine Benjamin Roth CIS LMU Benjamin Roth (CIS LMU) A Simple Search Engine 1 / 13 Document Collection for Search Engine Now that we have a documents, let s represent a collection of documents

### Encoding and Encrypting Information

Encoding and Encrypting Information Information is often encoded numerically. By using some mathematics to encode information in an appropriate way, we can overcome problems encountered in dealing with

### Introduction to Functional Programming. Slides by Koen Claessen and Emil Axelsson

Introduction to Functional Programming Slides by Koen Claessen and Emil Axelsson Goal of the Course Start from the basics Learn to write small-to-medium sized programs in Haskell Introduce basic concepts

### Arrays Arrays and pointers Loops and performance Array comparison Strings. John Edgar 2

CMPT 125 Arrays Arrays and pointers Loops and performance Array comparison Strings John Edgar 2 Python a sequence of data access elements with [index] index from [0] to [len-1] dynamic length heterogeneous

### gcc o driver std=c99 -Wall driver.c bigmesa.c

C Programming Simple Array Processing This assignment consists of two parts. The first part focuses on array read accesses and computational logic. The second part focuses on array read/write access and

Administrivia The Pyth Language Lecture 5 Please make sure you have registered your team, created SSH keys as indicated on the admin page, and also have electronically registered with us as well. Prof.

### How invariants help writing loops Author: Sander Kooijmans Document version: 1.0

How invariants help writing loops Author: Sander Kooijmans Document version: 1.0 Why this document? Did you ever feel frustrated because of a nasty bug in your code? Did you spend hours looking at the

### The Big Python Guide

The Big Python Guide Big Python Guide - Page 1 Contents Input, Output and Variables........ 3 Selection (if...then)......... 4 Iteration (for loops)......... 5 Iteration (while loops)........ 6 String

### 04 Storage management 15/07/17 12:34 AM. Storage management

Storage management 1 "High water" and "low water" marks PCTFREE and PCTUSED parameters PCTFREE ("high water" mark) and PCTUSED ("low water" mark) parameters control the use of free space for inserts and

### Student Profile & Lookup Options

Student Profile & Lookup Options Changing Entities Student Profile Ranges Student Selection Options Student Link Changing Entities Skyward uses entities to help organize student data. One entity is a group

### CS 251 Intermediate Programming Methods and More

CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

### 3 Follows two- and three-part oral directions. TE: 44, 57, 58 59, , PE: 57, 58 59, ,

Strand: Oral Communication Reading Standards 10 and 11 are addressed in Houghton Mifflin READING, Georgia Edition. Strand: Written Communication Reading Standards 13, 15 19, 29, 39, and 41 are addressed

### Design Patterns: State, Bridge, Visitor

Design Patterns: State, Bridge, Visitor State We ve been talking about bad uses of case statements in programs. What is one example? Another way in which case statements are sometimes used is to implement

### Data Modelling: 1 Entity, Keys & Attributes

Data Modelling: 1 Entity, Keys & Attributes Introduction Data (information) has become as precious a commodity to the organisation as the product they sell. The data and information accumulated by a company

### CE221 Programming in C++ Part 1 Introduction

CE221 Programming in C++ Part 1 Introduction 06/10/2017 CE221 Part 1 1 Module Schedule There are two lectures (Monday 13.00-13.50 and Tuesday 11.00-11.50) each week in the autumn term, and a 2-hour lab

### FORTRAN - CHARACTERS

FORTRAN - CHARACTERS http://www.tutorialspoint.com/fortran/fortran_characters.htm Copyright tutorialspoint.com The Fortran language can treat characters as single character or contiguous strings. Characters

### US Secret Service National Threat Assessment Center (NTAC), Insider threat study (2004)

US Secret Service National Threat Assessment Center (NTAC), Insider threat study (2004) 83% of incidents executed from within organization, during normal business hours Financial loss in almost all insider

### Introduction to MapReduce. Adapted from Jimmy Lin (U. Maryland, USA)

Introduction to MapReduce Adapted from Jimmy Lin (U. Maryland, USA) Motivation Overview Need for handling big data New programming paradigm Review of functional programming mapreduce uses this abstraction

### Outline: Finish uncapacitated simplex method Negative cost cycle algorithm The max-flow problem Max-flow min-cut theorem

Outline: Finish uncapacitated simplex method Negative cost cycle algorithm The max-flow problem Max-flow min-cut theorem Uncapacitated Networks: Basic primal and dual solutions Flow conservation constraints

### Informatica V9 Sizing Guide

Informatica V9 Sizing Guide Overview of Document This document shows average sizing for V9 Installs at 3 different levels. The first is the size of installed elements on the file system. The second is

### Structure and Interpretation of Computer Programs

CS 61A Fall 2017 Structure and Interpretation of Computer Programs Midterm 1 Solutions INSTRUCTIONS You have 2 hours to complete the exam. The exam is closed book, closed notes, closed computer, closed

### Assignment #6: Markov-Chain Language Learner CSCI E-220 Artificial Intelligence Due: Thursday, October 27, 2011

1. General Idea Assignment #6: Markov-Chain Language Learner CSCI E-220 Artificial Intelligence Due: Thursday, October 27, 2011 You will write a program that determines (as best as possible) the language

### Sequential Files EXAMPLE

C++ 30 By EXAMPLE Sequential Files So far, every example in this book has processed data that resided inside the program listing or came from the keyboard. You assigned constants and variables to other

### Lesson 1. Introduction to Programming OBJECTIVES

Introduction to Programming If you re new to programming, you might be intimidated by code and flowcharts. You might even wonder how you ll ever understand them. This lesson offers some basic ideas and

### Introduction to CS Dealing with tables in Word Jacek Wiślicki, Laurent Babout,

Most word processors offer possibility to draw and format even very sophisticated tables. A table consists of rows and columns, forming cells. Cells can be split and merged together. Content of each cell

### Functionally Modular. Self-Review Questions

Functionally Modular 5 Self-Review Questions Self-review 5.1 Which names are local, which are global and which are built-in in the following code fragment? Global names: Built-in names: space_invaders

### Microsoft Word 2010 : Tables

Microsoft Word 2010 : Tables A table is a structure of vertical columns and horizontal rows. Each column and row will have a heading. Heading 1 Heading 2 At the intersection of each column and row is a

### In This Lecture. Yet More SQL SELECT ORDER BY. SQL SELECT Overview. ORDER BY Example. ORDER BY Example. Yet more SQL

In This Lecture Yet More SQL Database Systems Lecture 9 Natasha Alechina Yet more SQL ORDER BY Aggregate functions and HAVING etc. For more information Connoly and Begg Chapter 5 Ullman and Widom Chapter

### Q1: Multiple choice / 20 Q2: C input/output; operators / 40 Q3: Conditional statements / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

EECE.2160: ECE Application Programming Spring 2017 Exam 1 February 17, 2017 Name: Section (circle 1): 201 (Dr. Li, MWF 8-8:50) 202 (Dr. Geiger, MWF 12-12:50) For this exam, you may use only one 8.5 x 11

### The Anatomy of a Large-Scale Hypertextual Web Search Engine

The Anatomy of a Large-Scale Hypertextual Web Search Engine Article by: Larry Page and Sergey Brin Computer Networks 30(1-7):107-117, 1998 1 1. Introduction The authors: Lawrence Page, Sergey Brin started

### Structure and Interpretation of Computer Programs

CS 6A Fall 25 Structure and Interpretation of Computer Programs Midterm 2 Solutions INSTRUCTIONS You have 2 hours to complete the exam. The exam is closed book, closed notes, closed computer, closed calculator,

### This quiz is open book and open notes, but do not use a computer.

1. /15 2. /10 3. /10 4. /18 5. /8 6. /13 7. /15 8. /9 9. /1 10. /1 Total /100 This quiz is open book and open notes, but do not use a computer. Please write your name on the top of each page. Answer all

### Variable and Data Type I

Islamic University Of Gaza Faculty of Engineering Computer Engineering Department Lab 2 Variable and Data Type I Eng. Ibraheem Lubbad September 24, 2016 Variable is reserved a location in memory to store

### CIS 110 Introduction to Computer Programming 8 October 2013 Midterm

CIS 110 Introduction to Computer Programming 8 October 2013 Midterm Name: Recitation # (e.g., 201): Pennkey (e.g., eeaton): My signature below certifies that I have complied with the University of Pennsylvania

### Information Retrieval

Introduction to Information Retrieval CS3245 Information Retrieval Lecture 6: Index Compression 6 Last Time: index construction Sort- based indexing Blocked Sort- Based Indexing Merge sort is effective

### Raspberry Pi Basics. CSInParallel Project

Raspberry Pi Basics CSInParallel Project Sep 11, 2016 CONTENTS 1 Getting started with the Raspberry Pi 1 2 A simple parallel program 3 3 Running Loops in parallel 7 4 When loops have dependencies 11 5

### Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1

Natural Semantics Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1 1 Natural deduction is an instance of first-order logic; that is, it is the formal

### Lesson 9: Introduction To Arrays (Updated for Java 1.5 Modifications by Mr. Dave Clausen)

Lesson 9: Introduction To Arrays (Updated for Java 1.5 Modifications by Mr. Dave Clausen) 1 Lesson 9: Introduction Objectives: To Arrays Write programs that handle collections of similar items. Declare

### Midterm 2: CS186, Spring 2015

Midterm 2: CS186, Spring 2015 Prof. J. Hellerstein You should receive a double-sided answer sheet and an 8-page exam. Mark your name and login on both sides of the answer sheet, and in the blanks above.

### The Warhol Language Reference Manual

The Warhol Language Reference Manual Martina Atabong maa2247 Charvinia Neblett cdn2118 Samuel Nnodim son2105 Catherine Wes ciw2109 Sarina Xie sx2166 Introduction Warhol is a functional and imperative programming

### 1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl?

Exercises with solutions. 1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl? #include b) What using statement do you always put at the top of

### def F a c t o r i a l ( n ) : i f n == 1 : return 1 else : return n F a c t o r i a l ( n 1) def main ( ) : print ( F a c t o r i a l ( 4 ) )

116 4.5 Recursion One of the most powerful programming techniques involves a function calling itself; this is called recursion. It is not immediately obvious that this is useful; take that on faith for

### Using SQLite in ArcGIS Python Scripts

Using SQLite in ArcGIS Python Scripts Leslie H. Morgan, Ph.D. Leslie.Morgan@GISNuts.com What is SQLite? The most widely deployed database engine worldwide. Transactional SQL database. Implements most of

### In the case of the dynamic array, the space must be deallocated when the program is finished with it. free(x);

C Notes Relation Between Pointers and Arrays Space for static arrays in C is allocated on the stack when the function that defines them is called and is automatically deleted when the function ends, just

### Adding Pages. Adding pages to your website is simple and powerful! In just a few minutes you can create a page that: Highlights a special event

A STEP-BY-STEP A STEP-BY-STEP GUIDE GUIDE TO TO UPDATING ADDING PAGES NAVIGATION ACADEMY Adding Pages Adding pages to your website is simple and powerful! In just a few minutes you can create a page that:

### Procedures, Parameters, Values and Variables. Steven R. Bagley

Procedures, Parameters, Values and Variables Steven R. Bagley Recap A Program is a sequence of statements (instructions) Statements executed one-by-one in order Unless it is changed by the programmer e.g.

### Rational Numbers CHAPTER Introduction

RATIONAL NUMBERS Rational Numbers CHAPTER. Introduction In Mathematics, we frequently come across simple equations to be solved. For example, the equation x + () is solved when x, because this value of

### CREATE INDEX. Syntax CREATE INDEX

CREATE INDEX Use the CREATE INDEX statement to create a new index for one or more columns in a table, a functional value on one or more columns, and, optionally, to cluster the physical table in the order

### Python and SQLite. COMP Lecture 25 March 26th, 2012 Mathieu Perreault. Monday, 26 March, 12

COMP 364 - Lecture 25 March 26th, 2012 Mathieu Perreault Cherry blossoms of the Japanese Yoshino variety bloom along the Tidal Basin, March 19, 2012, in Washington, DC, with the Jefferson Memorial to the

### Name Section: M/W T/TH Number Definition Matching (8 Points)

Name Section: M/W T/TH Number Definition Matching (8 Points) 1. (8 pts) Match the words with their definitions. Choose the best definition for each word. Iteration Counter Event Counter Loop Abstract Step

### Computer Science Foundation Exam

Computer Science Foundation Exam May 8, 015 Section I A COMPUTER SCIENCE NO books, notes, or calculators may be used, and you must work entirely on your own. SOLUTION Question # Max Pts Category Passing

### Contextual Search using Cognitive Discovery Capabilities

Contextual Search using Cognitive Discovery Capabilities In this exercise, you will work with a sample application that uses the Watson Discovery service API s for cognitive search use cases. Discovery

### Key Differences Between Python and Java

Python Python supports many (but not all) aspects of object-oriented programming; but it is possible to write a Python program without making any use of OO concepts. Python is designed to be used interpretively.

### Knowledge Discovery and Data Mining 1 (VO) ( )

Knowledge Discovery and Data Mining 1 (VO) (707.003) Data Matrices and Vector Space Model Denis Helic KTI, TU Graz Nov 6, 2014 Denis Helic (KTI, TU Graz) KDDM1 Nov 6, 2014 1 / 55 Big picture: KDDM Probability

### EECS 211 Fundamentals of Computer Programming II Homework #5. Homework #5. Released: Due: :59pm

Homework #5 Released: 02-08-2018 Due: 02-15-2018 11:59pm This is the first homework in the homework series of our project to build a tiny network simulator. In this homework, you are required to implement

### AP Computer Science A

2017 AP Computer Science A Sample Student Responses and Scoring Commentary Inside: RR Free Response Question 2 RR Scoring Guideline RR Student Samples RR Scoring Commentary College Board, Advanced Placement

### An Introduction to Business Process Modeling using Data Flow Diagrams

An Introduction to Business Process Modeling using Data Flow Diagrams BSAD 141 Dave Novak BDIS: 2.2 (61-77) Lecture Overview Systems and Business processes Business process models Data Flow Diagrams (DFDs)

### CS1073 Exam 3, Fall 2009 page 1. Important test instructions code fragments

CS1073 Exam 3, Fall 2009 page 1 Name (please print): Important test instructions code fragments Throughout this exam, you will be asked to write a code fragment based on certain assumptions (eg., assume