CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer...

72
mith College Computer Science Dominique Thiébaut [email protected] CSC 111 Introduction to Computer Science Dominique Thiebaut Fall 2015

Transcript of CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer...

Page 1: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

mith College

Computer Science

Dominique Thiébaut [email protected]

CSC 111 Introduction to

Computer ScienceDominique Thiebaut

Fall 2015

Page 2: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Today:• Class Web Page: http://tinyurl.com/

1112015

• Syllabus

• Piazza

• Moodle

• Python & Idle

• Waiver forms & Registration

Page 3: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Syllabus • http://tinyurl.com/111-F2015

• http://cs.smith.edu

• faculty

• D. Thiebaut

• more info

Fall 2015

Page 4: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Please answer the Survey!

Page 5: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

CSC111: Amount of Work

Semester

Leve

l of D

ifficu

lty

Page 6: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

CSC111: Amount of Work

Semester

Leve

l of D

ifficu

lty

Your level

Page 7: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

This week…

Semester

Leve

l of D

ifficu

lty

Your level

Page 8: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Goals for this Week• Learn the Rules for Pair Programming

• Learn how to use Idle

• Write simple programs that use variables, for loops, and output information

• Install Python and Idle on laptop (optional)

• Learn how to submit Python programs to Moodle (lab+homework)

Page 9: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Rule for Laptop Use in Class

• Laptops welcome for note-taking, accessing class Web page, and for running Python programs

• All other use is forbidden

Page 10: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Reading

• Read Chapter 1 in John Zelle's Python Programming, up to Section 1.7 included

Page 11: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

What is a Programming

language?

Page 12: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Important Concepts…

• Syntax and keywords and del from not while as elif global or with assert else if pass yield break except import print class exec in raise continue finally is return def for lambda try

• Algorithm

Page 13: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Rules for Pair Programming

Page 14: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

https://www.youtube.com/watch?v=vgkahOzFH2Q

Page 15: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

An Example Program

Page 16: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Page 17: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

COMMENT

DIFFERENT COLORS:SYNTAX HIGHLIGHTING

INDENTATIONIS

IMPORTANT

SPECIAL TOOL:EDITOR

I D E

Page 18: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Integrated Development = IDLE Environment

Page 19: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Integrated Development Environment

Integrated Development = IDLE Environment

Page 20: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Integrated Development Environment

(MAC)

Integrated Development = IDLE Environment

Page 21: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Integrated Development Environment

(Windows)

Integrated Development = IDLE Environment

Page 22: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

DEMO TIME!

Page 23: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Registration Update

Page 24: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Concepts to Cover in Demo

• Console vs. Edit window

• Variables

• numbers: integers and floats

• text: strings of characters

• print function

Page 25: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Demo Programs To Play With…

for name in [ "Lea Jones", "Julie Fleur", "Anu Vias" ]: print( name ) print( "———————" )

age = 20 year = 2015 yearBorn = year - age print( "you are", age ) print( "you were born in", yearBorn )

name = "Alex" college = "Smith College" print( name, "goes to", college )

Page 26: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Demo Programs To Play With… (cont’d)

for name in [ "Lea Jones", "Julie Fleur", "Anu Vias" ]: print( name, len( name ) )

print( "hello" * 4 ) print( "-" * 10 ) greetings = “hello” dash = "-" print( greetings * 4 ) print( dash * 10 )

greetings = "hello" longGreetings = greeting * 4 print( greetings ) print( longGreetings )

Page 27: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Demo Programs To Play With… (cont’d)

for name in [ "Lea Jones", "Julie Fleur", "Anu Vias" ]: bar = len( name ) * "-" print( name ) print( bar )

print( "hello" * 4 ) print( "-" * 10 )

greetings = “hello” dash = "-" print( greetings * 4 ) print( dash * 10 )

greetings = "hello" longGreetings = greeting * 4 print( greetings ) print( longGreetings )

Page 28: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

We stopped here last time…

Page 29: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Registering Wait-Listed Students

• Status as of 1/28/15 (R=registered, NS=needs signature, WL=wait-listed)

• Lab 01: W 1-3: 21 R + 2 WL

• Lab 02: Th 1-3: 24 R + 1 WL (?)

• Lab 03: Th 3-5: 24 R + 4 WL

• Lab 04: W 3-5: 16 R + 0 WL

Page 30: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Registration Update

• 3 slots left

• Should be able to absorb wait-listed students

• No section transfer between Labs 1, 2, 3, or 4 unless you find somebody to transfer the other way

• Some seats left in Section 4 (Wed 1-3)

Page 31: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Plan Review of the lab

Introduction to Homework #1

def block

Demo

Something fun…

Page 32: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Lab 1 Q&A

Page 33: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Understanding Moodle's Comments (1)

Line 1Line 2Line 3Line 4

Expected Output

Page 34: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Understanding Moodle's Comments (1)

Line 1Line 2Line 3Line 4

Expected OutputLine 1Line 2Line 3Line 4

Your Program Output

Page 35: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Understanding Moodle's Comments (1)

Line 1Line 2Line 3Line 4

Expected OutputLine 1Line 2Line 3Line 4

Your Program Output

Page 36: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Understanding Moodle's Comments (2)

Line 1Line 2Line 3Line 4

Expected Output

Page 37: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Understanding Moodle's Comments (2)

Line 1Line 2Line 3Line 4

Expected OutputLine 1Lines 20Line 3Line 4

Your Program Output

Page 38: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Understanding Moodle's Comments (2)

Line 1Line 2Line 3Line 4

Expected OutputLine 1Lines 20Line 3Line 4

Your Program Output

Line 1 - Lines 20 ? - - + Line 2 Line 3 Line 4

Page 39: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Understanding Moodle's Comments (3)

Line 1Line 2Line 3Line 4

Expected Output

Page 40: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Understanding Moodle's Comments (3)

Line 1Line 2Line 3Line 4

Expected Output

Line 1Line 3Line 4

Your Program Output

Page 41: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Understanding Moodle's Comments (3)

Line 1Line 2Line 3Line 4

Expected Output

Line 1Line 3Line 4

Your Program Output

Line 1 + Line 2 Line 3 Line 4

Page 42: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Understanding Moodle's Comments (4)

Line 1Line 2Line 3Line 4

Expected Output

Page 43: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Understanding Moodle's Comments (4)

Line 1Line 2Line 3Line 4

Expected OutputLine 1Line 2Extra LineLine 3Line 4

Your Program Output

Page 44: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Understanding Moodle's Comments (4)

Line 1Line 2Line 3Line 4

Expected Output Your Program Output

It will depends!

Line 1Line 2Extra LineLine 3Line 4

Page 45: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Practice Python!

Page 46: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Beginningof the

Semester

Page 47: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

AFTERONE SEMESTER

Page 48: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Computer Science

Major

Page 49: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Memory

Page 50: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Variables

age

Page 51: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Variables

age age = 23

23

Page 52: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Variables

23

age = 23age23

assignment

Page 53: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Variables

name

“Smith”

name = “Smith”“Smith”

assignment

Page 54: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Variables

rate

21.34

rate = 21.3421.34

assignment

Page 55: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Variables & Expressions

age23

newValue10

age = 23 newValue = 10

Page 56: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Variables & Expressions

age23

newValue10

age = 23 newValue = 10 age = newValue

Page 57: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Variables & Expressions

age23 10

newValue10

age = 23 newValue = 10 age = newValue

Page 58: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Variables & Expressions

age10

newValue10

age = 23 newValue = 10 age = newValue age = age + 2

Page 59: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Variables & Expressions

age10

newValue10

age = 23 newValue = 10 age = newValue age = age + 2

10

Page 60: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Variables & Expressions

age10

newValue10

age = 23 newValue = 10 age = newValue age = age + 2

10+2

Page 61: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Variables & Expressions

age10

newValue10

age = 23 newValue = 10 age = newValue age = age + 2

10+2 —> 12

Page 62: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Variables & Expressions

age10 12

newValue10

age = 23 newValue = 10 age = newValue age = age + 2

10+2 —> 12

Page 63: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Exercisea = 10 b = 20 c = 30

a = b # a = ?

Page 64: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Exercisea = 10 b = 20 c = 30

a = b # a = 20 b = a # a = ? b = ?

Page 65: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Exercisea = 10 b = 20 c = 30

a = b # a = 20 b = a # a = 20 b = 20 c = c * 2 # c = ?

Page 66: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Exercisea = 10 b = 20 c = 30

a = b # a = 20 b = a # a = 20 b = 20 c = c * 2 # c = 60 d = d - 10 # d = ?

Page 67: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Exercisea = 10 b = 20 c = 30

a = b # a = 20 b = a # a = 20 b = 20 c = c * 2 # c = 60 d = d - 10 # NameError: # name 'd' is not defined

Page 68: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Naming Variables

a age delta name1 name2 R2D2 aVeryLongName

1tooMany

Page 69: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Naming Variables

a age delta name1 name2 R2D2 aVeryLongName

1tooMany

Page 70: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Naming Variables

this_is_good_too but wePrefer thisIsGoodToo

lambda for def

Page 71: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Exercise 1

***Mae*****Alice*******Felicia

Page 72: CSC 111 Introduction to Computer Science - Clark …€¦ ·  · 2015-09-11mith College C omputer Science Dominique Thiébaut dthiebaut@smith.edu CSC 111 Introduction to Computer

D. Thiebaut, Computer Science, Smith College

Exercise 2

*Mae********Alice****Felicia**