Grab t h ese lecture notes… Welcome to IST338 ! CS for Insight Wally Wart, a protrusive advocate of concrete computing Everyone will get out of this course – a lot! We don't have words strong enough to describe this class. - NYTimes Review of Courses - US News and Course Report We give this course two thumbs… - Metametacritic 1 handout… slides & syllabus
161
Embed
Grab these lecture notes… Welcome to IST338 ! CS for Insight Wally Wart, a protrusive advocate of concrete computing Everyone will get out of this course.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Grab these lecture notes…
Welcome to IST338 !
CS for Insight
Wally Wart, a protrusive advocate of concrete
computing
Everyone will get out of this course – a lot!
We don't have words strong enough to describe this class.
Many companies want a larger diversity of skillsets, mindsets, and talents – but
all of them empowered by CS
CS? Leap before you look!Try it out!
hw0pr0: Run and submit this program… (due a week from Friday – easy!)
extra: Write a rock-paper-scissors program…
This week's hw… by next Fri. night:
Get to the CS5 website and hw0. Complete hw0pr0 - in brief,
1. Make sure you can log into the submission system
2. Change your password + upload an image3. Run and submit hw0pr0.py (provided!)
Extra: submit a rock-paper-scissors-playing program…
username = first initial + last name (most often)
password =troubles? email me!
Extra! Extra! ~ if you do the extra credit this week, your first problem for next week is already complete!
This week's hw… by next Fri. night:
Get to the CS5 website and hw0. Complete hw0pr0 - in brief,
1. Make sure you can log into the submission system
2. Change your password + upload an image3. Run and submit hw0pr0.py (provided!)
Extra: submit a rock-paper-scissors-playing program…
username = first initial + last name (most often)
password =troubles? email me!
Extra! Extra! ~ if you do the extra credit this week, your first problem for next week is already complete!
Demo!
the study of complexity:
How can it be done?
How well can it be done?
Can it be done at all?
it ~ informationor, more precisely, a process transforming
information from one form to another
But, what is CS a science of ?
the study of complexity:
How can it be done?
How well can it be done?
Can it be done at all?
What is CS a science of ?
it ~ information
3 examples? That's it for me!
We'll look at 3 examples – each of which you'll build in IST380e
…at least to some extent!
or, more precisely, a process transforminginformation from one form to another
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
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?
what if N is a billion-and-one…?
Can we build a 3d model from one 2d image?
Is your problem solvable?
How can you tell !?
How can it be done?
How well can it be done?
Can it be done at all?
What is CS?
Andrew Ng's "Make3d"
many problems are uncomputable… … and you'll prove this!
All three eyes tell me that Make3d has just failed ~ epically!
CS is the study of complexity
But only one is programming.
Do you see which?
Is every problem solvable?
Is there a way to tell?There isn’t always!
Can you solve this problem?
Can you create a process to solve such problems?
CS's 6 big questions are here.
Do you have the “best” solution?
How quickly can you find solutions?
What is CS?
How can it be done?
How well can it be done?
Can it be done at all?
Is every problem solvable?
Is there a way to tell?There isn’t always!
Can you solve this problem?
Can you create a process to solve such problems?
Do you have the “best” solution?
How quickly can you find solutions?
programming
CS
CS
CS
CS
CS
+ CS
CS is the study of complexity
But only one is programming.
Do you see which?
CS's 6 big questions are here.
What is CS?
How can it be done?
How well can it be done?
Can it be done at all?
More and more, CS can help!
Whatever you are, be a good one.
- Abraham Lincoln
CS’s philosophy:
in 1954, 1971, 1983, 1996, 2006, 2012, …
If Silicon Valley - or Silicon Beach – opened a fn. cookie…
these dots worry people!
HW
Lectures
Office hrs
W 7-9:50 (MW: 1:15 – 2:30 pm)
Friday nights: due by 11:59 pm - ish
Insight into the HW problems (what, why, how)
feel free to work on HW, to just stop by,
W: 3-5pm Olin B163
Key skills, topics, and their motivation
I'd like to see you! Let me know if you’ll be sick…
or, come to any of the many tutoring hrs!
LabGuided progress on the class's hw
W 9-9:50 (M or T: 2:45 - 4:45 pm or 8:00 - 10:00 pm)
Will SAVE you time and effort to get started!Not required, but encouraged
recommended by 4 out of 5 CS-for-Insight alums!
Soundbite SyllabusHMC
HMC
same for HMC
Hw is due on Sunday nights...
Come to Labs!
Come to Lectures!
Lots of help is available!
HW
Lectures
Office hrs
W 7-9:50 (MW: 1:15 – 2:30 pm)
Friday nights: due by 11:59 pm - ish
Insight into the HW problems (what, why, how)
feel free to work on HW, to just stop by,
W: 3-5pm Olin B163
Key skills, topics, and their motivation
I'd like to see you! Let me know if you’ll be sick…
or, come to any of the many tutoring hrs!
LabGuided progress on the class's hw
W 9-9:50 (M or T: 2:45 - 4:45 pm or 8:00 - 10:00 pm)
Will SAVE you time and effort to get started!Not required, but encouraged
recommended by 4 out of 5 CS-for-Insight alums!
Syllabus, brieflyHMC
HMC
same for HMC
Eur-ollowed to use one Euro for up to
three hwks.
No need to let us know, even.
HomeworkAssignments ~ 5 problems/week
Due Friday evenings by 11:59 pm.
Collaborate!
Some problems are specified “individual-only.”Others offer the option of working as pairs/partners:
• You don’t have to work in pairs/partners (that said, it's fun!)
• You must share the work equally - typing and coaching
• Be sure to indicate who your partner was at the submission site!
• Put your name(s) in the code, as well!
"Late Days"You have 3 CS 5 Euros to use…
Extra credit is usually available…
Pairs Partners
one computertradeoff typing/debugging ~
about every 20 minutes
two computersboth partners type/debug ~
provide help as needed
Standard is the same either way:
After finishing the hw, (a) each person has contributed equally and (b) both could complete the problems on their own
Please do use the internet for Python language references.
Pleas do use other's eyes for finding syntax erorrs.
Do not use the internet (or intranet) to (try to) find solutions…
If you work as a pair/partners, the rules apply for the group.
your work matters
• You're encouraged to discuss problems with other students – or tutors - or any instructors.
• You may not share written, electronic or verbal solutions with other students, present or past:
Even with three eyes, I
need to borrow others'
to find the syntax errors
here!
Claremont-wide code: Submit only your own work.
Grading
There are no exams in IST338…
if perc > .95: print 'A'elif perc > .90: print 'A-'elif perc > .70: print 'Pass'
~ 65% Assignments
~ 5% Participation/“quizzes”
~ 30% Final project
see online syllabus for the full grade list...
… there is a final project, however.
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:
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?
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
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 ?
Next time in IST338
1) What is CS?
2) Python!
Shouldn’t there be an
alien in this game?
I'm not so sure…
CS is just programming, right?
Whatever it is, it's definitely alien!
hw0pr0 – getting started ~
due a week from Fri, 1/30…
Thank you, everyone!!
How about a sneak peek at next week?
… you must mean sneak Pic !
Logically, I've got game!
rock – paper – scissors – lizard – Spock!
http://www.youtube.com/watch?v=fqlDc2VICZ0 start at about :28
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:
CS != programming
So, what is CS?
Punctuation matters! So what? is CS
"not equal to"
CS != programming
programming : CS ::
chemistry : biology
longboards : HMC maybe 5Cs?
equations : mathematics
language : ideas
programs are a vehicle, not the destination
Programming
CS
CS != programming
the study of complexity:
How can it be done?
How well can it be done?
Can it be done at all?
it ~ informationor, more precisely, a process transforming
information from one form to another
What is CS a science of ?
the study of complexity:
How can it be done?
How well can it be done?
Can it be done at all?
What is CS a science of ?
it ~ information
3 examples? That's it for me!
We'll look at 3 examples – each of which you'll construct in CS 5
…at least to some extent!
or, more precisely, a process transforminginformation from one form to another
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?
'CGCTGAGCTAGGCC...'
'ATCCTAGGTAACTG...'
Eye oneder if this haz othur aplications?
biology's string-matching problem, "LCS"
+109more
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?
what if N is a billion-and-one…?
Can we build a 3d model from one 2d image?
Is your problem solvable?
How can you tell !?
How can it be done?
How well can it be done?
Can it be done at all?
What is CS?
Andrew Ng's "Make3d"
many problems are uncomputable… … and you'll prove this!
All three eyes tell me that Make3d has just failed ~ epically!
CS is the study of complexity
But only one is programming.
Do you see which?
Is every problem solvable?
Is there a way to tell?There isn’t always!
Can you solve this problem?
Can you create a process to solve such problems?
CS's 6 big questions are here.
Do you have the “best” solution?
How quickly can you find solutions?
What is CS?
How can it be done?
How well can it be done?
Can it be done at all?
Is every problem solvable?
Is there a way to tell?There isn’t always!
Can you solve this problem?
Can you create a process to solve such problems?
Do you have the “best” solution?
How quickly can you find solutions?
programming
CS
CS
CS
CS
CS
+ CS
CS is the study of complexity
But only one is programming.
Do you see which?
CS's 6 big questions are here.
What is CS?
How can it be done?
How well can it be done?
Can it be done at all?
More and more, CS can help!
Whatever you are, be a good one.
- Abraham Lincoln
IST 338's philosophy:
Take-home message…
www.cs.hmc.edu/~dodds/IST338/
depending on where "home" is, perhaps…
But one homepage
is not enough…
Take-home message…
www.cs.hmc.edu/cs5
Two homes? This is two good!
Now in 2015!
Just Google for
hmc cs5
will be linked
You're here ~ what's next?
1) What is CS?
2) How IST 338 runs…
3) Python?!
the first Python HW is choice!
Shouldn’t there be an
alien in this game?
I'm not so sure…
CS is just programming, right?
Whatever it is, it's definitely alien!
Logically, I've got game!
rock – paper – scissors – lizard – Spock!
http://www.youtube.com/watch?v=fqlDc2VICZ0 start at about :28
HW
Lectures
Office hrs
W 7-9:50 (MW: 1:15 – 2:30 pm)
Friday nights: due by 11:59 pm - ish
Insight into the HW problems (what, why, how)
feel free to work on HW, to just stop by,
W: 3-5pm Olin B163
Key skills, topics, and their motivation
I'd like to see you! Let me know if you’ll be sick…
or, come to any of the many tutoring hrs!
LabGuided progress on the class's hw
W 9-9:50 (M or T: 2:45 - 4:45 pm or 8:00 - 10:00 pm)
Will SAVE you time and effort to get started!Not required, but encouraged
recommended by 4 out of 5 CS-for-Insight alums!
Soundbite SyllabusHMC
HMC
same for HMC
Hw is due on Sunday nights...
Come to Labs!
Come to Lectures!
Lots of help is available!
HW
Lectures
Office hrs
W 7-9:50 (MW: 1:15 – 2:30 pm)
Friday nights: due by 11:59 pm - ish
Insight into the HW problems (what, why, how)
feel free to work on HW, to just stop by,
W: 3-5pm Olin B163
Key skills, topics, and their motivation
I'd like to see you! Let me know if you’ll be sick…
or, come to any of the many tutoring hrs!
LabGuided progress on the class's hw
W 9-9:50 (M or T: 2:45 - 4:45 pm or 8:00 - 10:00 pm)
Will SAVE you time and effort to get started!Not required, but encouraged
recommended by 4 out of 5 CS-for-Insight alums!
Syllabus, brieflyHMC
HMC
same for HMC
This week's hw… by next Fri. night:
Get to the CS5 website and hw0. Complete hw0pr0 - in brief,
1. Make sure you can log into the submission system
2. Change your password + upload an image3. Run and submit hw0pr0.py (provided!)
Extra: submit a rock-paper-scissors-playing program…
username = first initial + last name (most often)
password =troubles? email me!
Extra! Extra! ~ if you do the extra credit this week, your first problem for next week is already complete!
This week's hw… by Sunday night:
Get to the CS5 website and hw0. Complete hw0pr0 - in brief,
1. Make sure you can log into the submission system
2. Change your password + upload an image3. Run and submit hw0pr0.py (provided!)
Extra: submit a rock-paper-scissors-playing program…
username = first initial + last name (most often)
password =troubles? email me!
Extra! Extra! ~ if you do the extra credit this week, your first problem for next week is already complete!
Demo!
Eur-ollowed to use one Euro for up to
three hwks.
No need to let us know, even.
HomeworkAssignments ~ 5 problems/week
Due Friday evenings by 11:59 pm.
Collaborate!
Some problems are specified “individual-only.”Others offer the option of working as pairs/partners:
• You don’t have to work in pairs/partners (that said, it's fun!)
• You must share the work equally - typing and coaching
• Be sure to indicate who your partner was at the submission site!
• Put your name(s) in the code, as well!
"Late Days"You have 3 CS 5 Euros to use…
Extra credit is usually available…
Pairs Partners
one computertradeoff typing/debugging ~
about every 20 minutes
two computersboth partners type/debug ~
provide help as needed
Standard is the same either way:
After finishing the hw, (a) each person has contributed equally and (b) both could complete the problems on their own
Submit with a partner as full co-owners of the work.
Please do use the internet for Python language references.
Pleas do use other's eyes for finding syntax erorrs.
Do not use the internet (or intranet) to (try to) find solutions…
If you work as a pair/partners, the rules apply for the duo.
Honor Code• You're encouraged to discuss problems with
other students – or tutors - or any instructors.
• You may not share written, electronic or verbal solutions with other students, present or past:
Even with three eyes, I
need to borrow others'
to find the syntax errors
here!
Grading
Exams
if perc > .95: print 'A'elif perc > .90: print 'A-'elif perc > .70: print 'Pass'
~ 65% Assignments
~ 5% Participation/“quizzes”
~ 30% Exams
using a page of notes is OK on exams
Final
most take CS5 P/NC
Midterm No foolin'! This feels more like a 3/4-term!
see online syllabus for the full grade list...
W, April 1, in-classF, May 15, in-class
the exams are written, not coded
the problems are modeled on the in-class "quizzes"
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:
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?
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
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?)
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 ?
# of TESTS ?
# of Control Structures ?
"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?
"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:
(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?
• Name
• Your favorite _____ is ________________.
• Your least favorite _______ is ______________.
Zach Dodds
tv show (+
Merlin)
coffee decaffeinated
Something in common? Our taste in hats!
"Quiz"
• Name
• Your favorite _________ is _______.
• Your least favorite _______ is ________.
canned-meat food product spam
# 41.999
T. E. Alien
Dr. Who
"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:
(4) How many RPS cases are there? How many of them are correctly handled by this code?
(Extra) What if it were RPS-5, with Lizard and Spock? RPS-101?
Please pass
these to the
aisles…
Turn back to
the notes.
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…
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 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
Remember ~ by Sunday night:
See you next Monday, everyone!!
Alien defeats everything – even Alien
How about a sneak peek at next week's CS… ? … you must mean sneak Pic !
Get to the CS5 website and complete hw0pr0Make sure you can log into the submission systemChange your passwordSubmit hw0pr0.py (provided!)Extra: submit an RPS-playing program…
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…
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
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:
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:
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:
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?
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 ?
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:
"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?
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?
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?
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
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?
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?
… and who is this Mudder, 35 years later?
Jon “Dean” Jacobsen, 1979
What is programming ?
Programming as "recipe-writing"
vs.
Programming as learning a foreign language
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
!
Why CS 5 ?Broad, constructive tour in CS
1
2
34
5
recursionsimulation
design
semester abroad
in pictures?
Python Programming?
One possibility...
Python Programming?
One possibility...
Happy co-existence! It can even be comfy!
Python Programming?
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!
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
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, "!"
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, "!"
What about me?
'Zach'
'Chris'
Zach
Chris
Eliot or Ran
Zach
‘Eliot’ or ‘Ran’
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
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
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
(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
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?
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?
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”
How I spent my summer vacation...
visiting Google Irvine serving as a historical consultant!