Skip to main content

CSC 151.01, Class 04: Numeric Computation

Overview

  • Preliminaries
    • Notes and news
    • Upcoming work
    • Extra credit
    • Questions
  • Quiz
  • About types
  • Lab
  • Debrief (?)

News / Etc.

  • We have a lot of preliminaries today. Sorry!
  • It appears that there was a problem with links on the news page. I think I have fixed it. Let me know if you encounter other problems. And yes, it’s fine if your email says PROBLEM (or QUESTION, when you have a question).
  • Lab writeups will start Monday. Generally, I pick one question from the lab and ask you to email an answer to the grader.
    • One email per group, unless you finish separately.
    • Make sure to list both group members.
  • Yes, I will take questions before the quiz.
  • Reminder: Your partner from Wednesday is your partner from HW 1.
  • I have heard some concerns that “I don’t like group work, and this class seems to have a ton of it.” I thought I should address my reasons for giving so much group work.
    • You know one from the first day: People solve problems better in groups.
    • I also firmly believe that almost no matter what you do in life, you will be called upon to collaborate with other people, people of differing skills and levels of commitment. You might as well get practice now.
    • [Story about Sam in junior high]
  • There are also concerns about class size. I can just describe past experiences in addressing these concerns.
  • The CS department maintains a mailing list of events and opportunities (and other things of potential interest).
  • Reminder: Starting next week, we will have mentor sessions on Wednesday and Thursday evenings from 8:00-9:00 p.m. Wednesdays will be more Q&A, Thursdays will include sample quizzes.
  • Reminder: We have tutors available Sunday through Thursday evening from 7-10 p.m. in Science 3813/15.
  • Friday PSA. Be responsible to yourself and to others.

Upcoming Work

Extra credit (Academic/Artistic)

  • One of the Camille A Brown events
    • Dialogue/Conversation: Arts & Activism. Friday January 27 4:15-5:15PM, BCA 152
    • Master Class (Open to All): A Journey through Juba and Other Social Dances. Saturday January 28, 11-12:30PM, Bucksbaum Dance Studio
    • Performance: Black Girl A Linguistics Play. Saturday January 28, 7:30PM Roberts Theatre. Get tickets at Bucksbaum!
  • CS Table, Tuesday, noon, middle PDR: Planning for the semester.
  • Thursday extras, Thursday, 4:15 p.m., Science 3821: LaTeX

Extra credit (Peer)

  • Open practice for Ritalin Test Squad, 2-4 Saturday in the Wall.
  • Swim meet next weekend.

Good things to do

  • Moderation.

Questions

How should I title my extra credit email?

CSC 151 Extra Credit (Your Name Here)

When will we get homework 1 back?

Monday, I hope. (40 students x 15 min/assignment = 10 hours)

How long is the quiz?

Ten minutes.

Do we use computers?

No, it’s on paper.

Open book?

No. Closed book.

How can I better prepare next week?

Go to mentor sessions or review session, or both.

Look at the sample quiz questions from the review and mentor sessions.

Ask questions.

If you ask us to evaluate an expression, and it has no result, what should we write?

You can write “nothing” or write nothing.

Can we ask questions about the material?

Yes.

What’s the difference between a parameter and a variable?

Shouldn’t you have asked that yesterday at the review session (if you were there)?

Parameter is something that’s given to you. Variable is something you name.

Parameter is the input to a function/subroutine/procedure.

What’s the difference between a string and a symbol? What do we use symbols for?

I’ll talk about it after the quiz.

Can we indent in the birthday algorithm?

Certainly.

What is the Scheme interpreter?

A computer program, built into DrRacket.

An algorithm

As I write it, guidelines to help you understand what is happening when the computer attempts to run your program.

How many copies of our HW should we submit?

One per group. Make sure to mention both group members.

What’s the difference between a basic operation and a subroutine?

Typically, the basic operations are the ones the programming language (or machine) provides to you and the subroutines are those you write.

Is everything you create along the way a variable?

No. Only the things you name.

Quiz

  • Ten minutes. Timed.

Types

  • Time is short enough that I’m going to do this quickly.
  • I’ll talk about symbols more another day.
  • In writing algorithms, it’s important to think about the kinds of values with which you work. (“types”)
  • Values suggest operations.
  • Pens: Throw, write
  • Index cards: Read, write-on, make-into-paper-airplane, throw
  • Throughout the semester, we will learn new types and the operations available for those types.
  • Some basic questions when I encounter a new type
    • How do I conceive of it?
    • How do I express it in Scheme?
    • How does Scheme express it back to me?
    • What operations are available to me?

Lab

  • You should try to finish this on your own (during tutor sessions is great, but you can work on it at any time).

Some notes

  • (* (sqrt 2) (sqrt 2)) is not 2 because the square root of two has an infinite number of digits, so DrRacket approximates. And when you square an approximation, you get an approximation.
  • (* (sqrt 4) (sqrt 4)) is 4 because the square root of 4 is an exact number, and DrRacket doesn’t need to approximate.
  • When you first learned division, you didn’t deal with fractional parts (at least if you learned in a typical American school). So, for example, 10/3 is 3r1 and 42/6 is 7r0. The thing that comes after the r is the remainder.
  • There is some ambiguity for negative numbers. Consider (remainder -9 8). We can think of -9 as -18 + -1 (quotient -1, remainder -1), or as -28
    • 7 (quotient -2 and remainder is 7). In the first case, the remainder is -1. In the second, the remainder is 7. For consistency, we choose the quotient that is closest to 0 (assuming that the remainder is beteween -divisor and divisor), and that tells us what the remainder is.
  • -17/8 = -2*8 + -1.

Debrief

Nope