60 Questions (review for final exam) CSC 161: The Art of Programming Prof. Henry Kautz 12/7/2009 1.

Slides:



Advertisements
Similar presentations
Computer Programming Mr. José A. Ortiz Morris. Computer Language  Languages that the computer understands.  They are low level languages. (BINARY 1.
Advertisements

Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 8 Fruitful Functions 05/02/09 Python Mini-Course: Day 2 - Lesson 8 1.
Programming Patterns CSC 161: The Art of Programming Prof. Henry Kautz 9/30/2009.
CSE 1301 Lecture 5B Conditionals & Boolean Expressions Figures from Lewis, “C# Software Solutions”, Addison Wesley Briana B. Morrison.
ECS 15 if and random. Topic  Testing user input using if statements  Truth and falsehood in Python  Getting random numbers.
Top-Down Design CSC 161: The Art of Programming Prof. Henry Kautz 9/16/2009.
1 9/24/07CS150 Introduction to Computer Science 1 Relational Operators and the If Statement.
CS 106 Introduction to Computer Science I 09 / 14 / 2007 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 02 / 11 / 2008 Instructor: Michael Eckmann.
CSC 171 – FALL 2004 COMPUTER PROGRAMMING LECTURE 0 ADMINISTRATION.
Chapter 2 Writing Simple Programs
1 CS150 Introduction to Computer Science 1 Relational Operators and the If Statement 9/22/08.
JavaScript Lesson 1 TBE 540. Prerequisites  Before beginning this lesson, the learner must be able to… Create a basic web page using a text editor and/or.
The If/Else Statement, Boolean Flags, and Menus Page 180
Professor Jennifer Rexford COS 217
CS 106 Introduction to Computer Science I 09 / 28 / 2007 Instructor: Michael Eckmann.
Computing with Strings CSC 161: The Art of Programming Prof. Henry Kautz 9/16/2009.
Recitation 1 Programming for Engineers in Python.
CS61A Lecture 2 Functions and Applicative Model of Computation Tom Magrino and Jon Kotker UC Berkeley EECS June 19, 2012.
CPS 2231 Computer Organization and Programming Instructor: Tian (Tina) Tian.
CC0002NI – Computer Programming Computer Programming Er. Saroj Sharan Regmi Week 7.
Introduction to Python Lecture 1. CS 484 – Artificial Intelligence2 Big Picture Language Features Python is interpreted Not compiled Object-oriented language.
Line Continuation, Output Formatting, and Decision Structures CS303E: Elements of Computers and Programming.
CSC318 – DYNAMIC WEB APPLICATION DEVELOPMENT
Computing with Numbers CSC 161: The Art of Programming Prof. Henry Kautz 9/14/2009.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #002 (January 17, 2015)
An Overview of Programming in Python CSC 161: The Art of Programming Prof. Henry Kautz 9/9/2009 Slides stolen shamelessly from Dr. Mark Goadrich, Centenary.
Data Collections: Dictionaries CSC 161: The Art of Programming Prof. Henry Kautz 11/4/2009.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 6 Value-Returning.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
 Expression Tree and Objects 1. Elements of Python  Literals, Strings, Tuples, Lists, …  The order of file reading  The order of execution 2.
CS 140 Computer Programming (I) Second semester (3 credits) Imam Mohammad bin Saud Islamic University College of Computer Science and Information.
PHP Logic. Review: Variables Variables: a symbol or name that stands for a value – Data types ( Similar to C++ or Java): Int, Float, Boolean, String,
CompSci 101 Introduction to Computer Science September 23, 2014 Prof. Rodger.
Functions. Built-in functions You’ve used several functions already >>> len("ATGGTCA")‏ 7 >>> abs(-6)‏ 6 >>> float("3.1415")‏ >>>
CHAPTER#3 PART1 STRUCTURED PROGRAM DEVELOPMENT IN C++ 2 nd semester King Saud University College of Applied studies and Community Service Csc.
Xin Liu Feb 4, * Use midterm questions for previous 231/217 midterms for practices * ams
Data Collections: Lists CSC 161: The Art of Programming Prof. Henry Kautz 11/2/2009.
CSCI/CMPE 4341 Topic: Programming in Python Review: Exam I Xiang Lian The University of Texas – Pan American Edinburg, TX 78539
CSC 110 Using Python [Reading: chapter 1] CSC 110 B 1.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
ECS 15 Variables. Outline  Using IDLE  Building blocks of programs: Text Numbers Variables!  Writing a program  Running the program.
Chapter#3 Part1 Structured Program Development in C++
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
1 CS161 Introduction to Computer Science Topic #8.
Variables and Expressions CMSC 201. Today we start Python! Two ways to use python: You can write a program, as a series of instructions in a file, and.
COP 2510 Chapter 6 - Functions. Random function (randint) #import the desired function import random #integer random number in the range of 1 through.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
Repetition Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Functions CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
CSx 4091 – Python Programming Spring 2013 Lecture L2 – Introduction to Python Page 1 Help: To get help, type in the following in the interpreter: Welcome.
Loops (While and For) CSE 1310 – Introduction to Computers and Programming 1.
Lenape Middle School Math DepartmentName: _________________________ Algebra 1 Keystone PrepDate: __________________________ This year you will take the.
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
IST 210: PHP Basics IST 210: Organization of Data IST2101.
Next Week… Quiz 2 next week: –All Python –Up to this Friday’s lecture: Expressions Console I/O Conditionals while Loops Assignment 2 (due Feb. 12) topics:
CompSci 101 Introduction to Computer Science February 5, 2015 Prof. Rodger Lecture given by Elizabeth Dowd compsci101 spring151.
CSC 108H: Introduction to Computer Programming Summer 2012 Marek Janicki.
CMSC201 Computer Science I for Majors Lecture 03 – Variables
CMSC201 Computer Science I for Majors Lecture 02 – Intro to Python
CMSC201 Computer Science I for Majors Lecture 22 – Binary (and More)
Line Continuation, Output Formatting, and Decision Structures
Variables, Expressions, and IO
Introduction to Python
Line Continuation, Output Formatting, and Decision Structures
Introduction to Python
CS 456 Interactive Software.
Introduction to Programming with Python
ECS15 boolean.
Functions Taken from notes by Dr. Neil Moore & Dr. Debby Keen
Presentation transcript:

60 Questions (review for final exam) CSC 161: The Art of Programming Prof. Henry Kautz 12/7/2009 1

Schedule Today: whole course review Workshop this week: programming exercises Final exam 8:30am-10:30am on Thursday December 17, this room 64 points: multi-choice / fill in the blank 36 points: programming problems based on the exercises in this week's workshop No class this Wednesday December 9 2

1 Which of the following are mutable? String List Tuple Object

2 How can this code be made shorter? z = 1 x = 0 while (x < 10): z = z * y x = x + 1 4

3 How else can this code be made shorter? x = 1 z = 1 while (x < 10): z = z * y x = x + 1 5

4 What does this code print? x = ['a', 'b', 'c'] y = [1, 2, 3] y = x x[0] = 'd' print y 6

5 What does this code print? x = ['a', 'b', 'c'] y = [1, 2, 3] y = list(x) x[0] = 'd' print y 7

6 What does this code print? x = ['a', 'b', 'c'] y = [1, 2, 3] x = y x[0] = 'd' print y 8

7 What kind of data structure is D after D = { 'ham':9.99, 'spam':1.99 } ? 9

8 What kind of data structure is D after D = open('foo.bar', 'r') ? 10

9 What kind of data structure is D after D = open('foo.bar', 'r').read() ? 11

10 What kind of data structure is D after D = urlopen(' ? 12

11 What kind of data structure is D after D = urlopen(' ? 13

12 How is this displayed in a web browser? Don't click here! 14

13 After this is executed, what is the value of X? X = range(10, 2, -3) 15

14 After this is executed, what is the value of X? Y = 'cats and dogs' X = Y[5:8] 16

15 After this is executed, what is the value of X? X = 'cats and dogs' [5:8] 17

16 What does this do? X = 'dog' Y = 'god' if X == Y[3:0]: print "Surprise!" 18

17 What does this do? Y = 'cats and dogs' print Y[:5] + Y[5:] 19

18 What does this do? Y = 'cats and dogs' print Y[:5] + Y[5:] == Y 20

19 When would this not print True? Y = 'cats and dogs' print Y[:w] + Y[w:] == Y 21

20 How can you make this code shorter? if (x == 1): y = 'a' else: if (x == 2): y = 'b' else: y = 'c' 22

21 How else can you make this code shorter? if (x == 1): y = 'a' else: if (x == 2): y = 'b' else: y = 'c' 23

22 What is the probability that this code prints 2? R = randrange(1,7) print R 24

23 What is the probability that this code prints 2? R = randrange(1,7) + randrange(1,7) print R 25

24 What is the probability that this code prints 3? R = randrange(1,7) + randrange(1,7) print R 26

25 What do alpha, f, i, and r stand for in the following formula? 27

26 Suppose C is a graphics object. What does this do? c.move(L*cos(R), L*sin(R)) 28

27 R is in what kind of units? c.move(L*cos(R), L*sin(R)) 29

28 Assuming D is a dictionary, exactly when does this not print True? print D['Pepsi'] == D.get('Pepsi', False) 30

29 If S is a string containing the text of a novel, does the following correctly count the number of words in the novel? string.count(S, ' ') 31

30 If S is a string containing the text of a novel, does the following correctly count the number of words in the novel? len(string.split(S)) 32

31 Do the following two statements do the same thing? P = string.find(S, 'a') P = S.find('a') 33

32 Suppose the sampling rate of a WAV file is You read it in, write all the data back out to a new file (unchanged), but set the sampling rate of the new file to What does the new file sound like? 34

33 What is the difference between a compiler and an interpreter? 35

34 Define CPU and RAM. 36

35 What was the first programmable computer used for? 37

36 What is the idea of top-down design? 38

37 What is the idea of spiral design? 39

38 In software development, what comes before implementation? 40

39 In software development, what comes after implementation? 41

40 How do you determine the examples to use for testing a program? 42

41 The name of a constructor is same as the name of an object's ______________ 43

42 Which of the following is a legal Python expression that is true if and only if the value of X is in the interval from 10 to 20? (a) 10 <= X <= 20 (b) 10 <= X or X <=20 (c) X in [10, 20] (d) 10 <= X and X <= 20 44

43 Which of the following are correct for the expression (X / 2) * 2 == X (a) If X is an integer, the expression is True if and only if X is an even number. (b) If X is a floating point number, the expression is always true. (c) If X is a string, the expression is always false. (d) The expression is true if and only if X is an integer power of 2. 45

44 Which of the following mean the same thing in Python? ____ A=B means the same thing as B=A ____ A>B means the same thing as B<A ____ A!=B means the same thing as B!=A ____ A==B means the same thing as B==A ____ (A<B and A==B) means the same thing as (A<=B) 46

45 What is an easy way to change all of the '?' in a string S into periods? 47

46 Consider the following program: A = 9 B = input('Enter your answer: ') print B Suppose the user types A at the prompt. What will the program do? (a) Print 9. (b) Print the letter A. (c) Print the letter B. (d) Print an error message. 48

47 Name a computer science class offered next semester are you eligible to sign up for, having passed CS

48 Name another computer science class offered next semester are you eligible to sign up for, having passed CS

49 What was the lecture topic where this picture appeared? 51

50 What did this program do? import math import random def make_pi(darts): hits = 1 for i in range(darts): dx = random.random() dy = random.random() if math.sqrt((0.5-dx)**2 + \ (0.5-dy)**2) < 0.5: hits = hits + 1 print (4.0*hits)/darts 52

51-60 Odd numbers: make up a question! Even numbers: answer it! 53

Last Words Please complete the online evaluation Please complete the workshop problem set Okay to bring notes, textbook, and calculator to exam Congratulations! 54