Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSC 160 Computer Programming for Non-Majors Lecture #3a: Stepper, Words, Sentences (continued) Prof. Adam M. Wittenstein

Similar presentations


Presentation on theme: "CSC 160 Computer Programming for Non-Majors Lecture #3a: Stepper, Words, Sentences (continued) Prof. Adam M. Wittenstein"— Presentation transcript:

1 CSC 160 Computer Programming for Non-Majors Lecture #3a: Stepper, Words, Sentences (continued) Prof. Adam M. Wittenstein Wittenstein@adelphi.eduhttp://www.adelphi.edu/~wittensa/csc160/

2 The Debug Button Last class, I said the Simply Scheme mode does not have a Stepper. There is actually a Debug button in place of the Step button. It is not as great, but still helpful. Let’s look at two examples from last class using Debug:

3 The Debug Button (+ 3 (* 4 5)) Step One: (* 4 5) = 20 Step Two: (+ 3 (* 4 5)) = 23 (item 4 (item 3 ‘(Today is Thursday September Seven))) Step One: (item 3 ‘(Today is Thursday September Seven))) = Thursday Step Two: (item 4 (item 3 ‘(Today is Thursday September Seven))) = r

4 Questions from Simply Scheme Do 5.3 on page 66. Do 5.3 on page 66. Do 5.11 on page 67. Do 5.11 on page 67.

5 Solutions to Questions 5.3 and 5.11 5.3: (first ‘mezzazine) = m *Returns the first letter of the word. (first ‘(mezzazine)) = ‘mezzazine *Returns the first word of the sentence. 5.11: For last to return a word, it needs to be given a sentence that ends with a word. For last to return a sentence, it needs to be given a sentence that ends with a sentence.

6 REVIEW: Converting from math notation to Scheme notation 1)Expand abbreviations 2)Parenthesize all subexpressions that have an operator. Should end up w/same number of operators, left-parentheses, and right-parentheses. 3)Move each operator to just after its own left parenthesis. 3z becomes 3 * z b 2 becomes b * b 3*3+4*5 becomes ( (3 * 3) + (4 * 5) ) b 2 - 4ac becomes ( (b * b) - (4 * a * c) ) ( (3 * 3) + (4 * 5) ) becomes ( + (* 3 3) (* 4 5) ) ( (b * b) - (4 * a * c) ) becomes (- (* b b) (* 4 a c) )

7 Translation Exercise 3x - 6/x 3x - 6/x √(b 2 -4ac) √(b 2 -4ac)

8 What’s on the Quiz? Atomic (Simple) Data Types –numbers, words, sentences, booleans Expressions / Calling Functions –subexpression: an expression inside of another expression. Vocabulary –function, argument, return value

9 What functions may be on the quiz? Numbers – +, -, *, / Words and sentences: –first, last, butfirst (bf), butlast –item, every, member?, vowel? –keep, word, sentence

10 Types of Quiz questions Translate a mathematical expression into Scheme. Translate a Scheme expression into math notation. Translate an expression about words or sentences into Scheme. Explain what a Scheme function on words or sentences means. Step through a problem (with numbers, words, or sentences) using the approach of your choice: Stepper, Debug, Little People

11 III. Preparing for Next Class

12 Next time… We will call functions involving pictures. Then, time permitting, we will see how to define variables. We will have a 20-25 minute quiz at the end of class.


Download ppt "CSC 160 Computer Programming for Non-Majors Lecture #3a: Stepper, Words, Sentences (continued) Prof. Adam M. Wittenstein"

Similar presentations


Ads by Google