CS 101: Introduction to Computing
This first course on Computer Science will be an introduction to computer programming, both with a theoretical and practical point of view.
Please refer to that document (perso.crans.org/besson/cs101/) for more information.
Temporary version!
This syllabus is approximative and temporary, can be changed at any moment, and might be changed. This small overview is only here to help you know what we will probably study, and approximatively when.
Introduction to the CS101 course at MEC
What ?
This is a really quick introduction to computer programming, CS and Python for the CS101 course. That document was written in November 2014, and a hard copy was given to you in December, during the last exam (ME 101).
External links?
It gives mainly external links about Python and CS. Mainly:
- continuum.io/downloads to download Anaconda, the Python 2.7 installer we decided to use in the CS lab,
- www.Python.org the official website for Python,
- docs.Python.org/2/ the documentation for Python 2.7.
- IntroToPython.org, an excellent web-site to start learning Python.
Evolution of computers and history of CS
What?
- History of nowadays computers, from the abacus to the super computer,
- About networks (Internet etc),
- Historical figures who participated in the development of modern computers (pioneers),
- Main goals and approaches of computer programming,
- Strategies of problem solving with programming,
- Presentation of main concept : if, for, while loops, functions etc.
When?
- First two weeks of January 2015, by Prof. Sanjay Dhande (4 lectures).
CS101 Labs:
Week by week, lab by lab, we will add one document for each lab, with the content, assignements and some examples of programs:
Introduction to Python (1/3) and a few basic programming concepts
What?
- What is Python, and its main features, and why choosing Python?
- Presentation of the main goals for the CS101 course, and external references (books, websites, etc),
- Using Python, starting with numbers (
int
,float
,long
andcomplex
) and strings (str
), - Arithmetic operations (
+
,-
,*
,**
,/
,%
), - Printing text and values with the
print
command, - Using variables to store values (
year = 2015
,name = "Batman"
etc), - Taking input from the user (with the
input
orraw_input
functions), - More? Floating Point Arithmetic: Issues and Limitations.
When?
- Third week of January 2015, by Prof. Arya Kumar Bhattacharya (2 lectures).
Introduction to Python (2/3) and more programming concepts
What?
- Boolean values (
True
,False
), and operations (and
,or
,not
), - Comparisons (
<
,>
,==
,!=
,<=
,>=
) and testing (is
,in
,not in
), - If block (
if
), with or without anelse
block, and multiple cases withelif
, - Concept of For and While loops (
for element in list: ...
,while condition: ...
), - Writing block with the proper indentation,
- Looping over integers with the
xrange
function (e.g.for i in xrange(100): print i
), - Breaking blocks with
break
orcontinue
, - Nesting blocks and loops, how to and how not to,
- More? Remarks on the coding style.
When?
- Last week of January 2015, by Prof. Arya Kumar Bhattacharya (2 lectures).
Introduction to Python (3/3) and more programming concepts
What?
- Functions: mathematical concept, examples already seen (
help
,type
,input
etc), - How to use a function:
name(arg1, arg2, arg3)
, - Defining our own functions (
def f(args): ...
), - Returning a value from a function’s body (
return stuff
), - Default argument values and keyword arguments (e.g.
complex(real=1, imag=2) == 1+2j
), - Documenting a function (with a docstring
""" Like this."""
), - Recursive functions (ie. using
f
in its body), examples with Fibonacci’s sequence or the factorial (def f(n): return 1 if n==0 else n*(f(n-1))
), - Use of recursion for algorithms, example of the binary search,
- More? Limits of a recursive function (ie. max size of the call stack, usually 10 000).
When?
- First week of February 2015, by Prof. Arya Kumar Bhattacharya (2 lectures).
Introduction to algorithms
What?
- Main concepts of algorithms (different paradigms),
- Some basic examples: searching the smallest element, sorting a list of numbers,
- From an idea, to pseudo-code, and from pseudo-code to a Python program,
- Efficiency of an algorithm (the O(n) notation) with examples,
- Different criteria: memory or time consumption, other examples (bandwidth, battery etc),
- More on list sorting : bubble sort (in $O(n^2)$), stupid random shuffling sort (in $O(n!)$), insertion sort (in $O(n^2)$), concept of the fusion/merge sort (in $O(n \log(n))$),
- More? Read this Wikipédia article.
When?
- Last week of February and first of March 2015, by Prof. Arya Kumar Bhattacharya (3 lectures).
First Mid-Term Exam CS101 (S2 2014-15)
What?
This exam will cover everything seen during the lectures and the lab sessions, from the beginning of the course to the last lecture and lab before the exam.
A more precise syllabus is given below:
- Basic knowledge of history of computers and computing (covered by Prof. Dhande)
- What is a programming language, an editor, a console (terminal), and examples with the Python language, the Spyder editor and the IPython console,
- All the elements of syntax and language of Python covered in the labs and the lectures: values, operations, functions, comments, strings, etc. An almost complete list is: arithmetic operations, print statement, help and type functions, variables, different data types for numbers, strings, boolean values, boolean operators (
and
,or
,not
) and boolean testing, - Conditional blocks:
if
,elif
andelse
(concept, syntax, use, limitation, possible errors etc), - Conditional loop:
while
, and iterative loopfor
(concept, syntax, use, limitation, possible errors etc), - Functions: concept, use, examples (
help
,type
,abs
,len
etc), and how to define a function (e.g.def f(x, y): return cos(x**2 - y**2)
).
When?
1h30 written exam, the Monday 9th of February 2015, from 10:30am to 12:00.
Data structures in Python
What?
1) List and tuples
- Concept of a list (like an array in C),
- Creating and using lists, methods for lists (accessing, searching, sorting),
- Looping over lists, different ways,
- Tuple = an unmutable list,
- More? List comprehension, concept and examples,
- More? Arrays, queues and stacks, concept and references (on the Python documentation),
- Examples (with the lab), e.g. grades for MA101 (
g = ['A', 'B+', 'A', .., 'D']
)
2) Sets and frozensets
- Concept of a set, coming from maths,
- Creating and using sets, mathematical operations (
<
,!=
,>
,<=
,>=
,|
,&
,^
), - Frozenset = an unmutable set,
- Converting between lists, tuples, sets and frozensets,
- More? Quick explanation of the limitation (only hashable object, see also the
__hash__
method) - Examples (with the lab), e.g. set of courses at MEC.
3) Dictionnaries
- Concepts and examples of use. A dict as a powerful way to store data,
- Creating, using, updating a dictionnary (
nbStudents = {'2014': 230}
,d[key] = newvalue
, etc), - Looping over a dict, different approaches,
- Converting from and to other data types,
- More? Quick explanation of the limitation (only hashable object, see also the
__hash__
method) - Examples (with the lab), e.g. student list used to do the face-book for 2014-15.
When?
- First two weeks of March 2015, by Prof. Lilian besson (4 lectures).
Modules, OOP, Exceptions
What?
1) Modules
- Modules (and packages) in Python: how to use them (e.g.
import math
) or only a subpart (i.e.from math import cos, sin, tan
), - How to define our own modules (
module/__init__.py
,module/stuff.py
), - How to use and define the help for a module (with a docstring, e.g.
""" This."""
), - Standard modules: an overview of the standard library (part 2).
2) OOP
- Concepts of an object, a class, and “everything is an object in Python”,
- Using a method, defining a new instance of a class,
- Defining our own classes (
class MyClass: ...
), roles of the special functions/methods (__init__
,__str__
, e.g.__add__
), - Inheritance, concept and examples,
3) Errors and Exceptions
- Understanding error messages (e.g. syntax errors),
- How to handle exceptions (
try: ... except TypeError as e: ...
), and thefinally
block, - Raising exceptions,
- Defining our own exceptions with a class (using OOP).
When?
- Third week of March 2015, by Prof. Vipin Kizhepatt (5 or 6 lectures).
Second Mid-Term Exam CS101 (S2 2014-15)
What?
This exam will cover everything seen during the lectures and the lab sessions, from the beginning of the course to the last lecture and lab before the exam.
A more precise syllabus will be specified two weeks before the exam.
When?
1h30 written exam, between the 25th and 27th of March.
Introduction to scientific plotting and computations
What?
1) Files
> « After using the RAM for 3 months, let us use the hard-drive with Python! »
- Opening a file, different modes (
w
,r
,a
b
):myfile = open('here.txt', 'wr')
, - Reading from a file, looping over the lines of a file (
for line in myfile: ...
), - Closing a file, or using the
with
block (with open('stuff.json', 'r') as f: ...
), - Writing to a file (two modes,
w
ora
), - Bonus: working with files and directories with distutil.file_utile, distutil.dir_utile.
- Saving Python values and objects to a file with JSON (or Pickle),
- More? Fetching files from the web: urllib and urllib2.
2) Scientific computations on array of numbers
- Using Spyder
pylab
mode (from pylab import *
), - NumPy arrays are like list, but optimized for float and int numbers. E.g.
x = linspace(-pi, pi, 1000)
, - Performing mathematical computations on arrays of numbers is easy, e.g.
y = sin(x)
.
3) An introduction to scientific plotting with MatPlotLib
- Basic concepts (creating a figure, a plot, showing it, saving it etc),
- MatPlotLib Commands are very close to the plotting and computation commands of Matlab (you will use Matlab next year in EE203),
- List of examples of plotting coming from MA101 and MA102, and other courses : functional, polar and parametric curves; histogram, bar and pie charts; 2D scatter plots etc,
- Quick introduction to 3D plots, with basic examples from MA102 (first part),
4) Performing some simple linear algebra operations with Python
- By using the numpy.linalg package, it’s easy!
- Examples from MA102 (second and first parts) : dot product, inner product, rank of a matrix, determinant and solving a linear system, Gauss elimination, Gram-Schmidt process etc
When?
- Second and third week of April 2015, by Prof. Lilian Besson (5 lectures).
Conclusion of the CS101 course
What?
- Toolbox: from Python 2 to Python 3 (2to3 or Six),
- Maybe one lecture on Sphinx to generate a PDF and web documentation for a Python project,
- Two or three lectures as a complete sum-up of the semester (concepts, syntax, examples, main algorithms, etc).
When?
- Third week of April 2015, by Profs. Vipin Kizhepatt and Lilian Besson (2 to 4 lectures).
End of the Semester Exam CS101 (S2 2014-15)
What?
This exam will cover everything seen during the lectures and the lab sessions, from the beginning of the course to the last lecture and the last lab, plus the two projects.
A more precise syllabus will be specified three weeks before the exam.
When?
3h00 written exam, between the 4th and 8th of May.