welcome (back) to ist 338 ! wally homework 0 alien due sun. night (11:59pm) wow – i see the...

156
Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours program: Can be done for lab... Problem 2: Rock-paper-scissors program (Maybe done already!) Problems 3-5: Picobot! empty room (3) maze (4) + extra (5) HW page Problem 6: Reading + response… Average of these two?

Upload: maximilian-mosley

Post on 16-Jan-2016

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Welcome (back) to IST 338 !

Wally

Homework 0

Alien

due Sun. night (11:59pm)

Wow – I see the resemblance

Problem 0: Already complete!

Problem 1: Four-fours program: Can be done for lab...

Problem 2: Rock-paper-scissors program (Maybe done already!)

Problems 3-5: Picobot! empty room (3) maze (4) + extra (5)

HW pageProblem 6: Reading + response…

Average of these two?

Page 2: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Welcome (back) to IST 338 !

Wally

Homework 0

Alien

due Sun. night (11:59pm)

Picobot!

Wow – I see the resemblance

Problem 0: Already complete!

Problem 1: Four-fours program: Can be done for lab...

Problem 2: Rock-paper-scissors program (Maybe done already!)

Problems 3-5: Picobot! empty room (3) maze (4) + extra (5)

HW pageProblem 6: Reading + response…

Page 3: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Welcome back (from) Baltimore!

world's expert on badge-based incentive systems

for education…

Page 4: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Extreme RPS!?

They call that an alien?

Spock mind-melds three-eyed aliens!

Provably.

http://www.youtube.com/watch?v=iapcKVn7DdYhttp://www.youtube.com/watch?v=yuEZEyDdmvQ

Try RPS-101!

this is

definitely

worth a

badge!

Page 5: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Last time…

CS != Programming

Page 6: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

What about the Python programming language ?

Page 7: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

One possible relationship... vs.

Python ?

Page 8: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Happy co-existence… It can even be comfy!

Python !

One possible relationship... vs.

Page 9: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Exclusive Choices

if perc > .95: print 'A'

elif perc > .90: print 'A-'

elif perc > .70: print 'Pass'

else: print 'Aargh!'

if ... elif ... else

When using if . elif … . else at most one block will run: the first whose test is True. If all fail, the else will run

4 mutually exclusive blocks

elif and else are optional

in a single control structure

Page 10: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

What's the difference?

if perc > .95: print 'A'

elif perc > .90: print 'A-'

elif perc > .70: print 'Pass'

if perc > .95: print 'A'

if perc > .90: print 'A-'

if perc > .70: print 'Pass'

mutually exclusive blocks nonexclusive blocks

How many separate control structures does each side have?

What if perc == .99 ? (How would we set it?)

Page 11: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

comp = 'rock'user = 'paper'

if comp == 'paper' and user == 'paper': print 'We tie. Try again?'

elif comp == 'rock':

if user == 'scissors': print 'I win! *_*' else: print 'You win. Aargh!'

Does this program print the correct RPS result this time?

Does it always?

# of BLOCKS ?

# of TESTS ?

# of Control Structures ?

What will this do?

try it: RPS example #1

Page 12: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

comp = 'rock'user = 'rock'

if comp == 'rock':

if user == 'paper': print 'I win *_*!' elif user == 'scissors': print 'You win.'

else: print 'Tie.' print 'Ties go to the runner.' print ' - and I am running!'

# of BLOCKS # of TESTS

Counting...

... what if the else were indented?

Printing…

try it: RPS example #2

Page 13: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

How many possible “input cases” are there?

comp = 'rock'user = 'rock'

if comp == 'rock': print 'I win *_*!'

if user == 'paper': print 'You win.'

else: print 'An awful tie'

For how many is this program correct?What does this print?

try it: RPS example #3

Page 14: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

How many possible “input cases” are there?

comp = 'rock'user = 'rock'

if comp == 'rock': print 'I win *_*!'

if user == 'paper': print 'You win.'

else: print 'An awful tie'

For how many is this program correct?What does this print?

… how efficiently can RPS be represented by program?• Fewest number of blocks?• Fewest number of tests?

'rock' 'paper' 'scissors'

'rock'

'paper'

'scissors'

comp

user

Page 15: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

This week: hw0pr1

get Python running on your own machine

shell or command-line or terminal

(the execution environment)

Python source code, a plain-text file

(here, edited by the Sublime text editor)

shell prompt > or $

Python prompt >>>

Page 16: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Commanding the command-linein Windows'

plain cmdMac/Linux/Windows Powershell

pwd

ls

mkdir

mv

cp

cd

..

.

dir

move

copy

mkdir

.

. .

cd

cd . print working directory (current path)

list (current directory)

change directory

shortcut for "directory above"

shortcut for "current directory"

move (source/from) (destination/to)

copy (source/from) (destination/to)

make directory (name of new dir)

Page 17: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Mental model .. .

CS5 (folder)

(file)pico3.txtpico4.txt (file)

Desktop

CS5 (folder)

start

usual picture ~ a window into the underlying structure

Page 18: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

a couple of shortcuts…

Up arrow

• Down arrow ~ scrolls the other way

Tab key

• Brings back previously-typed commands

• Cycles through possibilities (older versions would pause…)

• Completes the file or folder name you start

Page 19: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Mental model .. .

CS5 (folder)

(file)pico3.txtpico4.txt (file)

$ mkdir BotFiles

$ cd B

$ cp ../pico3.txt .

$ mv p ..

$ cd ..

Desktop

CS5 (folder)

$ pwd

$ ls

$ cd C

dir

copy

move

$

start

cd

Page 20: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Mental model .. .

CS5 (folder)

pico4.txt (file)

$ mkdir BotFiles

$ cd B

$ cp ../pico3.txt .

$ mv p ..

$ cd ..

Desktop

CS5 (folder)

$ pwd

$ ls

$ cd C

dir

copy

move

$

end

cd .

BotFiles (folder)

BotFiles (folder)

(file)pico3.txt

(file)pico3.txt

Page 21: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Try it!

CS5 (folder)

hw0pr0.py (file)

$ mkdir Week0

$ cd ..

$ mv ../h .

Desktop

CS5 (folder)

$ cd W

move

$

start hw0pr1.py (file)

$ mkdir Week1

$ cp ../h . copy

$ cd W

$

$

Extra #2: What line here would copy the hw0pr0.py file to the current location? See if you can use tabs…Extra #1: What is the current folder here?

Draw the changes these shell commands will make…

Page 22: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Not to mention…

ping

find .

curl or wget

which

python

cat

where

type

may need to install

add ;c:\python27

This is a window into the directory tree…

if you don't want to type the full path: c:\python27\python

tree

Page 23: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

XKCD's perspective…

Page 24: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Command line?!?

The Operating System's Window Manager

Computational interactions (files, folders, data…)

Physical interactions (arithmetic and storage)

Consume

Compose

Crazy!not really fair…

Page 25: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Command line?!?

The Operating System's Window Manager

Computational interactions (files, folders, data…)

Physical interactions (arithmetic and storage)

Consume

Compose

Commoditized!

Page 26: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Useful? Consuming Composing

Page 27: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Useful?

Everything at the command line is automatable and programmable…

Consuming Composing

Page 28: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Useful!

Everything at the command line is automatable and programmable…

Consuming Composing

Page 29: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

you'll see 100% in the next 10 minutes

Another language already?

Special-purpose language

you might see 50% by the end

of the term

Python

Picobot

General-purpose language

The Picobot simulatorwww.cs.hmc.edu/picobot

Picobot!

even then, <1% of its libraries!

Page 30: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Picobot

area already covered

Picobot can't tell…

area not covered

(yet!)

Inspiration?

wallsGoal: full-room coverage with only

local sensing…

HW problems 3 and 4: Picobot!

Page 31: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Picobot

area already covered

Picobot can't tell…

area not covered

(yet!)

Roomba!

walls

HW problems 3 and 4: Picobot!

can't tell "vacuumed" from "unvacuumed" area

Goal: full-room coverage with only

local sensing…

Let's see it!

Page 32: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Surroundings

Picobot can only sense things directly to the N, E, W, and S

For example, here its surroundings are

N

EW

S

NxWxN E W S

Surroundings are always in NEWS order.

Page 33: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

What are these surroundings?

NxWxN E W S

Surroundings are always in NEWS order.

Wow - this one is disgusting!

Page 34: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

How many distinct surroundings are there?

N

EW

S

Surroundings

Page 35: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

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 possible24

Surroundings

Page 36: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

State

Picobot's memory is a single number, called its state.

State is the internal context of a computation, i.e., the subtask.

State and surroundings represent everything Picobot knows about the world

Picobot always starts in state 0.

I am in state 0. My surroundings

are xxWS.

0

self-containedbut not simplistic

Page 37: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Rules

Picobot acts through a set of rules:

state

I am in state 0. My surroundings

are xxWS.

surroundings

0 xxWS 0N

direction new state

Picobot checks its rules from the top each time.

When it finds a matching rule, that rule runs.Notes

Page 38: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Rules

Each rule expresses your intent for Picobot!

state

I am in state 0. My surroundings

are xxWS.

surroundings

0 xxWS 0N

direction new state

If I'm now in state 0 seeing xxWS,

Then I move North, and "change" to state 0.

Picobot acts through a set of rules

Let's try it!

(on

board)

Page 39: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

WildcardsAsterisks * are wild cards. They match walls or empty space:

0 x*** 0N

state surroundings direction new state

EWS may be wall or empty spaceN must be empty

I only care about NORTH being EMPTY

that's it!

Page 40: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

state surroundings direction new state

(A) A rule that sends Picobot to the North as far as it can go:

(B) What does this next rule do?

(C) What about this one?

(D) How could we stop at the bottom and return up through the same column?

0 x*** 0N->

0 N*** 1W->

1 ***x 1S->

Page 41: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

The Rule: One step per rule

How many times does rule (A) run? ___________________

How many times does rule (B) run? ___________________

How many times does rule (C) run? ___________________

Extra! What additional rules would be needed in order to ensure that Picobot fully explores the empty room (not this crazy room) from any starting spot?

(this is problem 3…)

How many times does rule (D) run? ___________________

One rule to rule them all?

Precious!

Try it!

Where does Picobot stop? Why?

Picobot's world

P

Page 42: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

problem 3

Picobot hw problems

problem 4 Extra! (#5)

Your rules must work regardless of Picobot's starting position… !

Page 43: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

problem 3

Picobot's revenge!

problem 4 Extra! (#5)

Your rules must work regardless of Picobot's starting position… !

Page 44: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Be Picobot!

"Run" this Picobot program:

state surr dir newstate

0 ***x S 0->0 *x*S E 0->

0 *E*S X 1->

(1) How many times does the 1st rule run? _________

(2) How many times does the 2nd rule run? _________

(3) How many times does the 3rd rule run? _________

1st rule

2nd rule

3rd rule

(6) Add 2-3 rules that will, in state 1, get Picobot to the top of the stalagmite, then stop.

(4) In English, what does state 0 do?

(Extra!) What approach could get Picobot to travel around the whole outer edge?

(5) How could this help clear the empty room? … just a thought experiment

P

top

of

sta

lag

mite

A more intricate picobot world

Page 45: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Maze strategies?

Page 46: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours
Page 47: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Maze strategies? Right Hand Rule

Keep your

"right hand"

on the wall,

Picobot!

Why might this be difficult for

Picobot?

Page 48: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Maze strategies? Right Hand Rule

We'll need to use state to represent

the direction Picobot is facing.

State 0State 1State 2State 3

facing

Keep your

"right hand"

on the wall,

Picobot!

Page 49: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Suppose Picobot wants to traverse a maze with its right hand always on the wall.

We use state 0 to represent that “Picobot is facing North”

(A) Here is a single rule that tells Picobot:

If you're facing N with a wall at right and space ahead then go forward”

0

(B) Let's write a single rule that tells Picobot:

“If you're facing North and lose the wall, then get over to the wall now!” 0

(C) (for HW) Write 1 or 2 rules to tell Picobot to do the right thing if it hits a dead end.

0

(A)

(B)

(C) Repeat this IDEA for all four states, representing all four facing directions.

0 xE** 0N->

0 ->

Page 50: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Problem 6 this week… Typically an article on CS or an application...

Submit a one-paragraph responseA few sentences that raise or address questions, using the article as a guide.

Small part (5 pts)5 – insightful, careful4 – thoughtful3 – complete, on topic0-2 – less than complete

This week's article might not seem like CS at first…

Page 51: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Seventy years ago, in 1940, a popular science magazine published a short article that set in motion one of the trendiest intellectual fads of the 20th century. At first glance, there seemed little about the article to augur its subsequent celebrity. Neither the title, “Science and Linguistics,” nor the magazine, M.I.T.’s Technology Review, was most people’s idea of glamour. And the author, a chemical engineer who worked for an insurance company and moonlighted as an anthropology lecturer at Yale University, was an unlikely candidate for international superstardom. And yet Benjamin Lee Whorf let loose an alluring idea about language’s power over the mind, and his stirring prose seduced a whole generation into believing that our mother tongue restricts what we are able to think.

and I thought my language was alien!

Page 52: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Seventy years ago, in 1940, a popular science magazine published a short article that set in motion one of the trendiest intellectual fads of the 20th century. At first glance, there seemed little about the article to augur its subsequent celebrity. Neither the title, “Science and Linguistics,” nor the magazine, M.I.T.’s Technology Review, was most people’s idea of glamour. And the author, a chemical engineer who worked for an insurance company and moonlighted as an anthropology lecturer at Yale University, was an unlikely candidate for international superstardom. And yet Benjamin Lee Whorf let loose an alluring idea about language’s power over the mind, and his stirring prose seduced a whole generation into believing that our mother tongue restricts what we are able to think.

and I thought my language was alien!

Page 53: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

problem 3

CS ~ complexity science

problem 4 Extra! (5)

Shortest Picobot program:

6 rules

Shortest Picobot program:

8 rules

Shortest Picobot program:

? rules

Can it simply

be done!?complexity is deeper than simply the # of rules…

Page 54: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Happy Picobotting!

You are not alone!

Tutoring hours all weekend in the LAC lab -also, weekday evenings @ LAC lab, too

I can attest to that!

Lead on! I will follow.

As you head northwards…

Page 55: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Each week's lab…

1) … to work on the problems

2) Also, you can use the CS5 lab and tutoring times, linked from the site

0) Feel free to stay for the final hour…

Encouraged: bring your laptop

Page 56: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Seek help!

see page

Tutoring schedule…

this link:

every day there are tutoring hours in the LAC computer lab Linde Activities Center

Page 57: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

HMC office + tutoring locations

Beckman B163 ~ office location

Enter through Olin building

Tutoring hours are in the Linde Activities Center

computer lab (LAC lab)

west-side entrance

Page 58: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Each week's lab…

1) … to work on the problems

2) Also, you can use the CS5 lab and tutoring times, linked from the site

0) Feel free to stay for the final hour…

Encouraged: bring your laptop

Thanks,

everyone!

Page 59: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours
Page 60: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours
Page 61: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Programming as learning a foreign language

1) Expect it to be different!

2) You don't need to know all the details

3) Immersion ~ Experimentation

4) Key benefit == new mindsetgo/went

No one does!

The shell ~ yet another language…

Page 62: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Say hello.

It's all language …but it's not all languages

MoO moO MoO mOo MOO OOM MMM moO moO MMM mOo mOo moO MMM mOo MMM moO moO MOO MOo mOo MoO moO moo mOo mOo moo

(=<`$9]7<5YXz7wT.3,+O/o'K%$H"'~D|#z@b=`{^Lx8%$Xmrkpohm_Ni;gsedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543s+O<oLm

0 lI'moH A cher1 lI'moH B cher A cha' B cha'18 { A B boq latlh cha' B "A" cher "B" cher} vangqa'

Hello worldMalbolge

FibonacciVar'aq

FibonacciCow

FibonacciPiet

Hello worldWhitespace

Fortunately, CS 5 does NOT goto the fringe of the programming-language universe !

Who are you calling fringe?

Page 63: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

The foreign language of python…

syntax semantics intentHow it looks What it does What it should do

name = raw_input('Hi... what is your name? ') print # prints a blank line

if name == 'Eliot' or name == 'Ran': print 'I\'m "offline." Try later.'

elif name == 'Zach': # is it Zach? print 'Zach Quinto...?', 'No?', 'Oh.' else: # in all other cases... print 'Welcome', name, '!' my_choice = random.choice( [ 'R','P','S' ] ) print 'My favorite object is', my_choice, "!"

This program should greet

its user appropriately.

Page 64: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

The foreign language of python…

syntax semantics intentHow it looks What it does What it should do

name = raw_input('Hi... what is your name? ') print # prints a blank line

if name == 'Eliot' or name == 'Ran': print 'I\'m "offline." Try later.'

elif name == 'Zach': # is it Zach? print 'Zach Quinto...?', 'No?', 'Oh.' else: # in all other cases... print 'Welcome', name, '!' my_choice = random.choice( [ 'R','P','S' ] ) print 'My favorite object is', my_choice, "!"

This program should greet

its user appropriately.human-desired output

Page 65: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

name = raw_input('Hi... what is your name? ') print # prints a blank line

if name == 'Eliot' or name == 'Ran': print 'I\'m "offline." Try later.'

elif name == 'Zach': # is it Zach? print 'Zach Quinto...?', 'No?', 'Oh.' else: # in all other cases... print 'Welcome', name, '!' my_choice = random.choice( [ 'R','P','S' ] ) print 'My favorite object is', my_choice, "!"

The foreign language of python…

syntax semantics intentHow it looks What it does What it should do

Page 66: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

name = raw_input('Hi... what is your name? ') print # prints a blank line

if name == 'Eliot' or name == 'Ran': print 'I\'m "offline." Try later.'

elif name == 'Zach': # is it Zach? print 'Zach Quinto...?', 'No?', 'Oh.' else: # in all other cases... print 'Welcome', name, '!' my_choice = random.choice( [ 'R','P','S' ] ) print 'My favorite object is', my_choice, "!"

The foreign language of python…

syntax semantics intentHow it looks What it does What it should do

machine-produced

output

Page 67: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

What about me?

'Zach'

'Chris'

Zach

Chris

Eliot or Ran

Zach

‘Eliot’ or ‘Ran’

a graphical view of a program's semantics

machine-produced

output

Page 68: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

www.theonion.com

• how punctuation is used• the language keywords used• use of whitespace

How Python looks!

The foreign language of python…

syntax semantics intentHow it looks What it does What it should do

• peculiarities of formatting

• how behavior is affected …

Page 69: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

www.theonion.com

• how punctuation is used• the language keywords used• use of whitespace

How Python looks!

The foreign language of python…

syntax semantics intentHow it looks What it does What it should do

• peculiarities of formatting

• how behavior is affected …

human-

typed

input

Page 70: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

www.theonion.com

The challenge of programming…

syntax semantics intentHow it looks What it does What it should do

human-typed input

machine-produced

output

human-desired output

?

Page 71: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

user = raw_input( "Choose your weapon! " )

comp = random.choice( ['rock','paper','scissors") ]

print 'user (you) chose:', 'user'

print 'comp (me!) chose:' comp

if user == rock and comp = 'paper'

print 'The result is, YOU LOSE!'

print 'unless you're a CS 5 grader, then YOU WIN!'

(1) Find and correct as many errors as you can here…

import random(2) This line is doing three things… what are they?

(3) What are the 6-7 punctuation marks used in more than one way here?

Syntax challenge!

Page 72: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

user = raw_input( "Choose your weapon! " )

comp = random.choice( ['rock','paper','scissors'] )

print 'user (you) chose:', user

print 'comp (me!) chose:', comp

if user == rock and comp == 'paper':

print 'The result is, YOU LOSE.'

print 'unless you\'re a CS 5 grader, then YOU WIN!'

import random

(3) Punctuation characters used in more than one way: ().'=,:

(1) prints the "weapon" prompt (2) gets user's input from the kbd

(3) assigns that input to the variable user

ever

y bl

ock

of c

ode

mus

t lin

e up

!ev

ery

bloc

k of

co

de m

ust

line

up!

a backslash handles special charactersflattering - or flouting - graders is encouraged!

test-equals uses TWO equals signs

a colon starts a new block

The comma prints a space and does NOT go to the next line.

set-equals always uses ONE equals sign

match brackets and quotes !

(1) Find and correct as many errors as you can here…

(2) This line is doing three things… what are they?

Syntax challenge!

Page 73: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Tear off that pagePass those to the aisles + Southward…

only 1 "quiz" is needed per pair

… then turn back into the packet

Page 74: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

The Rule: One step per rule

How many times does rule (A) run? ___________________

How many times does rule (B) run? ___________________

How many times does rule (C) run? ___________________

In a phrase, what do state 0 and state 1 do?

Extra! What additional rules would be needed in order to ensure that Picobot fully explores the empty room (not this crazy room) from any starting spot? (this is problem 3…)

How many times does rule (D) run? ___________________

One rule to rule them all?

This is precious!

Quiz! Solve this on the back page first…

Where does Picobot stop? Why?

Picobot's world

Using the ruleset above…

P

Page 75: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Pico-reminders…

Picobot follows a set of rules:

state surroundings direction new state

0 x*** 0N->

Picobot takes ONE STEP each time a rule runs.The programmer uses states to create behaviors!

0 N*** 0W->

Picobot!

Page 76: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Each week's lab…

1) Get Python running…

2) Run and submit a file…

0) Find the lab! Sign in…

Encouraged: bring your laptop

demo

download things now, perhaps…

Page 77: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Edwards Macalister Pryne

coffee

cool machines - drills, lathes, etc.

other keyboard-free machines

Physicists, chemists & other parenthesis-needing individuals,

CS Hallway and Labs

B102

B105

to Olin (Bio + CS)

Your account for CS submissions: B100

Map to CS Lab

Biologists, bees, spiders and other

arachnophiles

Big Beckman

(B126)

Koi

Galileo

Beckman

Shanahan

passwd:

or Olin

Evening lab? You can pickup a keycard from

HMC's F&M dep't.

Laptop? Bring it!

in Platt

Page 78: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

perc = 0.91

if perc > 0.95: print 'A'elif perc > 0.90: print 'A-'elif perc > 0.70: print 'Pass'else: print 'Aargh!'

Suppose we set the value of perc to 0.91...

Choices, choices!

What will this program print, if perc is 0.91?

# of BLOCKS here:# of TESTS here:

Page 79: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

comp = 'rock'user = 'paper'

if comp == 'paper' and user == 'paper': print 'We tie. Try again?'

elif comp == 'rock':

if user == 'scissors': print 'I win! *_*' else: print 'You win. Aargh!'

in a fiercely contested game of RPS...Does this program print the correct RPS result this time?

Does it always?

# of BLOCKS here:# of TESTS here:

Page 80: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

perc = 0.91

if perc > 0.95: print 'A'elif perc > 0.90: print 'A-'elif perc > 0.70: print 'Pass'else: print 'Aargh!'

Suppose that the value of perc is 0.91...

Choices, choices!

What will this program print, if perc is 0.91?

# of BLOCKS here:# of TESTS here:

Page 81: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Choices, choices!

perc = 0.80

if perc > 0.95: print 'A'elif perc > 0.90: print 'A-'elif perc > 0.70: print 'Pass'else: print 'Aargh!'

How can you get a better grade on the right than the left?

perc = 0.80

if perc > 0.00: print 'Aargh!'elif perc > 0.70: print 'Pass'elif perc > 0.90: print 'A-'else: print 'A'

What does each of these programs print out, if perc is 0.8?

What value of perc gives an 'A-' on the right?

Page 82: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

What's the difference?

if perc > .95: print 'A'

elif perc > .90: print 'A-'

elif perc > .70: print 'Pass'

if perc > .95: print 'A'

if perc > .90: print 'A-'

if perc > .70: print 'Pass'

mutually exclusive blocks nonexclusive blocks

How many separate control structures does each side have?

What if perc == .99 ?

Page 83: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

comp = 'rock'user = 'paper'

if comp == 'paper' and user == 'paper': print 'We tie. Try again?'

elif comp == 'rock':

if user == 'scissors': print 'I win! *_*' else: print 'You win. Aargh!'

in a fiercely contested game of RPS...Does this program print the correct RPS result this time?

Does it always?

# of BLOCKS here:# of TESTS here:

Page 84: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

"Quiz" Name ______________________

Your favorite __________ is ____________.

Your least favorite ____________ is ____________.

Name ______________________

Your favorite __________ is ____________.

Your least favorite ____________ is ____________.

Pair up with someone nearby – and answer these questions together…

What is something non-Claremont-collegey you have in common?

comp = 'rock'user = 'rock'

if comp == 'rock': if user == 'paper': print 'I win *_*!' elif user == 'scissors': print 'You win.'else: print 'Tie.'

(1) What output does this code print? (3) Change these inputs to produce a completely correct RPS output here.

comp = 'rock'user = 'rock'

if comp == 'rock': print 'I win *_*!'if user == 'paper': print 'You win.'else: print 'Tie.'

(2) As written, what output does this print?

(5) What is the smallest number of tests and blocks of code you'll need to correctly handle a full game of RPS?

(0) How many tests and blocks are here?

First: Pick up your CS lab login + password and look up your submission-site login

Then, try these Python q's:

(4) How many RPS cases are there? How many of them does this code handle correctly?

(Extra) What if it were RPS-5, with Lizard and Spock? RPS-101?

Page 85: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

comp = 'rock'user = 'rock'

if comp == 'rock':

if user == 'paper': print 'I win *_*!' elif user == 'scissors': print 'You win.’

else: print 'Tie.' print 'Ties go to the runner!' print ' - and I'm running.'

# of BLOCKS # of TESTS

Counting...

... what if the else were indented?

Page 86: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

How many possible “inputs” are there?

comp = 'rock'user = 'rock'

if comp == 'rock': print 'I win *_*!‘

if user == 'paper': print 'You win.‘

else: print 'An awful tie'

For how many is this program correct?What does this print?

… how efficiently can RPS be represented?• Fewest number of blocks?• Fewest number of tests?

Page 87: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Can you solve the problem?

Can you create a process to solve such problems?

What is the Longest Common Subsequence between 2 strings?

'HUMAN'

'CHIMPANZEE'

How can it be done?

How well can it be done?

Can it be done at all?

What is CS?

'CGCTGAGCTAGGCA...'

'ATCCTAGGTAACTG...'

Eye oneder if this haz othur aplications?

biology's string-matching problem, "LCS"

+109more

Page 88: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Feels like home!

How much work is needed to simulate N stars?

physics's "N-body" problemIs your solution the "best" possible?

How quickly can you find a solution?

How can it be done?

How well can it be done?

Can it be done at all?

What is CS?

Page 89: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Why here?

Placement based on experience, not ability:• Gold is for students mostly new to CS,

• Black for students with a good amount of previous CS

• Tradeoff: more careful coverage – a few more applications

• Green is for those who'd like biology-flavored CS!

• All of Gold Black and Green will prepare you well for• CS 60• Future computational work• A happy and fulfilling life :-)

official alien of CS 5 Gold official mascot of CS 5 Black

official turtle of CS 5 Green

switching?

Page 90: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

… and who is this Mudder, 35 years later?

Jon “Dean” Jacobsen, 1979

Page 91: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours
Page 92: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

What is programming ?

Programming as "recipe-writing"

vs.

Programming as learning a foreign language

Page 93: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

1) Expect it to be different!

2) Don’t feel you need to memorize it

3) Immersion == Experimentation go/went

What is programming ?

Programming as "recipe-writing"

vs.

Programming as learning a foreign language

Baggage

!

Page 94: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Why CS 5 ?Broad, constructive tour in CS

1

2

34

5

recursionsimulation

design

semester abroad

Page 95: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

in pictures?

Python Programming?

Page 96: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

One possibility...

Python Programming?

Page 97: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

One possibility...

Happy co-existence! It can even be comfy!

Python Programming?

Page 98: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Python Programming?

Python (language) and IDLE (editor)

open-source, free, powerful, and common

We will be using Python 2.7.3

~ the “Enthought” distribution

Plain old Python 2.7.x is certainly OK, too.Don't get 3.1 or 3.x!

Page 99: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

"Editor" and "Shell"

Editor (IDLE): typing 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 100: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

The foreign language of python…

Lab 0 – Tues. / Wed. is to run and submit “this” program

name = raw_input('Hi... what is your name? ') print # prints a blank line

if name == 'Eliot' or name == 'Ran': print 'I\'m "offline." Try later.'

elif name == 'Zach': # is it Zach? print 'Zach Quinto...?', 'No?', 'Oh.' else: # in all other cases... print 'Welcome', name, '!' my_choice = random.choice( [ 'R','P','S' ] ) print 'My favorite object is', my_choice, "!"

Page 101: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

The foreign language of python…

syntax semantics intentHow it looks What it does What it should do

name = raw_input('Hi... what is your name? ') print # prints a blank line

if name == 'Eliot' or name == 'Ran': print 'I\'m "offline." Try later.'

elif name == 'Zach': # is it Zach? print 'Zach Quinto...?', 'No?', 'Oh.' else: # in all other cases... print 'Welcome', name, '!' my_choice = random.choice( [ 'R','P','S' ] ) print 'My favorite object is', my_choice, "!"

Page 102: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

What about me?

'Zach'

'Chris'

Zach

Chris

Eliot or Ran

Zach

‘Eliot’ or ‘Ran’

Page 103: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

The foreign language of python…

Syntax

www.theonion.com

• how punctuation is used• the language keywords that are used• use of whitespace• peculiarities of formatting• how behavior is affected …

How Python looks!

syntax semantics intentHow it looks What it does What it should do

Page 104: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Language is language...?

int main(){ printf("%s\n", "Hello, world!");}

PLEASE DO ,1 <- #13DO ,1 SUB #1 <- #238DO ,1 SUB #2 <- #112DO ,1 SUB #3 <- #112DO ,1 SUB #4 <- #0DO ,1 SUB #5 <- #64DO ,1 SUB #6 <- #238DO ,1 SUB #7 <- #26DO ,1 SUB #8 <- #248DO ,1 SUB #9 <- #168DO ,1 SUB #10 <- #24DO ,1 SUB #11 <- #16DO ,1 SUB #12 <- #158DO ,1 SUB #13 <- #52PLEASE READ OUT ,1PLEASE GIVE UP

v>v"Hello world!"0<,:^_25*,@

(DEFUN HELLO-WORLD () (PRINT (LIST 'HELLO 'WORLD)))

CC++

LISPScheme

Befunge

Intercal

Pythonprint 'Hello, World!'

HAI CAN HAS STDIO?VISIBLE "HAI WORLD!" KTHXBYE

LOLCODE

Page 105: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Language is language...?

int main(){ printf("%s\n", "Hello, world!");}

PLEASE DO ,1 <- #13DO ,1 SUB #1 <- #238DO ,1 SUB #2 <- #112DO ,1 SUB #3 <- #112DO ,1 SUB #4 <- #0DO ,1 SUB #5 <- #64DO ,1 SUB #6 <- #238DO ,1 SUB #7 <- #26DO ,1 SUB #8 <- #248DO ,1 SUB #9 <- #168DO ,1 SUB #10 <- #24DO ,1 SUB #11 <- #16DO ,1 SUB #12 <- #158DO ,1 SUB #13 <- #52PLEASE READ OUT ,1PLEASE GIVE UP

v>v"Hello world!"0<,:^_25*,@

(DEFUN HELLO-WORLD () (PRINT (LIST 'HELLO 'WORLD)))

CC++

LISPScheme

Befunge

Intercal

Pythonprint 'Hello, World!'

HAI CAN HAS STDIO?VISIBLE "HAI WORLD!" KTHXBYE

LOLCODE

Page 106: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

name = raw_input('Hi... what is your name? ') print # prints a blank line

if name == 'Eliot' or name == 'Ran': print 'I\'m "offline." Try later.'

elif name == 'Zach': # is it Zach? print 'Zach Quinto...?', 'No?', 'Oh.' else: # in all other cases... print 'Welcome', name, '!' my_choice = random.choice( [ 'R','P','S' ] ) print 'My favorite object is', my_choice, "!"

Punctuation? Spacing? Color information? Strings? Variables?

Second looks?

Page 107: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

CS’s motto ?

print 'hv',print 'dcle\naemdoe'print 'ryu',print 'lg!'

print 'whteo'print 'aerub\nv',print 'aeo\nyraoo'print 'egdne'

details are temporary… …but CS thinking isn’t !

Page 108: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

CS’s motto ?

print 'hv',print 'dcle\naemdoe'print 'ryu',print 'lg!'

print 'whteo'print 'aerub\nv',print 'aeo\nyraoo'print 'egdne'

details are temporary… …but CS thinking isn’t !

hv dcleaemdoeryu lg!

whteoaerubv aeoyraooegdne

Page 109: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Whatever you are, be a good

one.- Abraham Lincoln

... more and more, CS can

help!

We agree...

Page 110: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Lab 0!(1) Pick up this page

(2) Login to your own laptop OR a CS machine (with your CS account)

and open a browser, e.g., Safari

Questions? Ask us!

(3) Go to Lab 0 and work through it...Google for "HMC CS" – click "Schedule" – then CS5 . Or, type www.cs.hmc.edu/twiki/bin/view/CS5/

(a) (or later) Change your CS password(b) Try Python & its "shell"

(c) Submit hw0pr1 of the assignment(d) Complete the CS policy forms(e) Finish hw0pr2 (if you'd like...)

(4) Either before or after changing your CS password, feel free to use your own laptop instead...

(0) Be sure to sign in!

anything but IE

Page 111: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

comp = 'rock'user = 'rock'

if comp == 'rock': if user == 'paper': print 'I win *_*!' elif user == 'scissors': print 'You win.'else: print 'Tie.' print 'Ties go to the runner!' print 'I'm running - are you?'

What does this print?

Page 112: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

How many RPS-legal inputs are there?

comp = ???user = ???

if comp == 'rock': print 'I win *_*!'if user == 'paper': print 'You win.'else: print 'Tie.' print '-- a horrible tie!'

For how many is this program correct?

What does this print?

Page 113: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Why CS ?

Information is life’s fundamental building block.

CS is a set of fundamental techniques for understanding and leveraging this information…

Genetic Code: DNA Our senses and experiences

GTAGCACAITTAGC… More coffee required…

us

“constructing with”

Page 114: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

How I spent my summer vacation...

visiting Google Irvine serving as a historical consultant!

... and programming flying robots, too...

Page 115: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

CS is deceptively easy.

No worries...

Page 116: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

What is CS?

creativity / design

commodity skills

It's a big span

Page 117: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

What is CS?

creativity / design

commodity skills

It's a big span

Page 118: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

The Atari 2600 game, Adventure!

Page 119: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Why Python ?

Python is a general-purpose computer language

Physics: LabView

Biology: Lasergene, DNA*

Engineering: Matlab

Mathematics: Maple, Mathematica

skills apply to all special-purpose languages

ALL of these seem alien at first!

You’re telling me!

Page 120: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Language is language ?

Perls of wisdom ?

eval evalq.q>trd!Uj:%L<061:%C<csnvo:%f<fsddo0:%c<cmtd:%x<xdmmnv:%I<011:%u<251:%bs<bsd`udSdbu`ofmd:%w<lnwd:%U<2:%t<L`hoVhoenv,?odv),idhfiu<?314-,vheui<?254(:%b<%t,?B`ow`r:%b,?bnoghftsd),vheui<?%u-,idhfiu<?311(:%b,?q`bj)(:s)3-3-%u-001-%c(:s)3-081-%u-311-%f(:s)3-001-%u-031-%f(:s)3-1-%u-34-%f(:gns)%{<1:%{=%u:%{*<71(zs)%{-01-%{*51-54-%f-%f(:|s)3-1-%u-04-cm`bj(:%b,?%bs)3-1-%u-311(:%G<,041:v)1-%L-31-C-%x(:v)%G-%L-,021-C-%x(:%B<,91:v),31-041-,4-B-%c(:v),91-041-,74-B-%c(:%E<,%I:v)1-021-31-E-%x(:v),%I-021-, 91-E-%x(:%K<,231:v),71-81-,31-@-%C(:v),301-81-,%L-@-%C(:v),%u-81-,211-@-%C(:%M<,%u:v),51-61-1-F-%C(:v),%L-61-,021-F-%C(:v),%u-61-,211-F-%C(:%J<%u:v)751-41-791-[-%C(:v)401-41-441-[-%C(:v)%u-41-291-[-%C(:%b,?bsd`udNw`m)063-080-091-088-,u`fr<?G-,ghmm<?fsddo5(:S)1(:%b,?sdqd`u)%I-]'t(:%t,?choe)&=Envo?&<?rtczS),0(:'V:%b,?%w)G-1-31(hg)%x=081(:|(:%t,?choe)&=Tq?&<?rtczS)0(:%b,?%w)G-1-,31(:|(:%t,?choe)&=Mdgu?&<?rtcz'V:%b,?%w)G-,31-1(hg)%y?31(:|(:%t,?choe)&=Shfiu?&<?rtcz'V:%b,?%w)G-31-1(hg)%Y=%u,31(:|(:L`hoMnnq)(:dyhu:rtc!vz%b,?%bs)%^Z1\-%^Z0\-%^Z3\-%^Z0\*8-,u`fr<?%^Z2\-,ghmm<?%^Z5\(:|rtc!tzhg)%G?%u(z%G*<%L:%d<,%G:%G<,%L:|dmrdz%G*<01:%d<01:|%b,?%w)C-%d-1(:hg)%B?%u(z%B*<%I:%d<,%B:%B<,%I:|dmrdz%B*<01:%d<01:|%b,?%w)B-%d-1(:hg)%E?%u(z%E*<031:%d<,%E:%E<,031:|dmrdz%E*<01:%d<01:|%b,?%w)E-%d-1(:hg)%K?%u(z%K*<229:%d<,%K:%K<,251:|dmrdz%K*<7:%d<7:|%b,?%w)@-%d-1(:hg)%M?%u(z%M*<271:%d<,%M:%M<,271:|dmrdz%M*<9:%d<9:|%b,?%w)F-%d-1(:hg)%J=,%u(z%J,<%u:%d<,%J:%J<%u:|dmrdz%J,<7:%d<,7:|%b,?%w)[-%d-1(:'V:hg)%x=081(zhg))%x?031(}})%x=001((zAn<%b,?ghoe)nwdsm`qqhof-%y-%x-%Y-%X(:hg)%x?031(zhg)%"n(z'R:||dmrdzhg)%x?58(zhg)%"n?0(z%n<7:%n*<3hg)%x=81(:%n<,7hg)%x=61(:%b,?%w)G-%n-1(:|dmrdz'R:||dmrdzhg)%"n?0(z'R:|dmrdzS)00(:%U**:%O**:'R:v)%y-%x-%Y-Q-%f(:%b,?edmdud)&Q&(hg))%O$4((:||||rmddq)4(''Uj;;dyhu)1(hg)%U=0(:||rtc!Rz%U,,:qshou#]`#:%b,?%w)G-063,%y-081,%x(:|rtc!SzP)cm`bj(:%R*<%^Z1\:P)sde(: |rtc!Pz%b,?bsd`udUdyu)%L-9,udyu<?%R/1-,ghmm<?%^Z1\(:|rtc!sz%b,?%bs)%^Z1\-%^Z0\-%^Z3\-%^Z2\-,ghmm<?%^Z5\-,ntumhod<?%^Z4\(:|rtc!Vz)%y-%x-%Y-%X(<%b,?bnnser)G(:|>^chr($$/$$)x2016.

Perl might be a little bit TOO flexible a language!

Goal: expression, not language details.

Page 121: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

The results

back to Python

Page 122: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

What Google thinks I look like

First 4 Google Image hits (8/29/10) for a search of

"Zach Dodds HMC"

Page 123: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

What Google thinks I look like

First 4 Google Image hits (8/29/10) for a search of

"Zach Dodds HMC"

Page 124: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

What Google thought I looked like…

"Zach Dodds"

Images are difficult!

First Google Image hit (8/30/09) for a search of

Page 125: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Map to CS Labs

CIS + Labs

Edwards Macalister

Pryne

coffee

cool machines - drills, lathes, etc.

more cool, keyboardless machines

Parsons

CS Hallway

Physicists and other parenthesis-

needing individuals, e.g.

chemists

CS Hallway

Big Beckman (B126)

B102

B105

Beckman B102, B105

Olin (math, bio, CS)

Get your CS account. Laptop is OK, with wireless.

B100

See you in Lab!

Page 126: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

CS? Not why...

Programming will solve problems for you

Python is the ultimate programming language

Programming will save time and effort

Page 127: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours
Page 128: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours
Page 129: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Abstraction

Artists are mystics rather than rationalists. They leap to conclusions

that logic cannot reach.

-- Sol LeWitt,conceptual artist

Simplicity does not precede complexity, but follows it.

-- Alan Perlis, early CS-ist.

Page 130: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours
Page 131: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Picobot

area already covered

area not covered

(yet!)

inspiration?

walls

Goal: whole-environment coverage with only local sensing…

Picobot

Picobot

as envisioned by an HMC clinic

HW problems 3 and 4

Page 132: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

inspiration!

PicobotPicobot

area already covered

area not covered

(yet!)

walls

Goal: whole-environment coverage with only local sensing…iRobot's Roomba vacuum

Page 133: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Surroundings

Picobot can only sense things directly to the N, E, W, and S

For example, here its surroundings are

NxWx

N

EW

S

N E W SSurroundings are

always in NEWS order.

Page 134: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

How many distinct surroundings are there?

N

EW

S

Surroundings

Page 135: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

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 136: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

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 137: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

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 138: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Wildcards

Asterisks * are wild cards. They match walls or empty space:

0 x*** 0N

state surroundings direction new state

and EWS may be wall or empty space

I am in state 0. My surroundings

are xxWS.Aha! This matches x***

N must be empty

Page 139: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

What will this set of rules do to Picobot?

0 x*** 0N

0 N*** 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.

->

->

how can we get back down the screen?

Page 140: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

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 141: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

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

Page 142: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Alter these "up & down" rules so that Picobot will traverse the empty room… "Quiz" #2

the empty room

Page 143: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Ideas for the maze?

the maze

Page 144: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Computer Science

Information is intrinsic to every system…How can we benefit from this information?

Efficiently? Effectively? Possibly?

Representing it … Applying it … Measuring it

“create with”

Page 145: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Computer Science

Information is intrinsic to every system…How can we benefit from this information?

Efficiently? Effectively? Possibly?

Representing it … Applying it … Measuring it

How to measure these rooms' complexity?

“create with”

Page 146: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Computer Science

our best: 4 states, 8 rulesour best: 3 states, 7 rules

How many states and rules are

really necessary ?

How much information does

each system contain ?

Information is intrinsic to every system…How can we benefit from this information?

Efficiently? Effectively? Possibly?

Representing it … Applying it … Measuring it

“create with”

How to measure these rooms' complexity?

Page 147: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Computer Science

This image: 20 kilobytes!This image: 5 kilobytes

How many states and rules are

really necessary ?

How much information does

each system contain ?

Information is intrinsic to every system…How can we benefit from this information?

Efficiently? Effectively? Possibly?

Representing it … Applying it … Measuring it

“create with”

How to measure these rooms' complexity?

Page 148: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Happy Picobotting!

Remember

Office hours at the CS labs: Friday 2:00-4:00

Tutoring hours all weekend in LAC lab & CS labs…

Email me with any account/web/other [email protected]

Page 149: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours
Page 150: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

Abstraction

Artists are mystics rather than rationalists. They

leap to conclusions that logic cannot reach.

-- Sol LeWitt,conceptual artist

Simplicity does not precede complexity, but follows it.

-- Alan Perlis, creator of the first compiler

Page 151: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

What is programming ?

Programming as "recipe-writing"

vs.

Programming as learning a foreign language

What is CS?

but ... let's start with the foundation!

Page 152: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

"Quiz" Name ______________________

Birthday ____________

A place you considered home __________

Your favorite __________ is ____________.

Your least favorite ____________ is ____________.

Name ______________________

Birthday ____________

A place you considered home __________

Your favorite __________ is ____________.

Your least favorite ____________ is ____________.

Pair up with someone nearby – and answer these questions together…

What is something non-Claremont-collegey you have in common?

comp = 'rock'user = 'rock'

if comp == 'rock': if user == 'paper': print 'I win *_*!' elif user == 'scissors': print 'You win.'else: print 'Tie.'

(1) What output does this print?

(3) Change these inputs to produce a completely correct RPS output here.

comp = 'rock'user = 'rock'

if comp == 'rock': print 'I win *_*!'if user == 'paper': print 'You win.'else: print 'Tie.'

(2) As written, what output does this print?

(4) What is the smallest number of tests and

blocks of code that are needed to play RPS?

Get your CS lab

accounts, too!(0) How many tests and blocks are here?

Page 153: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

the study of complexity

How can it be done?

How well can it be done?

Can it be done at all?

What is CS?

Can you solve this problem?

Can you create a process to solve such problems?

The "LCS" problem

What is the longest common subsequence between 2 'strings'

'HUMAN'

'CHIMPANZEE'

'CGCTGAGCTAGGCA...'

'ATCCTAGGTAACTG...'

Eye oneder if LCS haz othur aplications?

Page 154: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

"Quiz" Name ______________________

Your favorite __________ is ____________.

Your least favorite ____________ is ____________.

Name ______________________

Your favorite __________ is ____________.

Your least favorite ____________ is ____________.

Pair up with someone nearby – and answer these questions together…

What is something non-Claremont-collegey you have in common?

comp = 'rock'user = 'rock'

if comp == 'rock': if user == 'paper': print 'I win *_*!' elif user == 'scissors': print 'You win.'else: print 'Tie.'

(1) What output does this code print?(3) Change these inputs to produce a completely correct RPS output here.

comp = 'rock'user = 'rock'

if comp == 'rock': print 'I win *_*!'if user == 'paper': print 'You win.'else: print 'Tie.'

(2) As written, what output does this print?

(4) What is the smallest number of tests and blocks of code you'll need to play full RPS?

Get your CS lab

accounts, too!

(0) How many tests and blocks are here?

Page 155: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

"Quiz" Name ______________________

Your favorite __________ is ____________.

Your least favorite ____________ is ____________.

Name ______________________

Your favorite __________ is ____________.

Your least favorite ____________ is ____________.

Pair up with someone nearby – answer these questions together…

What is something non-Claremont-collegey you have in common?

comp = 'rock'user = 'rock'

if comp == 'rock': if user == 'paper': print 'I win *_*!' elif user == 'scissors': print 'You win.'else: print 'Tie.'

(1) What output does this code print?

(3) Change these inputs to produce a completely correct RPS output here.

comp = 'rock'user = 'rock'

if comp == 'rock': print 'I win *_*!'if user == 'paper': print 'You win.'else: print 'Tie.'

(2) As written, what output does this print?

(5) What is the smallest number of tests and blocks of code you'll need to correctly handle a full game of RPS?

(0) How many tests and blocks are here?

Then, try these Python q's:

(Extra) What if it were RPS-5, with Lizard and Spock? RPS-101?

People

Python

Paper

(4) How many RPS input cases are there? How many are correctly handled by this code?

Page 156: Welcome (back) to IST 338 ! Wally Homework 0 Alien due Sun. night (11:59pm) Wow – I see the resemblance Problem 0: Already complete! Problem 1: Four-fours

"Quiz" Name ______________________

Your favorite __________ is ____________.

Your least favorite ____________ is ____________.

Name ______________________

Your favorite __________ is ____________.

Your least favorite ____________ is ____________.

Pair up with someone nearby – introduce yourself…

What is something non-Claremont-collegey you have in common?

comp = 'rock'user = 'rock'

if comp == 'rock': if user == 'paper': print 'I win *_*!' elif user == 'scissors': print 'You win.'else: print 'Tie.'

(1) What output does this code print?

(3) Change these inputs to produce a completely correct RPS output here.

comp = 'rock'user = 'rock'

if comp == 'rock': print 'I win *_*!'if user == 'paper': print 'You win.'else: print 'Tie.'

(2) As written, what output does this print?

(5) What is the smallest number of tests and blocks of code you'll need to correctly handle a full game of RPS?

(0) How many tests and blocks are here?

Then, try these Python q's:

(4) How many RPS input cases are there? How many are correctly handled by this code?

(Extra) What if it were RPS-5, with Lizard and Spock? RPS-101?