36
CSC 160 CSC 160 Computer Programming Computer Programming for Non-Majors for Non-Majors Introduction Introduction Prof. Adam M. Wittenstein Prof. Adam M. Wittenstein [email protected] [email protected] http://www.adelphi.edu/~wittensa/csc160/ http://www.adelphi.edu/~wittensa/csc160/

CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein [email protected]/csc160

  • View
    214

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

CSC 160CSC 160Computer ProgrammingComputer Programming

for Non-Majorsfor Non-Majors

IntroductionIntroduction

Prof. Adam M. WittensteinProf. Adam M. Wittenstein

[email protected]@adelphi.edu

http://www.adelphi.edu/~wittensa/csc160/http://www.adelphi.edu/~wittensa/csc160/

Page 2: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

What's this course about?

● Fundamentals of computer programming● Going from a word problem to a working

program● Designing programs to be modified and reused● How computer scientists think

Page 3: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

What's this course not about?

● A particular programming language– (e.g. Scheme, Java, C++, perl, ...)

● A particular programming environment– (e.g. DrScheme, Visual Studio, ...)

● Designing and writing Web pages● Arithmetic

Page 4: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

However, we have to use...

● A programming language– (we'll use Scheme)

● A programming environment– (we'll use DrScheme)

● The Web– (for textbook, assignments, announcements, ...)

● Arithmetic (as an example we all know)

Page 5: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Who should take this course?

● Non-CS majors for Math/CS distribution credit● Math and CIS majors for programming credit● Undecided majors to “test the waters” of

programming● CS majors as a “warm-up” to CSC 171

Page 6: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Who should not take this course?

● CS majors for major credit● End-users and Web page authors● Students needing to fulfill the Second

Competency requirement ● Students looking for a “cake” course

– This course does require an average of 9 hours a week: 3 in class, and 6 in reading and homework

Page 7: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

This course as a Liberal Arts Requirement

● This course trains you to think logically by focusing on Design Recipes: beginning from a problem statement and ending with a well-organized solution, a skill that is useful throughout college and life, regardless of your choice of profession.

● Many professions require some form of computer programming. Some examples include: accounting, photography, music, and of course, computer science.

Page 8: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Getting Started: A Course Overview

Computers do many of the same things people do.

The differences are that computers are:● faster and more accurate● they do not get bored

To program a computer:

• Figure out how you would solve a problem. • Present that explanation to the computer.

Page 9: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Course Overview (continued)

Unfortunately, computers are literal-minded andhave no intuition. So your explanation has to bemore precise than if you were explainingsomething to a human being.

Therefore, this course is about:

• Figuring out precisely how you would solve a problem.

• Presenting that explanation to the computer.

Page 10: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Imagine this assignment...

● 20-page paper● Due at end of semester● On Napoleon's invasion of Russia

Page 11: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

What kinds of knowledge are needed?

1. How to write a 20-page paper2. How to finish a long-term project on time3. Napoleon & Russia

Page 12: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Imagine this assignment...

● 20-page paper● Due at end of semester● On Napoleon's invasion of Russia● In Swedish● With a quill pen

Page 13: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

What kinds of knowledge are needed?

1. How to write a 20-page paper2. How to finish a long-term project on time3. Napoleon & Russia4. Swedish language (spelling, vocabulary,

grammar, idioms…)5. How to use a quill pen

Page 14: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

In a programming course...

1. How to structure a program(understand the problem and design a solution)

2. How to plan your time(going through the steps of the Design Recipes)

3. Content-area knowledge(math, graphics, economics, physics, spelling, etc.)

4. Scheme (or C++ or Java or whatever) language5. How to use the software & hardware

Page 15: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Our Focus

Although we need to do all five of these things, our goal is learning how to do the first two.

However, all problems require:● Knowledge (in some content area)● Language (like English)● Thinking Tools (like your brain)

Page 16: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Content-area Knowledge

● This is not a course on math or science or English, but we will solve problems from these disciplines.

● No need to worry, I will either give you the required information, or you will be allowed to look it up.

Page 17: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Writing and Thinking

● Outside this class, we write in a language called English. Inside this class, we will write in a language called Scheme.

● Outside this class, we use our brain to think about what is being said in English. Inside this class, we use Dr. Scheme to think about what is being said in Scheme.

Page 18: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Scheme is to English

● Scheme - The programming language that we will use.

● Dr. Scheme - the program that we will use to run programs written in Scheme.

As Dr. Scheme is to the brain

Page 19: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Choosing a Language to Speak

● We can speak in any language. Why do we choose English?

Page 20: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Choosing a Language to Speak

● We can speak in any language. Why do we choose English?

● Because we already know enough of it to understand the basics of how it works.

Page 21: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Choosing a Language to Program In

● We can program in any programming language. Why do we choose Scheme?

Page 22: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Choosing a Language to Program In

● We can program in any programming language. Why do we choose Scheme?

● Because we can quickly learn enough of it to understand the basics of how it works.

Page 23: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Design Recipe (in Life)Design Recipe (in Life)

To solve To solve anyany problem, in problem, in anyany area (not just area (not justprogramming), requires three steps: programming), requires three steps:

Figure out what you need to do. Figure out what you need to do.

Do it.Do it.

Check that you did it right. Check that you did it right.

Page 24: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Design Recipe (in Programming)Design Recipe (in Programming)

To make this recipe useful, we need to adapt itTo make this recipe useful, we need to adapt itmore specifically to computer programming:more specifically to computer programming:

Figure out Figure out preciseprecisely what you need to do. ly what you need to do.

Tell the computer how to do it.Tell the computer how to do it.

Check that the computer does it right. Check that the computer does it right.

Page 25: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

CSC 160CSC 160Computer ProgrammingComputer Programming

for Non-Majorsfor Non-Majors

Chapter 1: Students, Teachers, ComputersChapter 1: Students, Teachers, Computers

Prof. Adam M. WittensteinProf. Adam M. Wittenstein

[email protected]@adelphi.edu

http://www.adelphi.edu/~wittensa/csc160/http://www.adelphi.edu/~wittensa/csc160/

Page 26: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

A few preliminary definitions

● Program - A set of instructions that tell the computer how to perform a task

● Programming - Writing a program ● Programming language - a language of

instruction for a computer program ● Data - Information that is used by a program ● Operations - The individual instructions

performed by the computer ● Primitive operations - The basic operations

performed on data of a specific data type. – e.g., +, -, *, / are primitive operations performed on

integers.

Page 27: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Some typical problems in English

● The temperature is 350C; convert this temperature into Fahrenheit.

● Are there 7 days in a week?

● How do we cover someone’s face in a picture?

Page 28: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

What the computer would think?

● The computer would have no idea what we are asking it.

Page 29: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

What the computer would think?

● The computer would have no idea what we are asking it.

● We must communicate with the computer in a language that it understands.

Page 30: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

What the computer would think?

● The computer would have no idea what we are asking it.

● We must communicate with the computer in a language that it understands.

● We will communicate in the Scheme language.

Page 31: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Types of Data

There are many types of data. They are split into two general categories:

1) atomic (simple) data – numbers, booleans, symbols, images, etc.

2) compound data – structures and lists composed of other pieces of data. For example, a series (list) of numbers.

The next several chapters deal only with atomic data.Sometime after the midterm, we will extend ourprogramming to compound data.

Page 32: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Course web page:http://www.adelphi.edu/~wittensa/csc160

I recommend you visit the web page frequently as Iwill post important information including:

– the lecture slides (so you can find out what you missed, if you are absent)

– reading and programming assignments

– assignment corrections (and perhaps, extensions)

– class cancellations (in the event of weather, or some other emergency)

Page 33: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Reading assignments for next time...

● Read the Syllabus.

● Read the Joys (and Woes) of the Craft of Programming.

● Read the preface of the textbook (pages xvii to xxiv).

● Read Chapter 1 of the textbook (pages 1 to 5).

Page 34: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Homework #1 (due SUNDAY)

● Write a short essay (at least 1-2 pages) that summarizes and gives your opinion on each of the above reading assignments, and turn them in by email to [email protected].

● Be sure to include your first and last name!

● The essay will be graded primarily on whether I'm convinced you've read the material and thought about it carefully, although really bad spelling, grammar, or style may cost you points too.

Page 35: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Homework #2 (due NEXT SUNDAY)

Go to HW2 on the course website:

● Download DrScheme

● Start reading the draft chapter. Before the next class, read the introduction and Flying a UFO sections. For now, it is up to you whether to try or skip the exercises.

● Make a list of anything you do not fully understand in the reading and bring it up at the beginning of the next class.

Page 36: CSC 160 Computer Programming for Non-Majors Introduction Prof. Adam M. Wittenstein adamwittenstein@adelphi.eduwittensa/csc160

Next time…An Overview: The UFO Example

● We will learn how to do the first step – flying a UFO.

● More specifically, we will learn how to write a our first program – one that changes the UFO’s location on the computer screen.