Download presentation
Presentation is loading. Please wait.
Published byAndrew Cross Modified over 9 years ago
1
EECS 110: Lec 2: What is Programming? Aleksandar Kuzmanovic Northwestern University http://cs.northwestern.edu/~akuzma/classes/EECS110-s10/
2
CS != programming What is computer science (CS)? Take EECS 101
3
CS != programming What is computer science (CS)? Take EECS 101 "not equal to"
4
4 Programming CS a vehicle, not a destination programming : CS :: machining : engineering grammar : literature equations : mathematics CS != programming
5
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?
6
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"
7
Information What information does Google work with? What technical problems does Google face?
8
Information What information does Facebook work with? What technical problems does Facebook face?
9
Information What information does the iPhone work with? What technical problems does the iPhone face?
10
Computer Science and Information Information is life’s fundamental building block CS is a set of fundamental techniques for understanding and leveraging this information 10
11
Python and Idle 11 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
12
If statements (1) 12 name = raw_input('Hi... what is your name? ') if name == 'Ionut': # is it Ionut? print 'x1' else: # in all other cases... print 'x2' print 'x3' hw0pr1.py Homework 0, problem 1
13
If statements (2) 13 name = raw_input('Hi... what is your name? ') if name == 'Ionut‘: print 'x1' else: print 'x2' print 'x3'
14
If statements (3) 14 name = raw_input('Hi... what is your name? ') if name == 'Ionut': # is it Ionut? print 'x1' elif name == 'Aleksandar': print 'x2' else: # in all other cases... print 'x3' print 'x4' hw0pr1.py Homework 0, problem 1
15
If statements (4) 15 name = raw_input('Hi... what is your name? ') if name == 'Ionut': print 'x1' elif name == 'Aleksandar': print 'x2' else: print 'x3' print 'x4'
16
If statements (5) 16 name = raw_input('Hi... what is your name? ') if name == 'Ionut': # is it Ionut? print 'x1' elif name == 'Aleksandar': print 'x2' elif name == ‘Lisa': print 'x3' else: # in all other cases... print 'x4' print 'x5' hw0pr1.py Homework 0, problem 1
17
If statements (6) 17 name = raw_input('Hi... what is your name? ') if name == 'Ionut‘: print 'x1' elif name == 'Aleksandar’: print 'x2' elif name == 'Lisa': print 'x3' else: print 'x4' print 'x5'
18
What is programming? 18 Programming as learning a foreign language 1) Expect it to be different! 2) Don’t feel you need to memorize it 3) Immersion == Experimentation
19
The foreign language of Python… 19 syntax? How it looks semantics? What it does intent? What it should do name = raw_input('Hi... what is your name? ') print # prints a blank line if name == 'Ionut': # is it Ionut? 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, '!'
20
The foreign language of Python… 20 syntax? How it looks semantics? What it does intent? What it should do name = raw_input('Hi... what is your name? ') print # prints a blank line if name == 'Ionut': # is it Ionut? 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, '!'
21
The foreign language of Python 21 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 …
22
HW 0, Problem 2 22 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…
23
Homework problems 3 and 4 23 Picobot area not covered (yet!) Picobot walls area already covered Goal: whole-environment coverage with only local sensing … inspiration?
24
Picobot 24 area not covered (yet!) Goal: whole-environment coverage with only local sensing … area already covered Picobot walls iRobot's Roomba vacuum inspiration!
25
Surroundings 25 N W E S Picobot can only sense things directly to the N, E, W, and S For example, here its surroundings are NxWxNxWx N E W S Surroundings are always in NEWS order.
26
How many distinct surroundings are there? N E W S xxxxNxxxxExxxxWxxxxSNExxNxWxNxxS xEWxxExSxxWSNEWxNExSNxWSxEWSNEWS (won’t happen) == 16 possible … 2424 Surroundings
27
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.
28
Rules Picobot moves according to a set of rules: state I am in state 0. My surroundings are xxWS. surroundings 0 xxWS 0N directionnew state If I'm in state 0 seeing xxWS, Then I move N orth, and change to state 0. Aha! I should move N. I should enter state 0.
29
Wildcards Asterisks * are wild cards. They match walls or empty space: 0 x*** 0N statesurroundingsdirectionnew state here, EWS may be wall or empty space I am in state 0. My surroundings are xxWS. Aha! This matches x***
30
What will this set of rules do to Picobot? 0 x*** 0N 0 N*** 1X 1 ***x 1S 1 ***S 0X statesurroundingsdirectionnew 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. ->
31
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)
32
Alter these "up & down" rules so that Picobot will traverse the empty room… the empty room
33
Ideas for the maze? the maze
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.