際際滷

際際滷Share a Scribd company logo
Choosing a Programming Language for CS1
Fred Annexstein
CS Curriculum Meeting
April 9, 2015
Current State of Language Adoption for
CS1-type Courses in US
The chart below shows how many of the top 39 departments teach either CS0
or CS1 using the seven most common languages. The bar heights add up to
more than 39 since many schools offer both CS0 and CS1.
Rank University Python Java MATLAB C C++ Scheme
1 Carnegie Mellon 15-110, 15-112 15-122
1 MIT 6.00, 6.01
1 Stanford CS106A
1 UC Berkeley CS61A
5 UIUC CS103 CS125 CS101 CS101
6 Cornell CS1110 CS1112
6 U.Washington CSE140 CSE142
8 Princeton COS126
9 Georgia Tech CS1301, CS1315 CS1371
9 UT Austin CS303E CS312
11 Caltech CS1
11 U. Wisconsin Madison CS302
13 UCLA CS31
13 U. Michigan EECS182 EECS182, 183
15 Columbia ENGI E1006 COMS W1004-1 COMS W1005-1
15 UCSD CSE8A CSE7 CSE5A
15 U. Maryland - College Park CMSC 198C,D,E CMSC131
18 Harvard CS50
19 U. Penn CIS 110, 120
20 Brown CSCI0931 CSCI0150 CSCI0040 0170,0190
20 Purdue CS17700 CS18000 CS15900 CS15800, CS15900
20 Rice COMP 140
20 USC CSCI 101 CSCI 103 CSCI 103
20 Yale CPSC112 CPSC201
25 Duke CompSci 101
25 UMass Amherst CMPSCI 119 CMPSCI 121
25 UNC Chapel Hill Comp 110 Comp 401
28 Johns Hopkins EN600.107
29 NYU CSCI-UA.2 CSCI-UA.0101
29 Penn State CMPSC 121
29 UC Irvine CSE 41
29 U. Minnesota CSci 1001,1901 CSci 1103 CSci 1901
29 U. Virginia CS 1120 CS 1110, 1111
34 Northwestern EECS110 EECS110 EECS111
34 Ohio State CSE201 CSE 205 CSE 202
34 Rutgers CS111
34 UC Davis ECS 10
34 UC Santa Barbara CS8
34 U. Chicago CMSC 12100, 12200, 12300 CMSC 12100, 12200, 12300
CMSC 12100, 12200, 12300 CMSC 10500, 11500
Ref: BLOG@CACM
CS1 Assumptions
 Goals of the CS1 instruction
 learn computer programming  no tech background assumed.
 Must provide students with a broad view of the CS field:
 theory and practice,
 academic and industrial perspectives.
 Course Core
 problem-solving
 program design
 programming implementations
 Learning to program
 is a hands-on activity,
 involves programming projects of various sizes in lab setting.
CS1 Ideals
 Expose students to a variety of programming
methodologies
 procedural and functional decomposition,
 object-oriented methods.
 Avoid narrow or complex prog language issues
 Empower students to see the scope and
possibilities of computer programming.
 Super fun and not scary (scary comes later)
Choosing an introductory
programming language
 The hands-on, experimental nature of the course
implies
 Programming language should enable program
designs that are concise and expressed with
minimal overhead.
 To encourage experimentation the language
should enable
 easy modification and much interactivity.
 To encourage computational thinking about
algorithms and design the language expressions
should limit low-level implementation details.
Problems with a C++ only course
 C++ makes experimentation difficult
 long cycle times between compilations,
 long and indecipherable (link) errors,
 mysterious crashes from pointer or array-bounds errors,
increasing frustration.
 No simple, high-quality, platform independent IDE
 Most C++ textbooks focus on dry, simplistic
database programming projects.
Successes with Python
 Python 1.0 1990  2.0 2000  Python 3.0 2008
 Many platform independent high-quality IDEs
 The most widely used language for CS1 in top CS
programs
 Credited with increasing diversity and female
participation in CS
 All large MOOCs (edX, Coursera, Udacity) use it in
Intro to CS courses
 Many Large Software Projects:
http://en.wikipedia.org/wiki/List_of_Python_software
Python-based Courses and Resources
 UC-Berkeley CS61A
 Composing Programs (based on modernizing SICP)
 Rice University and Coursera-Fundamentals of Computing
 MIT OpenCourseware - Introduction to CS and
Programming
 Harvard and Edx: Introduction to Computer Science
 Harvey Mudd CS5
 CSforAll (text developed under NSF CPATH grant)
 Rose-Hulman CSEE 120 (integration with C)
 Paul Talagas Shared Doc
Courses Integrating Python-Low-level Constructs
NPR: How One
College Is Closing
The Computer
Science Gender Gap
C++ vs Python: Design and Function
System Prog w/ C++
 Statically typed
 Compiled
 Reflects underlying
machine architecture
 Useful for performance
intensive tasks
 Device drivers, games,
media engines, telecom,
embedded systems
Scripting w/ Python
 Dynamically typed
 Repl - interactive
 Industrial strength for rapid
development
 Web + Internet frameworks
 Scientific, numerical, and
data mining,
 Automated testing and tools
 Desktop GUIs
Compare Codes - Caesar Ciphers
Python
def main():
plain = list(raw_input('Enter msg: '))
alpha = list('abcdefghijklmnopqrstuvwxyz)
k = input("Enter key: ")
cipher = ''
for c in plain:
c = c.lower()
if c in alpha:
cipher += alpha[(alpha.index(c)+k)
%(len(alpha))]
print Encrypted message is:  + cipher
main()
C++
#include <iostream>
#include <string>
using namespace std;
int main() {
string plain;
cout << "Enter msg: " << endl;
getline(cin, plain);
int k; cout << "Enter key"; cin >> k;
string cipher = "";
for(int i = 0; i < input.length(); i++){
char c = plain[i];
if ((c >= 97) && (c <= 122))
cipher += (((c-97)+ k) % 26) + 97;
}
cout << "Encrypted message is: " << cipher
<< endl;
} //end main
Teaching Data Methods:
List Enumeration and Visualization
>>>text = When in the course of human events it 
>>>words = list(text.split())
>>>for w in words:
if w not in stopWords:
print w,
=> course human events people 
________________________________________________
>>>noprimes = [j for d in range(2, 8)
for j in range(d*2, 50, d)]
>>>primes = [x for x in range(2, 50)
if x not in noprimes]
>>> print primes
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
Teaching OOP
Concisely
class Stack:
def __init__(self,size):
self.data = [None]*size
self.size = 0
def push(self,item):
self.data[self.size] = item
self.size = self.size + 1
def pop(self):
self.size = self.size - 1
return self.data[self.size]
def is_empty(self):
return self.size == 0
def is_full(self):
return self.size == len(self.data)
from Stackfile import *
S1 = Stack(3)
for i in
[one,True,3.0]:
S1.push(i)
print S1.is_full()
Python Type Safety
 Full dynamic run-time type checking
 Bounds checking on array subscripts.
 Easy to type and namespace check at the repl. Also
docstrings not stripped, useful for interactive help
 Employs garbage collection
 no problem with dangling pointers or memory leaks.
 No segmentation faults.
Good Design == Fun
 With Python
 easier to learn programming
 easier to complete more interesting projects.
 Just four Iterator types unify much of the language 
automatically apply in for-loop:
 immutable strings,
 list (dynamic array) data structure,
 tuples (immutable lists)
 dictionaries (hash tables).
 These can be used to quickly build sophisticated data
structures for interesting projects.
Libraries == More Fun
 Absence of type declarations
 makes for less code and more flexible programming.
 Huge library (standard and contributed modules) provides
components for
 programming GUIs, client-server applications, html viewers,
databases, animations, and much more.
 Interesting projects can be developed with only a fraction
of the code that would be required in a system language.
 Experience shows that students are
 more productive
 less frustrated
 enjoy the repl.
Addressing concerns of
experience in low-level programming
 Python is an opportunity to
 demonstrate, compare, and experiment with
low-level programming constructs
 Example
 Comparison of codes, e.g., Caesar Cipher
 Coverage of the C-reference implementation
of the Python list construct
 Excellent introduction to DS-style topics
involving pointers and arrays
Rank University Python Java MATLAB
1 Carnegie Mellon 15-110, 15-112 15-122
1 MIT 6.00, 6.01
1 Stanford CS106A
1 UC Berkeley CS61A CS10
5 UIUC CS103 CS125 CS101 CS101
6 Cornell CS1110 CS1112
6 U.Washington CSE140 CSE142
8 Princeton COS126
9 Georgia Tech CS1301, CS1315 CS1371
9 UT Austin CS303E CS312
11 Caltech CS1
11 U. Wisconsin Madison CS302 CS202
13 UCLA CS31
13 U. Michigan EECS182 EECS182, 183
15 Columbia ENGI E1006 COMS W1004-1 COMS W1005-1
15 UCSD CSE8A CSE7 CSE5A
15 U. Maryland - College Park CMSC 198C,D,E CMSC131
18 Harvard CS50
19 U. Penn CIS 110, 120
20 Brown CSCI0931 CSCI0150 CSCI0040 0170,0190
20 Purdue CS17700 CS18000 CS15900 CS15800, CS15900
20 Rice COMP 140
20 USC CSCI 101 CSCI 103 CSCI 103
20 Yale CPSC112 CPSC201
25 Duke CompSci 101
25 UMass Amherst CMPSCI 119 CMPSCI 121
25 UNC Chapel Hill Comp 110 Comp 401
28 Johns Hopkins EN600.107
29 NYU CSCI-UA.2 CSCI-UA.0101
29 Penn State CMPSC 121
29 UC Irvine CSE 41
29 U. Minnesota CSci 1001,1901 CSci 1103 CSci 1901
29 U. Virginia CS 1120 CS 1110, 1111
34 Northwestern EECS110 EECS110 EECS111
34 Ohio State CSE201 CSE 205 CSE 202
34 Rutgers CS111
34 UC Davis ECS 10
34 UC Santa Barbara CS8
34 U. Chicago CMSC 12100, 12200, 12300 CMSC 12100, 12200, 12300 CMSC 12100, 12200,
12300 CMSC 10500, 11500
Sample Python Lab #1: Freshman CS1
Lab #1 Algorithm:
0. Create a list of all the words
from web transcript.
1. Remove Stop Words.
2. Determine Frequency of
remaining words.
3. Find the word with the largest
frequency.
4. Print it  and its frequency 
and remove it.
5. Prompt the user to continue or
not.
6. If yes then go to step 3. Else
end the program gracefully.
https://compuzzle.wordpress.com/2015/01/08/project-1-what-are-the-
most-significant-words-in-the-declaration-of-independence/
Sample Midterm Python Lab #6:
Freshman CS1
ADTs, OperatorOverloading, Recursion
Lab: Complex Plane drawing of
n-dimensional Hypercubes
nth_roots_of_unity =
[math.e**(complex(0,1)*2*math.pi*k/n)
for k in range(n)]
def binary(i,n):
if (n == 0):
return ''
else:
if (i % 2 == 0):
return binary(i/2,n-1) + '0'
else:
return binary((i-1)/2, n-1)+'1'
https://compuzzle.wordpress.com/2015/03/19/adts-and-operator-
overloading/
Ad

Recommended

Sample CS Senior Capstone Projects
Sample CS Senior Capstone Projects
Fred Annexstein
Interfacing C/C++ and Python with SWIG
Interfacing C/C++ and Python with SWIG
David Beazley (Dabeaz LLC)
仂亟从仍ム亠仆亳亠 于仆亠仆亳 弍亳弍仍亳仂亠从 于 python
仂亟从仍ム亠仆亳亠 于仆亠仆亳 弍亳弍仍亳仂亠从 于 python
Maxim Shalamov
How to think like a computer scientist - Learn with python
How to think like a computer scientist - Learn with python
Rajendra Kumar Uppal
Python-content-1.pdf
Python-content-1.pdf
panimalarhemdochemla
thinkCSpy
thinkCSpy
webuploader
Learn Python
Learn Python
Vinayak Hegde
Lecture02
Lecture02
Rudy Martinez
Python programming language presentation
Python programming language presentation
dhanishev1
Solution Manual for Python for Everyone 2nd Edition Horstmann
Solution Manual for Python for Everyone 2nd Edition Horstmann
tactsukut
Python-Introduction-slides-pkt
Python-Introduction-slides-pkt
Pradyumna Tripathy
Python for Engineers-AI102Prgdefhdhfb.pptx
Python for Engineers-AI102Prgdefhdhfb.pptx
LatikaSharma62
PYTHON INTERNSHIP PPT download free.pptx
PYTHON INTERNSHIP PPT download free.pptx
dhruvn097
2024-25 TYBSC(CS)-PYTHON_PROG_ControlStructure.pptx
2024-25 TYBSC(CS)-PYTHON_PROG_ControlStructure.pptx
sangeeta borde
pythonUnit_1forprogrammin launguage.pptx
pythonUnit_1forprogrammin launguage.pptx
bharathece1
Introductory Programming With Python
Introductory Programming With Python
Brendan McCane
PP ECE A Sec UNIT-1.pptx
PP ECE A Sec UNIT-1.pptx
Venkateswara Babu Ravipati
Python for class 11 (CBSE Computer science sub code 083)
Python for class 11 (CBSE Computer science sub code 083)
Nitin Kumar
Das patrac sandpythonwithpracticalcbse11
Das patrac sandpythonwithpracticalcbse11
NumraHashmi
Expection Setting - 1st ppt. pptx
Expection Setting - 1st ppt. pptx
DarshanR953832
Python_intro.ppt
Python_intro.ppt
Mariela Gamarra Paredes
Programming RPi for IoT Applications.pdf
Programming RPi for IoT Applications.pdf
rakeshk213994
Python for informatics
Python for informatics
Christoforos Rekatsinas
PYthon
PYthon
Rajesh Tiwary
Python in 30 minutes!
Python in 30 minutes!
Fariz Darari
Learn Python 3 for absolute beginners
Learn Python 3 for absolute beginners
KingsleyAmankwa
Python avinash
Python avinash
Avinash Jangir
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
Prof. Wim Van Criekinge
Revista digital preescolar en transformaci坦n
Revista digital preescolar en transformaci坦n
guerragallardo26
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado

More Related Content

Similar to CS1 and Python (20)

Python programming language presentation
Python programming language presentation
dhanishev1
Solution Manual for Python for Everyone 2nd Edition Horstmann
Solution Manual for Python for Everyone 2nd Edition Horstmann
tactsukut
Python-Introduction-slides-pkt
Python-Introduction-slides-pkt
Pradyumna Tripathy
Python for Engineers-AI102Prgdefhdhfb.pptx
Python for Engineers-AI102Prgdefhdhfb.pptx
LatikaSharma62
PYTHON INTERNSHIP PPT download free.pptx
PYTHON INTERNSHIP PPT download free.pptx
dhruvn097
2024-25 TYBSC(CS)-PYTHON_PROG_ControlStructure.pptx
2024-25 TYBSC(CS)-PYTHON_PROG_ControlStructure.pptx
sangeeta borde
pythonUnit_1forprogrammin launguage.pptx
pythonUnit_1forprogrammin launguage.pptx
bharathece1
Introductory Programming With Python
Introductory Programming With Python
Brendan McCane
PP ECE A Sec UNIT-1.pptx
PP ECE A Sec UNIT-1.pptx
Venkateswara Babu Ravipati
Python for class 11 (CBSE Computer science sub code 083)
Python for class 11 (CBSE Computer science sub code 083)
Nitin Kumar
Das patrac sandpythonwithpracticalcbse11
Das patrac sandpythonwithpracticalcbse11
NumraHashmi
Expection Setting - 1st ppt. pptx
Expection Setting - 1st ppt. pptx
DarshanR953832
Python_intro.ppt
Python_intro.ppt
Mariela Gamarra Paredes
Programming RPi for IoT Applications.pdf
Programming RPi for IoT Applications.pdf
rakeshk213994
Python for informatics
Python for informatics
Christoforos Rekatsinas
PYthon
PYthon
Rajesh Tiwary
Python in 30 minutes!
Python in 30 minutes!
Fariz Darari
Learn Python 3 for absolute beginners
Learn Python 3 for absolute beginners
KingsleyAmankwa
Python avinash
Python avinash
Avinash Jangir
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
Prof. Wim Van Criekinge
Python programming language presentation
Python programming language presentation
dhanishev1
Solution Manual for Python for Everyone 2nd Edition Horstmann
Solution Manual for Python for Everyone 2nd Edition Horstmann
tactsukut
Python-Introduction-slides-pkt
Python-Introduction-slides-pkt
Pradyumna Tripathy
Python for Engineers-AI102Prgdefhdhfb.pptx
Python for Engineers-AI102Prgdefhdhfb.pptx
LatikaSharma62
PYTHON INTERNSHIP PPT download free.pptx
PYTHON INTERNSHIP PPT download free.pptx
dhruvn097
2024-25 TYBSC(CS)-PYTHON_PROG_ControlStructure.pptx
2024-25 TYBSC(CS)-PYTHON_PROG_ControlStructure.pptx
sangeeta borde
pythonUnit_1forprogrammin launguage.pptx
pythonUnit_1forprogrammin launguage.pptx
bharathece1
Introductory Programming With Python
Introductory Programming With Python
Brendan McCane
Python for class 11 (CBSE Computer science sub code 083)
Python for class 11 (CBSE Computer science sub code 083)
Nitin Kumar
Das patrac sandpythonwithpracticalcbse11
Das patrac sandpythonwithpracticalcbse11
NumraHashmi
Expection Setting - 1st ppt. pptx
Expection Setting - 1st ppt. pptx
DarshanR953832
Programming RPi for IoT Applications.pdf
Programming RPi for IoT Applications.pdf
rakeshk213994
Python in 30 minutes!
Python in 30 minutes!
Fariz Darari
Learn Python 3 for absolute beginners
Learn Python 3 for absolute beginners
KingsleyAmankwa
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
2016 bioinformatics i_python_part_2_strings_wim_vancriekinge
Prof. Wim Van Criekinge

Recently uploaded (20)

Revista digital preescolar en transformaci坦n
Revista digital preescolar en transformaci坦n
guerragallardo26
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
Introduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdf
TechSoup
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
The Man In The Back Exceptional Delaware.pdf
The Man In The Back Exceptional Delaware.pdf
dennisongomezk
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
Non-Communicable Diseases and National Health Programs Unit 10 | B.Sc Nursi...
Non-Communicable Diseases and National Health Programs Unit 10 | B.Sc Nursi...
RAKESH SAJJAN
Nice Dream.pdf /
Nice Dream.pdf /
ErinUsher3
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
FIRST DAY HIGH orientation for mapeh subject in grade 10.pptx
FIRST DAY HIGH orientation for mapeh subject in grade 10.pptx
GlysdiEelesor1
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
Revista digital preescolar en transformaci坦n
Revista digital preescolar en transformaci坦n
guerragallardo26
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
Introduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdf
TechSoup
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
Plate Tectonic Boundaries and Continental Drift Theory
Plate Tectonic Boundaries and Continental Drift Theory
Marie
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
The Man In The Back Exceptional Delaware.pdf
The Man In The Back Exceptional Delaware.pdf
dennisongomezk
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
How to Configure Vendor Management in Lunch App of Odoo 18
How to Configure Vendor Management in Lunch App of Odoo 18
Celine George
Capitol Doctoral Presentation -June 2025.pptx
Capitol Doctoral Presentation -June 2025.pptx
CapitolTechU
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
Non-Communicable Diseases and National Health Programs Unit 10 | B.Sc Nursi...
Non-Communicable Diseases and National Health Programs Unit 10 | B.Sc Nursi...
RAKESH SAJJAN
Nice Dream.pdf /
Nice Dream.pdf /
ErinUsher3
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Basic English for Communication - Dr Hj Euis Eti Rohaeti Mpd
Restu Bias Primandhika
FIRST DAY HIGH orientation for mapeh subject in grade 10.pptx
FIRST DAY HIGH orientation for mapeh subject in grade 10.pptx
GlysdiEelesor1
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
Ad

CS1 and Python

  • 1. Choosing a Programming Language for CS1 Fred Annexstein CS Curriculum Meeting April 9, 2015
  • 2. Current State of Language Adoption for CS1-type Courses in US The chart below shows how many of the top 39 departments teach either CS0 or CS1 using the seven most common languages. The bar heights add up to more than 39 since many schools offer both CS0 and CS1.
  • 3. Rank University Python Java MATLAB C C++ Scheme 1 Carnegie Mellon 15-110, 15-112 15-122 1 MIT 6.00, 6.01 1 Stanford CS106A 1 UC Berkeley CS61A 5 UIUC CS103 CS125 CS101 CS101 6 Cornell CS1110 CS1112 6 U.Washington CSE140 CSE142 8 Princeton COS126 9 Georgia Tech CS1301, CS1315 CS1371 9 UT Austin CS303E CS312 11 Caltech CS1 11 U. Wisconsin Madison CS302 13 UCLA CS31 13 U. Michigan EECS182 EECS182, 183 15 Columbia ENGI E1006 COMS W1004-1 COMS W1005-1 15 UCSD CSE8A CSE7 CSE5A 15 U. Maryland - College Park CMSC 198C,D,E CMSC131 18 Harvard CS50 19 U. Penn CIS 110, 120 20 Brown CSCI0931 CSCI0150 CSCI0040 0170,0190 20 Purdue CS17700 CS18000 CS15900 CS15800, CS15900 20 Rice COMP 140 20 USC CSCI 101 CSCI 103 CSCI 103 20 Yale CPSC112 CPSC201 25 Duke CompSci 101 25 UMass Amherst CMPSCI 119 CMPSCI 121 25 UNC Chapel Hill Comp 110 Comp 401 28 Johns Hopkins EN600.107 29 NYU CSCI-UA.2 CSCI-UA.0101 29 Penn State CMPSC 121 29 UC Irvine CSE 41 29 U. Minnesota CSci 1001,1901 CSci 1103 CSci 1901 29 U. Virginia CS 1120 CS 1110, 1111 34 Northwestern EECS110 EECS110 EECS111 34 Ohio State CSE201 CSE 205 CSE 202 34 Rutgers CS111 34 UC Davis ECS 10 34 UC Santa Barbara CS8 34 U. Chicago CMSC 12100, 12200, 12300 CMSC 12100, 12200, 12300 CMSC 12100, 12200, 12300 CMSC 10500, 11500 Ref: BLOG@CACM
  • 4. CS1 Assumptions Goals of the CS1 instruction learn computer programming no tech background assumed. Must provide students with a broad view of the CS field: theory and practice, academic and industrial perspectives. Course Core problem-solving program design programming implementations Learning to program is a hands-on activity, involves programming projects of various sizes in lab setting.
  • 5. CS1 Ideals Expose students to a variety of programming methodologies procedural and functional decomposition, object-oriented methods. Avoid narrow or complex prog language issues Empower students to see the scope and possibilities of computer programming. Super fun and not scary (scary comes later)
  • 6. Choosing an introductory programming language The hands-on, experimental nature of the course implies Programming language should enable program designs that are concise and expressed with minimal overhead. To encourage experimentation the language should enable easy modification and much interactivity. To encourage computational thinking about algorithms and design the language expressions should limit low-level implementation details.
  • 7. Problems with a C++ only course C++ makes experimentation difficult long cycle times between compilations, long and indecipherable (link) errors, mysterious crashes from pointer or array-bounds errors, increasing frustration. No simple, high-quality, platform independent IDE Most C++ textbooks focus on dry, simplistic database programming projects.
  • 8. Successes with Python Python 1.0 1990 2.0 2000 Python 3.0 2008 Many platform independent high-quality IDEs The most widely used language for CS1 in top CS programs Credited with increasing diversity and female participation in CS All large MOOCs (edX, Coursera, Udacity) use it in Intro to CS courses Many Large Software Projects: http://en.wikipedia.org/wiki/List_of_Python_software
  • 9. Python-based Courses and Resources UC-Berkeley CS61A Composing Programs (based on modernizing SICP) Rice University and Coursera-Fundamentals of Computing MIT OpenCourseware - Introduction to CS and Programming Harvard and Edx: Introduction to Computer Science Harvey Mudd CS5 CSforAll (text developed under NSF CPATH grant) Rose-Hulman CSEE 120 (integration with C) Paul Talagas Shared Doc
  • 10. Courses Integrating Python-Low-level Constructs NPR: How One College Is Closing The Computer Science Gender Gap
  • 11. C++ vs Python: Design and Function System Prog w/ C++ Statically typed Compiled Reflects underlying machine architecture Useful for performance intensive tasks Device drivers, games, media engines, telecom, embedded systems Scripting w/ Python Dynamically typed Repl - interactive Industrial strength for rapid development Web + Internet frameworks Scientific, numerical, and data mining, Automated testing and tools Desktop GUIs
  • 12. Compare Codes - Caesar Ciphers Python def main(): plain = list(raw_input('Enter msg: ')) alpha = list('abcdefghijklmnopqrstuvwxyz) k = input("Enter key: ") cipher = '' for c in plain: c = c.lower() if c in alpha: cipher += alpha[(alpha.index(c)+k) %(len(alpha))] print Encrypted message is: + cipher main() C++ #include <iostream> #include <string> using namespace std; int main() { string plain; cout << "Enter msg: " << endl; getline(cin, plain); int k; cout << "Enter key"; cin >> k; string cipher = ""; for(int i = 0; i < input.length(); i++){ char c = plain[i]; if ((c >= 97) && (c <= 122)) cipher += (((c-97)+ k) % 26) + 97; } cout << "Encrypted message is: " << cipher << endl; } //end main
  • 13. Teaching Data Methods: List Enumeration and Visualization >>>text = When in the course of human events it >>>words = list(text.split()) >>>for w in words: if w not in stopWords: print w, => course human events people ________________________________________________ >>>noprimes = [j for d in range(2, 8) for j in range(d*2, 50, d)] >>>primes = [x for x in range(2, 50) if x not in noprimes] >>> print primes [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
  • 14. Teaching OOP Concisely class Stack: def __init__(self,size): self.data = [None]*size self.size = 0 def push(self,item): self.data[self.size] = item self.size = self.size + 1 def pop(self): self.size = self.size - 1 return self.data[self.size] def is_empty(self): return self.size == 0 def is_full(self): return self.size == len(self.data) from Stackfile import * S1 = Stack(3) for i in [one,True,3.0]: S1.push(i) print S1.is_full()
  • 15. Python Type Safety Full dynamic run-time type checking Bounds checking on array subscripts. Easy to type and namespace check at the repl. Also docstrings not stripped, useful for interactive help Employs garbage collection no problem with dangling pointers or memory leaks. No segmentation faults.
  • 16. Good Design == Fun With Python easier to learn programming easier to complete more interesting projects. Just four Iterator types unify much of the language automatically apply in for-loop: immutable strings, list (dynamic array) data structure, tuples (immutable lists) dictionaries (hash tables). These can be used to quickly build sophisticated data structures for interesting projects.
  • 17. Libraries == More Fun Absence of type declarations makes for less code and more flexible programming. Huge library (standard and contributed modules) provides components for programming GUIs, client-server applications, html viewers, databases, animations, and much more. Interesting projects can be developed with only a fraction of the code that would be required in a system language. Experience shows that students are more productive less frustrated enjoy the repl.
  • 18. Addressing concerns of experience in low-level programming Python is an opportunity to demonstrate, compare, and experiment with low-level programming constructs Example Comparison of codes, e.g., Caesar Cipher Coverage of the C-reference implementation of the Python list construct Excellent introduction to DS-style topics involving pointers and arrays
  • 19. Rank University Python Java MATLAB 1 Carnegie Mellon 15-110, 15-112 15-122 1 MIT 6.00, 6.01 1 Stanford CS106A 1 UC Berkeley CS61A CS10 5 UIUC CS103 CS125 CS101 CS101 6 Cornell CS1110 CS1112 6 U.Washington CSE140 CSE142 8 Princeton COS126 9 Georgia Tech CS1301, CS1315 CS1371 9 UT Austin CS303E CS312 11 Caltech CS1 11 U. Wisconsin Madison CS302 CS202 13 UCLA CS31 13 U. Michigan EECS182 EECS182, 183 15 Columbia ENGI E1006 COMS W1004-1 COMS W1005-1 15 UCSD CSE8A CSE7 CSE5A 15 U. Maryland - College Park CMSC 198C,D,E CMSC131 18 Harvard CS50 19 U. Penn CIS 110, 120 20 Brown CSCI0931 CSCI0150 CSCI0040 0170,0190 20 Purdue CS17700 CS18000 CS15900 CS15800, CS15900 20 Rice COMP 140 20 USC CSCI 101 CSCI 103 CSCI 103 20 Yale CPSC112 CPSC201 25 Duke CompSci 101 25 UMass Amherst CMPSCI 119 CMPSCI 121 25 UNC Chapel Hill Comp 110 Comp 401 28 Johns Hopkins EN600.107 29 NYU CSCI-UA.2 CSCI-UA.0101 29 Penn State CMPSC 121 29 UC Irvine CSE 41 29 U. Minnesota CSci 1001,1901 CSci 1103 CSci 1901 29 U. Virginia CS 1120 CS 1110, 1111 34 Northwestern EECS110 EECS110 EECS111 34 Ohio State CSE201 CSE 205 CSE 202 34 Rutgers CS111 34 UC Davis ECS 10 34 UC Santa Barbara CS8 34 U. Chicago CMSC 12100, 12200, 12300 CMSC 12100, 12200, 12300 CMSC 12100, 12200, 12300 CMSC 10500, 11500
  • 20. Sample Python Lab #1: Freshman CS1 Lab #1 Algorithm: 0. Create a list of all the words from web transcript. 1. Remove Stop Words. 2. Determine Frequency of remaining words. 3. Find the word with the largest frequency. 4. Print it and its frequency and remove it. 5. Prompt the user to continue or not. 6. If yes then go to step 3. Else end the program gracefully. https://compuzzle.wordpress.com/2015/01/08/project-1-what-are-the- most-significant-words-in-the-declaration-of-independence/
  • 21. Sample Midterm Python Lab #6: Freshman CS1 ADTs, OperatorOverloading, Recursion Lab: Complex Plane drawing of n-dimensional Hypercubes nth_roots_of_unity = [math.e**(complex(0,1)*2*math.pi*k/n) for k in range(n)] def binary(i,n): if (n == 0): return '' else: if (i % 2 == 0): return binary(i/2,n-1) + '0' else: return binary((i-1)/2, n-1)+'1' https://compuzzle.wordpress.com/2015/03/19/adts-and-operator- overloading/