0% found this document useful (0 votes)
98 views112 pages

Lectures Cip3 Lecture-Slides-Karel File PDF

This document introduces Code in Place, an introductory computer science course taught online and volunteer-led. It discusses the teaching team, course structure, and goals. The course uses Karel the robot as a gentle way to introduce programming concepts using Python. Students will learn programming basics through examples and exercises controlling Karel. The document emphasizes community, learning by doing, and creating a welcoming environment for all.

Uploaded by

Zaky Drive
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views112 pages

Lectures Cip3 Lecture-Slides-Karel File PDF

This document introduces Code in Place, an introductory computer science course taught online and volunteer-led. It discusses the teaching team, course structure, and goals. The course uses Karel the robot as a gentle way to introduce programming concepts using Python. Students will learn programming basics through examples and exercises controlling Karel. The document emphasizes community, learning by doing, and creating a welcoming environment for all.

Uploaded by

Zaky Drive
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 112

Lesson 1

Welcome to Code in Place

Piech and Sahami, Code in Place


In your first lesson
✔ Meet the Teaching Team
✔ What Is Code in Place?
✔ Get to Know Karel!

Start something beautiful!


Piech and Sahami, Code in Place
Meet the team!

Piech and Sahami, Code in Place


Mehran Sahami

• Childhood: Iran
• High School: San Diego
• Stanford University Ph.D. in Machine Learning
(Before Machine Learning was cool)
• Spent a decade in tech industry before coming back as professor
• Love of teaching is why I came back

Piech and Sahami, Code in Place


Mehran Sahami

Piech and Sahami, Code in Place


Chris Piech

Piech and Sahami, Code in Place


Chris Piech

Piech and Sahami, Code in Place


Leadership Team

Piech and Sahami, Code in Place


24 Amazing Head TAs

Piech and Sahami, Code in Place


700 Section Leaders

These are not the actual people, just a representation

Piech and Sahami, Code in Place


Piech and Sahami, Code in Place
Gather around and let
me tell you a story

Piech and Sahami, Code in Place


Piech and Sahami, Code in Place
Multiple
pandemics

Pandemic of
loneliness

Pandemic of
education
inequality

Piech and Sahami, Code in Place


Scale the best part of Stanford
What is the secret sauce of: CS106A,
Stanford’s Intro to Computer Science course?

Section Leaders

Piech and Sahami, Code in Place


Laura: Shelter in Code?
Mehran: Code in Place

Piech and Sahami, Code in Place


Code in Place 2021:

2,400+ section leaders teach


24,000+ students
1/2 of CS106A
As Community Service
Piech and Sahami, Code in Place
Represent over 150 countries
One of the most interesting classes ever assembled

Piech and Sahami, CS106A, Stanford University


This class is just for fun
(what could be more fun than learning)

Piech and Sahami, Code in Place


We are doing this as volunteer
work. You get a class for free!

Piech and Sahami, Code in Place


This class is at it’s best if we
help each other. We want
everyone to succeed.

Piech and Sahami, Code in Place


Course Logistics

Piech and Sahami, Code in Place


Prerequisite Test

Piech and Sahami, CS106A, Stanford University


Course Website

https://codeinplace.stanford.edu/cip3

Piech and Sahami, Code in Place


Learning Goal

Learn how to solve


problems with
python

Find the joy


of a new skill

Piech and Sahami, Code in Place


Course components:

Piech and Sahami, Code in Place


Section 50 mins

Build a community
Piech and Sahami, Code in Place
Please try to make them!

Your section leaders really want


you there

Piech and Sahami, Code in Place


Your Tasks

Piech and Sahami, Code in Place


Lessons

Piech and Sahami, Code in Place


Lessons: Worked Examples

Piech and Sahami, CS106A, Stanford University


Lessons: Online Readings

Piech and Sahami, CS106A, Stanford University


Discussion Forum

Piech and Sahami, Code in Place


Course Communication
For almost all
questions, the Forum
is the right place.

There are 10,000


students.

Private posts go to
just the section
leaders
Piech and Sahami, Code in Place
We are all learners, teachers

This is a collective
community service project.
You are part of our
community.

Help us make this work.

Piech and Sahami, Code in Place


We are all learners, teachers

Do:

Show respect for others in


all actions in Code in Place.

Piech and Sahami, Code in Place


We are all learners, teachers

Do:

Protect your privacy. This is


a public classroom with
folks from all walks of life.

Piech and Sahami, Code in Place


We are all learners, teachers

Do not:

Advertise or solicit outside


groups or organizations.
We can’t vouch for them!

Piech and Sahami, Code in Place


We have been building…

👷👷
󰠻Piech and Sahami, Code in Place
Course Plan

Karel
Karel

Data
Graphics

Piech and Sahami, Code in Place


Karel Speaks Python

Piech and Sahami, Code in Place


Khansole Academy

Piech and Sahami, Code in Place


Khansole Academy

Piech and Sahami, Code in Place


The Challenge

Piech and Sahami, Code in Place


The Course Rhythm
This Week

Next Week

Piech and Sahami, Code in Place


The Course Rhythm

Piech and Sahami, Code in Place


What is a successful
experience?

If you learn something, you


have been successful.

Piech and Sahami, Code in Place


What if I fall behind?

Not a worry, we will leave


material up for you to finish at
your own pace.

Piech and Sahami, Code in Place


Course Values

Piech and Sahami, Code in Place


Art of Computer Science

Piech and Sahami, Code in Place


Learn by Doing

Footer Text 51
4/9/20 Piech and Sahami, Code in Place
Humane in Trying Times

Piech and Sahami, Code in Place


Gratitude

Piech and Sahami, Code in Place


Being Welcoming

Piech and Sahami, CS106A, Stanford University


There are a lot of cool
programs you may one day
write

Piech and Sahami, CS106A, Stanford University


Computer Graphics

Pat Hanrahan, a founding employee at Pixar, is a professor at Stanford.


He won the Turing Award last year – the Nobel Prize of Computer Science
Piech and Sahami, CS106A, Stanford University
Consumer Applications

Piech and Sahami, CS106A, Stanford University


Medical Innovation

(c) 2012 Intuitive Surgical, Inc.

Piech and Sahami, CS106A, Stanford University


Self-Driving Car

Piech and Sahami, CS106A, Stanford University


This is the start
of your journey

Piech and Sahami, CS106A, Stanford University


We have seen many people
learn to code

Piech and Sahami, CS106A, Stanford University


It is hard!

Piech and Sahami, CS106A, Stanford University


That is why we start with a
gentle introduction

Piech and Sahami, CS106A, Stanford University


Piech and Sahami, CS106A, Stanford University
Lesson 1
Meet Karel

Piech and Sahami, Code in Place


Meet Karel the Robot

Good morning

Piech and Sahami, CS106A, Stanford University


Karel Speaks Python

Piech and Sahami, CS106A, Stanford University


Why Python?

1 Program language popularity

y thon
p

2012
2019

https://stackoverflow.blog/2017/09/06/incredible-growth-python/
Piech and Sahami, CS106A, Stanford University
Guido van Rossum

Monty Python’s Flying Circus

Piech and Sahami, CS106A, Stanford University


Karel’s World

3 + + + + + North

2 + + + + + West East

1 + + + + +
South
1 2 3 4 5

Piech and Sahami, CS106A, Stanford University


Walls

3 + + + + +

2 + + + + +

1 + + + + +

1 2 3 4 5

Piech and Sahami, CS106A, Stanford University


Beepers

3 + + + + +

2 + + + + +

1 + + + + +

1 2 3 4 5

Piech and Sahami, CS106A, Stanford University


Knows Four Commands

move()
turn_left()
put_beeper()

pick_beeper()

Piech and Sahami, CS106A, Stanford University


move()

Piech and Sahami, CS106A, Stanford University


move()

3 + + + + +

2 + + + + +

1 + + + + +

1 2 3 4 5

Piech and Sahami, CS106A, Stanford University


move()

3 + + + + +

2 + + + + +

1 + + + + +

1 2 3 4 5

Piech and Sahami, CS106A, Stanford University


turn_left()

Piech and Sahami, CS106A, Stanford University


turn_left()

3 + + + + +

2 + + + + +

1 + + + + +

1 2 3 4 5

Piech and Sahami, CS106A, Stanford University


turn_left()

3 + + + + +

2 + + + + +

1 + + + + +

1 2 3 4 5

Piech and Sahami, CS106A, Stanford University


Bird’s Eye View

Karel is facing East

Piech and Sahami, CS106A, Stanford University


Turn Left

Karel is facing North

Piech and Sahami, CS106A, Stanford University


Turn Left

Karel is facing West

Piech and Sahami, CS106A, Stanford University


Turn Left

Karel is facing South

Piech and Sahami, CS106A, Stanford University


Move

Piech and Sahami, CS106A, Stanford University


pick_beeper()

Piech and Sahami, CS106A, Stanford University


pick_beeper()

3 + + + + +

2 + + + + +

1 + + + + +

1 2 3 4 5

Piech and Sahami, CS106A, Stanford University


pick_beeper()

3 + + + + +

2 + + + + +

1 + + + + +

1 2 3 4 5

Piech and Sahami, CS106A, Stanford University


First Challenge

3 + + + + +

2 + + + + +

1 + + + + +

1 2 3 4 5

Piech and Sahami, CS106A, Stanford University


First Challenge

3 + + + + +

2 + + + + +

1 + + + + +

1 2 3 4 5

Piech and Sahami, CS106A, Stanford University


Bird’s Eye View

3 + + + + +

2 + + + + +

1 + + + + +

1 2 3 4 5

Piech and Sahami, CS106A, Stanford University


First Challenge

3 + + + + +

2 + + + + +

1 + + + + +

1 2 3 4 5

Piech and Sahami, CS106A, Stanford University


First Challenge

3 + + + + +

2 + + + + +

1 + + + + +

1 2 3 4 5

Piech and Sahami, CS106A, Stanford University


Piech and Sahami, CS106A, Stanford University
Learn By Doing

Piech and Sahami, CS106A, Stanford University


Program in an IDE
Your application had an IDE

PyCharm is also an IDE


Piech and Sahami, CS106A, Stanford University
Function Definition

def name():
function statements

a n ew
a d ds a re ls
This nd to K
ma l a ry
co m a b u
v o c

Piech and Sahami, CS106A, Stanford University


Anatomy of a Program
Import Packages

Program

Piech and Sahami, CS106A, Stanford University


Anatomy of a Program
Import Packages

Piech and Sahami, CS106A, Stanford University


Anatomy of a Program
Import Packages

def main():
move()
pick_beeper()
move()
turn_left()
main function
move()
turn_right()
move()
put_beeper()
move()

def turn_right():
turn_left()
helper functions
turn_left()
turn_left()
if __name__
start == "__main__":
program
run_karel_program()
Piech and Sahami, CS106A, Stanford University
Anatomy of a Program
Import Packages

def main():
move()
pick_beeper()
move()
turn_left()
move()
turn_right()
move()
put_beeper()
move()

def turn_right():
turn_left()
helper functions
turn_left()
turn_left()
if __name__
start == "__main__":
program
run_karel_program()
Piech and Sahami, CS106A, Stanford University
Anatomy of a Program
Import Packages

def main():
move()
pick_beeper()
move()
turn_left()
move()
turn_right()
move()
put_beeper()
move()

def turn_right():
turn_left()
turn_left()
turn_left()
if __name__
start == "__main__":
program
run_karel_program()
Piech and Sahami, CS106A, Stanford University
Anatomy of a Program
Import Packages

def main():
move()
pick_beeper()
move()
turn_left()
move()
turn_right()
move()
put_beeper()
move()

def turn_right():
turn_left()
turn_left()
turn_left()
if __name__ == "__main__":
run_karel_program()
Piech and Sahami, CS106A, Stanford University
Anatomy of a Program
from karel.stanfordkarel import *

def main():
move()
pick_beeper()
move()
turn_left()
move()
turn_right()
move()
put_beeper()
move()

def turn_right():
turn_left()
turn_left()
turn_left()
if __name__ == "__main__":
run_karel_program()
Piech and Sahami, CS106A, Stanford University
Anatomy of a Program
from karel.stanfordkarel import *

def main():
move()
pick_beeper()
move()
turn_left()
move()
turn_right()
move()
put_beeper()
move()

def turn_right():
turn_left()
turn_left()
turn_left()
if __name__ == "__main__":
run_karel_program()
Piech and Sahami, CS106A, Stanford University
Anatomy of a Program
from karel.stanfordkarel import *

def main():
move()
pick_beeper()
move()
turn_left() This piece of the
move() program's source code is
turn_right() called a function.
move()
put_beeper()
move()

def turn_right():
turn_left()
turn_left()
turn_left()
if __name__ == "__main__":
run_karel_program()
Piech and Sahami, CS106A, Stanford University
Anatomy of a Program
from karel.stanfordkarel import *

def main():
move()
pick_beeper()
move()
turn_left()
move() This line of code gives the
turn_right() name of the function
move() (here, main)
put_beeper()
move()

def turn_right():
turn_left()
turn_left()
turn_left()
if __name__ == "__main__":
run_karel_program()
Piech and Sahami, CS106A, Stanford University
Anatomy of a Program
from karel.stanfordkarel import *

def main():
move()
pick_beeper()
move()
turn_left()
move() This line of code gives the
turn_right() name of the function
move() (here, turn_right)
put_beeper()
move()

def turn_right():
turn_left()
turn_left()
turn_left()
if __name__ == "__main__":
run_karel_program()
Piech and Sahami, CS106A, Stanford University
Anatomy of a Program
from karel.stanfordkarel import *

def main():
move()
pick_beeper()
move()
turn_left() This is called a
move() code block
turn_right()
move()
put_beeper()
move()

def turn_right():
turn_left()
turn_left()
turn_left()
if __name__ == "__main__":
run_karel_program()
Piech and Sahami, CS106A, Stanford University
Anatomy of a Program
from karel.stanfordkarel import *

def main():
move()
pick_beeper()
move()
turn_left() This is called a
move() code block
turn_right()
move()
put_beeper()
move()

def turn_right():
turn_left()
turn_left()
turn_left()
if __name__ == "__main__":
run_karel_program()
Piech and Sahami, CS106A, Stanford University
Anatomy of a Program
from karel.stanfordkarel import *

def main():
move()
pick_beeper()
move()
turn_left() This is called a
move() code block
turn_right()
move()
put_beeper()
move()

def turn_right():
turn_left()
turn_left()
turn_left()
if __name__ == "__main__":
run_karel_program()
Piech and Sahami, CS106A, Stanford University
The End,
but really just the start.

Piech and Sahami, CS106A, Stanford University


Be well and be kind.

Piech and Sahami, CS106A, Stanford University

You might also like