Introduction - Northwestern University
Download
Report
Transcript Introduction - Northwestern University
EECS 110: Introduction to
Programming for Non-Majors
Oliver Cossairt
Northwestern University
http://ollie-imac.cs.northwestern.edu/~ollie/eecs110/
If you take only one thing today
http://ollie-imac.cs.northwestern.edu/~eecs110/eecs110/
2
Who am I?
Oliver Cossairt
Office:
Ford 3-337
Email:
[email protected]
Research area:
Computational photography
3
What course is this?
•
EECS 110: Introduction to Programming for
Non-Majors
• Based on a Harvey Mudd College’s
Introduction to Computer Science course
4
Application Domains
Web and Internet development
Database access
Desktop GUIs
Scientific and numeric applications
– Bioinformatics, physics…
Education
Network programming
Software development
Games and 3D graphics
5
Why EECS110?
The key is to teach you to effectively program!
6
Syllabus
TTh: 4:00 – 4:50
Lectures
Key skills, topics, and their motivation
Insight into the HW problems (what, why, how)
Required! Let me know if you won’t make it
“Lab /
Office Hours”
WF: 10:00 am – 1:00;
Will SAVE you time and effort in EECS110!
OFFICE HOURS IN WILKINSON LAB
HW
Sunday nights: due by 11:59 pm
HOMEWORK 0 DUE THIS SUNDAY!
7
Coursework
1.
2.
3.
4.
Seven assignments (1 per week)
Final Project (2 weeks)
Midterm
Final Exam
8
Homework
Submit all assignments to
CANVAS
Assignments
~ 4-5 problems/week
~ 100 points
20-25% extra credit available
Due Sunday evening - by 11:59 pm. You can submit 3 homeworks 1 day later
"Late Days"
Some problems are specified “individual-only.”
Others offer the option of working in a pair.
Collaboration
•You must share the work equally - typing and coaching
•Each of you should make ONE submission (2 per team)
•Be sure to indicate who your partner was at the submission site!
Honor Code
9
Honor Code
•
You may not share written, electronic or
verbal solutions with other students (present or past):
• You are encouraged to discuss problems with
other students, TAs, or instructors.
• You may not share written, electronic or verbal
solutions with other students (present or past):
• Copying of files except those provided by the
course material.
You will have the option of working in pairs for MANY of each
week’s problems: the same guidelines apply for each pair.
10
Grading
Grades
Based on points percentage
if perc >= .90: grade = 'A'
elif perc >= .80: grade = ‘B'
elif perc >= .70: grade = 'C'
~ 75% Assignments
~ 25% Exams
Extra ~ 5% Participation
Exams
Note!
Midterm
Thu February 2
Final
Thu March 9
To pass EECS 110, you must have a passing grade on
both the exams and HW.
11
Book
CS for Scientists and Engineers, by C.
Alvarado, Z. Dodds, G. Kuenning, and R.
Libeskind-Hadas (Note: this is a preliminary
draft!)
Available at:
http://networks.cs.northwestern.edu/EECS110
-s13/cs5book.pdf
• (there is a direct link from the documentation page)
The book is recommended, but NOT required
12
Software and Web site
Programs: Python and Idle
open source, free from
www.python.org
installation instructions on the Web site
MAKE SURE TO DOWNLOAD
python-3.2.2
13
Getting help!
•
•
Labs / Office Hours
•
You should attend the labs because they will have
you solve about 50% of your homework
•
Professor, 2 TA’s and 1 grader will be there.
Recitations
•
•
There will be a recitation class each Friday (1010:50 am): help with the rest 50% of the homework
Other Office Hours
•
Friday: 3:30-6pm (Wilkinson - hopefully).
•
Sunday: TBD
Communication
Professor:
Oliver Cossairt: [email protected]
TAs
Zihao (Winston) Wang: [email protected]
Chia-Kai Yeh: [email protected]
Graders:
Pranav Dhigra: [email protected]
Jeanette Pranin: [email protected]
Eric Hao: [email protected]
Nurid Dintussipov: [email protected]
Sebastian Perez: [email protected]
Vickie Li: [email protected]
Office hours:
15
Homework problems 3 and 4
Picobot
walls
Picobot
area not
covered
(yet!)
area
already
covered
Goal: whole-environment coverage
with only local sensing…
inspiration?
16
Picobot
walls
Picobot
area not
covered
(yet!)
area
already
covered
iRobot's Roomba vacuum
inspiration!
Goal: whole-environment coverage
with only local sensing…
17
Surroundings
Picobot can only sense things
directly to the N, E, W, and S
N
E
W
S
For example, here its surroundings are
NxWx
N E W S
Surroundings are
always in NEWS order.
18
Surroundings
How many distinct
surroundings are there?
N
E
W
S
24 == 16 possible …
xxxx
Nxxx
xExx
xxWx
xxxS
NExx
NxWx
xEWx
xExS
xxWS
NEWx
NExS
NxWS
xEWS
NxxS
NEWS
(won’t happen)
State
I am in state 0.
My surroundings
are xxWS.
Picobot's memory is a single
number, called its state.
State is the internal context of
computation.
Picobot always starts in state 0.
State and surroundings represent
everything the robot knows about the world
Rules
I am in state 0.
My surroundings
are xxWS.
Aha!
I should move N.
I should enter state 0.
Picobot moves according to a set of rules:
state
0
surroundings
xxWS
If I'm in state 0
seeing xxWS,
direction
new state
N
0
Then I move North, and
change to state 0.
Wildcards
I am in state 0.
My surroundings
are xxWS.
Aha! This matches x***
Asterisks * are wild cards.
They match walls or empty space:
state
0
surroundings
x***
direction
new state
N
0
here, EWS may be wall or empty space
What will this set of rules do to Picobot?
state
surroundings
0
0
x***
N***
1
1
***x
***S
direction
new state
->
->
N
X
0
1
->
->
S
X
1
0
Picobot checks its rules from the top each time.
When it finds a matching rule, that rule runs.
Only one rule is allowed per state and surroundings.
To do
Write rules that will always cover these two rooms.
(separate sets of rules are encouraged…)
hw0, Problem #3 (Extra)
hw0, Problem #4 (Extra)
but your rules should work regardless of Picobot's starting location
Alter these "up & down" rules so
that Picobot will traverse the empty
room…
the empty room
Ideas for the maze?
the maze
Python and Idle
Editor window: code
Shell window: running code
Here, you can save and change
programs. Hitting F5 runs your
program over in the shell
Here, you can try things out at
the command prompt >>>
27
If statements (1)
name = input('Hi... what is your name? ')
if name == ’Ning':
print('x1’)
# is it Ning?
else:
print('x2’)
# in all other cases...
print('x3’)
hw0pr1.py
Homework 0, problem 128
If statements (2)
name = input('Hi... what is your name? ')
if name == ’Ning‘:
print('x1’)
else:
print('x2’)
print('x3’)
29
The foreign language of Python…
syntax?
How it looks
semantics?
What it does
intent?
What it should do
name = input('Hi... what is your name? ')
print
# prints a blank line
if name == ’Ning':
# is it Ning?
print( name, '??’)
print(‘You must be a TA!')
elif name == ‘Aleksandar’:
# is it Aleksandar?
print( ‘You must be an instructor!')
else:
# in all other cases...
print( 'Welcome to Python,', name, '!')
30
The foreign language of Python…
syntax?
How it looks
semantics?
What it does
intent?
What it should do
name = input('Hi... what is your name? ')
print
# prints a blank line
if name == ’Ning':
# is it Ning?
print( name, '??’)
print(‘You must be a TA!')
elif name == ‘Aleksandar’:
# is it Aleksandar?
print( ‘You must be an instructor!')
else:
# in all other cases...
print( 'Welcome to Python,', name, '!')
31
The foreign language of Python
syntax?
How it looks
semantics?
What it does
intent?
What it should do
• how punctuation is used
• the language keywords that are used
• use of whitespace
• peculiarities of formatting
• how behavior is affected …
32
HW 0, Problem 2
syntax?
How it looks
semantics?
What it does
intent?
What it should do
• Save hw0pr1.py under a new name, hw0pr2.py
• Change hw0pr2.py to play rock-paper-scissors.
It does not have to play fair!
Feel free to add to the dialog, if you wish…
• Submit your hw0pr2.py in the usual way.
Stepping back from Python for a moment…33