eecs 110: lec 2: what is programming? aleksandar kuzmanovic northwestern university
TRANSCRIPT
![Page 1: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/1.jpg)
EECS 110: Lec 2: What is Programming?
Aleksandar Kuzmanovic
Northwestern University
http://networks.cs.northwestern.edu/EECS110-s15/
![Page 2: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/2.jpg)
Grading
2
Note!
Grades
Exams
Based on points percentage
if perc >= .90: grade = 'A'elif perc >= .80: grade = ‘B'elif perc >= .70: grade = 'C'
Midterm Wed April 29
~ 75% Assignments
Extra ~ 5% Participation~ 25% Exams
Final Wed June 3
To pass EECS 110, you must have a passing grade on both the exams and HW. I will also give quizzes in the
class, but they will not be graded.
![Page 3: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/3.jpg)
Getting help! • Labs
• You should attend the labs because they will have you solve about 50% of your homework
• Recitations
• There will be a recitation class each Friday (10-10:50 am): help with the rest 50% of the homework
• Office Hours
• TA1: Friday 1-3 pm (Wilkinson).
• TA2: Sunday (3-5 pm) (Wilkinson)
• Professor: Tuesday: 9-12 (Wilkinson).
![Page 4: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/4.jpg)
4
Communication • Professor:
• TAs:
• Ning Xia [email protected]
• Xitao Wen [email protected]
• Bhavita Jaiswal [email protected]
• Juan Li [email protected]
• Group e-mail:
• [email protected] (all students, TAs, and the professor)
![Page 5: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/5.jpg)
5
Teaching Assistants
Ning Xia
Xitao Wen
![Page 6: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/6.jpg)
6
Teaching Assistants
Bhavita Jaiswal Juan Li
![Page 7: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/7.jpg)
Homework
7
Assignments~ 4-5 problems/week ~ 100 points 20-25% extra credit
availableDue Sunday evening - by 11:59 pm. You can submit 3 homeworks 1 day later
Collaboration
Some problems are specified “individual-only.”
Others offer the option of working in a pair.
•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
"Late Days"
![Page 8: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/8.jpg)
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.
8
You will have the option of working in pairs for MANY of each week’s problems: the same guidelines apply for each pair.
![Page 9: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/9.jpg)
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-s15/cs5book.pdf
• (there is a direct link from the documentation page)
The book is recommended, but NOT required
9
![Page 10: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/10.jpg)
Software and Web site
Web page:http://networks.cs.northwestern.edu/EECS110-s15/
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
10
![Page 11: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/11.jpg)
Submission site
11
http://ivy.cs.northwestern.edu/users/sign_in
Username: …………… Password: …………… Submit
![Page 12: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/12.jpg)
Submission site
12
Username: …………… Password: ……………
Welcome aleksandar
Upload your assignment
Choose a file to upload: ……………
Password ChangeOld Password: ……………
New Password: ……………
Confirm Password: ……………
http://ivy.cs.northwestern.edu/users/sign_in
Submit
Upload File
Browse...
Change Password
Logout
![Page 13: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/13.jpg)
Submission site
13
Username: …………… Password: ……………
Welcome aleksandar
Upload your assignment
Choose a file to upload: ……………
Password ChangeOld Password: ……………
New Password: ……………
Confirm Password: ……………
How to get login/password:[email protected]
http://ivy.cs.northwestern.edu/users/sign_in
Submit
Upload File
Browse...
Change Password
Logout
![Page 14: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/14.jpg)
Homework problems 3 and 4
14
Picobot
area not covered
(yet!)
Picobotwalls
area already covered
Goal: whole-environment coverage with only local sensing…
inspiration?
![Page 15: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/15.jpg)
Picobot
15
area not covered
(yet!)
Goal: whole-environment coverage with only local sensing…
area already covered
Picobotwalls
iRobot's Roomba vacuum
inspiration!
![Page 16: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/16.jpg)
Surroundings
16
N
W E
S
Picobot can only sense things directly to the N, E, W, and S
For example, here its surroundings are
NxWxN E W S
Surroundings are always in NEWS order.
![Page 17: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/17.jpg)
How many distinct surroundings are there?
N
EW
S
xxxx Nxxx xExx xxWx xxxS NExx NxWx NxxS
xEWx xExS xxWS NEWx NExS NxWS xEWS NEWS(won’t happen)
== 16 possible …24
Surroundings
![Page 18: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/18.jpg)
State
Picobot's memory is a single number, called its state.
State is the internal context of computation.
State and surroundings represent everything the robot knows about the world
Picobot always starts in state 0.
I am in state 0. My surroundings
are xxWS.
![Page 19: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/19.jpg)
Rules
Picobot moves according to a set of rules:
state
I am in state 0. My surroundings
are xxWS.
surroundings
0 xxWS 0N
direction new state
If I'm in state 0 seeing xxWS,
Then I move North, and change to state 0.
Aha!I should move N.
I should enter state 0.
![Page 20: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/20.jpg)
Wildcards
Asterisks * are wild cards. They match walls or empty space:
0 x*** 0N
state surroundings direction new state
here, EWS may be wall or empty space
I am in state 0. My surroundings
are xxWS.Aha! This matches x***
![Page 21: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/21.jpg)
What will this set of rules do to Picobot?
0 x*** 0N
0 N*** 1X
1 ***x 1S
1 ***S 0X
state surroundings direction new state
Picobot checks its rules from the top each time.
Only one rule is allowed per state and surroundings.
When it finds a matching rule, that rule runs.
->
->
->
->
![Page 22: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/22.jpg)
To do Write rules that will always cover these two rooms.(separate sets of rules are encouraged…)
but your rules should work regardless of Picobot's starting location
hw0, Problem #3 hw0, Problem #4 (Extra)
![Page 23: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/23.jpg)
Alter these "up & down" rules so that Picobot will traverse the empty room…
the empty room
![Page 24: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/24.jpg)
Ideas for the maze?
the maze
![Page 25: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/25.jpg)
Python and Idle
25
Editor window: code Shell window: running code
Here, you can try things out at the command prompt >>>
Here, you can save and change programs. Hitting F5 runs your
program over in the shell
![Page 26: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/26.jpg)
If statements (1)
26
name = input('Hi... what is your name? ')
if name == ’Ning': # is it Ning? print('x1’) else: # in all other cases... print('x2’)
print('x3’)
hw0pr1.py Homework 0, problem 1
![Page 27: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/27.jpg)
If statements (2)
27
name = input('Hi... what is your name? ')
if name == ’Ning‘: print('x1’) else: print('x2’)
print('x3’)
![Page 28: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/28.jpg)
CS != programming
What is computer science (CS)?Take EECS 101
![Page 29: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/29.jpg)
CS != programming
What is computer science (CS)?Take EECS 101
"not equal to"
![Page 30: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/30.jpg)
30
Programming
CS
a vehicle, not a destination
programming : CS ::
machining : engineering
grammar : literature
equations : mathematics
CS != programming
![Page 31: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/31.jpg)
CS == computing science
Study of complexity (or complex things?)
How can it be done?
How well can it be done?
Can it be done at all?
![Page 32: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/32.jpg)
CS == computing science
Study of complexity (or complex things?)
How can it be done?
How well can it be done?
Can it be done at all?"equal to"
![Page 33: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/33.jpg)
Information
What information does Google work with?What technical problems does Google face?
![Page 34: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/34.jpg)
Information
What information does Facebook work with?What technical problems does Facebook face?
![Page 35: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/35.jpg)
Information
What information does the iPhone work with?What technical problems does the iPhone face?
![Page 36: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/36.jpg)
Computer Science and Information
Information is life’s fundamental building block
CS is a set of fundamental techniques for understanding and leveraging this information
36
![Page 37: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/37.jpg)
What is programming?
37
Programming as learning a foreign language
1) Expect it to be different!
2) Don’t feel you need to memorize it
3) Immersion == Experimentation
![Page 38: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/38.jpg)
The foreign language of Python…
38
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, '!')
![Page 39: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/39.jpg)
The foreign language of Python…
39
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, '!')
![Page 40: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/40.jpg)
The foreign language of Python
40
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 …
![Page 41: EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University](https://reader036.vdocument.in/reader036/viewer/2022062304/56649e3f5503460f94b306a9/html5/thumbnails/41.jpg)
HW 0, Problem 2
41
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…