====== Programming for Data Science A.Y. 2017/18 ====== This is an introductory course to computer programming and related mathematical/logic background for students without a Bachelor in Computer Science or in Computer Engineering. The objective is to smoothly introduce the student to the programming concepts and tools needed for typical data processing and data analysis tasks. The course consists of lectures and practice in computer labs. =====Instructors===== * **Giuseppe Prencipe** (labs) * Università di Pisa * [[http://pages.di.unipi.it/prencipe/]] * [[giuseppe.prencipe@unipi.it]] * **Salvatore Ruggieri** (lectures) * Università di Pisa * [[http://pages.di.unipi.it/ruggieri/]] * [[ruggieri@di.unipi.it]] * **Jacopo Soldani** (lab assistant) * Università di Pisa * [[http://pages.di.unipi.it/soldani/]] * [[soldani@di.unipi.it]] =====Classes===== ^ Day of Week ^ Hour ^ Room ^ Type ^ | Monday | 11:00 - 13:00 | Fib C1 | Lectures | | Tuesday | 9:00 - 11:00 | Fib C1 | Lectures | | Wednesday | 16:00 - 18:00 | Fib M-Lab | Labs | | Thursday | 11:00 - 13:00 | Fib M-Lab | Labs | =====Office hours===== * Prof. Prencipe: Wednesdays h 15:00 - 19:00 or by appointment, Department of Computer Science, room 327/DO. * Prof. Ruggieri: Tuesdays h 14:00 - 17:00 or by appointment, Department of Computer Science, room 321/DO. =====Text Books===== * **[T]** Kenneth H. Rosen. //Discrete Mathematics and Its Applications//. Seventh Edition, MCGraw-Hill, 2012. [[http://highered.mheducation.com/sites/0073383090|Supplement material]] (including Errata-Corrige). * **[P]** Pieter Spronck. //The Coder’s Apprentice: Learning Programming with Python 3//, 2017. [[http://www.spronck.net/pythonbook|Book and supplement material]]. * **[C]** Brian W. Kernighan, Dennis M. Ritchie. //C Programming Language//. Second Edition, Prentice Hall, 1988. * **[A]** David A. Patterson,‎ John L. Hennessy. //Computer Organization and Design//. Fifth Edition, The Morgan Kaufmann Series in Computer Architecture and Design, 2014. [[http://apa.di.unipi.it/pds/video/MKComputerOrganizationAndDesign-1stChapter.pdf|MKComputerOrganizationAndDesign-1stChapter.pdf]] * **[O]** Paolo Ancilotti, Maurelio Boari, Anna Ciampolini, Giuseppe Lipari. //Sistemi Operativi//. McGraw-Hill, 2008 =====Software===== * **Python programming:** [[https://www.continuum.io/downloads|Anaconda distribution of Python 3]]. Computers at lab rooms include it both on Linux and Windows OS. * **C programing:** either [[https://wiki.gnome.org/Apps/Gedit|gedit]] (or equivalent text editor) and [[https://gcc.gnu.org/|gcc]]. If you do not have gcc on your machine, check next item. Gedit and gcc are available on computers at lab room (Linux only). * **gcc compiler:** To be able to compile C programs, you need to have a gcc compiler installed on your machine. If you use Linux....well, why are you still reading? :) If you use macOSX, almost no problems: just install XCode; then from Xcode Preferences > Downloads choose “Command line tool”, and install it as well: you will have gcc on your machine. Finally, for Windows users, you need to install any gcc compiler. You have two options: * (1) install minGW [[http://www.mingw.org/|minGW]]. Once the MinGW Installation Manager has been installed, execute it and install the whole MinGW package (from the Package menu). After everything has been downloaded and installed, you first need to set the PATH environment variable (see here: [[https://www.computerhope.com/issues/ch000549.htm|set Windows PATH]]); now, you will also have gcc compiler on your machine. * (2) install [[https://sourceforge.net/projects/orwelldevcpp/|DevC++]]: write and save your program, and then compile and run it by accessing the **Execute** menu. * **Compile C on lab machines (Windows)** Use DevC++. * **Editor for C files** Either use the DevC++ editor, or use [[https://notepad-plus-plus.org/download/v7.5.2.html|Notepad++ ]]. * **Python/C online** including visualization of memory state [[http://pythontutor.com/|PythonTutor]]. =====Preliminary program and calendar===== * [[https://esami.unipi.it/esami2/programma.php?c=34828&aa=2017|Preliminary program]]. * [[https://www.di.unipi.it/en/education/mds/academic-calendar-2017-2018-wea|Calendar of lessons]]. =====Exams===== Registration to exams and mid-terms is mandatory: [[https://esami.unipi.it/esami2/|register here]] **Next exam (reserved session) will be on Wednesday 4th of April, from 2pm to 6pm, Lab H.** IMPORTANT: **To be able to solve the C exercises during the exam, you need to use DevC++ installed in the Windows partition of the computers' lab**. Please, read **carefully** the instructions in the Software section above. ^ Day ^ Hour ^ Room ^ Type ^ | 30.10.2017 | 9:00 - 11:00 | M-Lab | First Mid-Term | | 18.12.2017| 11:00 - 13:00 | M-Lab | Second Mid-Term | | 15.1.2018| 9:00 - 13:00 | M-Lab | Regular Exam | | 12.2.2018| 9:00 - 13:00 | M-Lab | Regular Exam | | 22.6.2018| 14:00 - 16:00 | H-Lab | Regular Exam | | 13.7.2018| 14:00 - 16:00 | H-Lab | Regular Exam | | 07.9.2018| 9:00 - 13:00 | H-Lab | Regular Exam | **Mid-terms text and solutions: [[http://apa.di.unipi.it/pds/esercizi/PDS_2017_midterm_1.zip|PDS_2017_midterm_1.zip]] and [[http://apa.di.unipi.it/pds/esercizi/PDS_2017_midterm_2.zip|PDS_2017_midterm_2.zip]] ** **Sample exam texts and solutions: [[http://apa.di.unipi.it/pds/esercizi/PDS_2017_1session.zip|PDS_2017_1session.zip]], [[http://apa.di.unipi.it/pds/esercizi/PDS_2017_2session.zip|PDS_2017_2session.zip]] ** =====Class calendar===== Recordings are password protected. Ask the teachers for credentials. ^ ^ Day ^ Room ^ Topic ^ Learning material ^ Recordings ^ Instructor ^ |1.| 18.9 11:00-13:00 | C1 | Introduction. Propositional logic. | [**T**: 1.1-1.3] | [[http://apa.di.unipi.it/pds/video/20170918.flv|20170918.flv]] | Ruggieri | |2.| 19.9 9:00-11:00 | C1 | Exercises. Rules of inference for propositional logic. | [**T**: 1.6] | [[http://apa.di.unipi.it/pds/video/20170919.flv|20170919.flv]] | Ruggieri | |3.| 20.9 16:00-18:00 | M-Lab | Algorithms and programming: notions, programming steps, states, expressions and assignment. Introduction to Python. Data types, expressions using numbers, variables. | [**P**: 1-4] | [[http://apa.di.unipi.it/pds/video/20170920.mp4|20170920.mp4]] | Prencipe | |4.| 21.9 11:00-13:00 | M-Lab | Exercises and programming practice. | [**P**: 1-4] | [[http://apa.di.unipi.it/pds/esercizi/Esercizi1.pdf|Esercizi1.pdf]] | Prencipe | |5.| 25.9 11:00-13:00 | C1 | Predicate logic. | [**T**: 1.4-1.6] | [[http://apa.di.unipi.it/pds/video/20170925.flv|20170925.flv]] | Ruggieri | |6.| 26.9 9:00-11:00 | C1 | Simple functions, input, if-else, if-elif-else, while, for. | [**P**: 4-7] | [[http://apa.di.unipi.it/pds/video/20170926.mp4|20170926.mp4]] | Prencipe | |7.| 27.9 16:00-18:00 | M-Lab | Sets. Sets in Python. | [**T**: 2.1-2.2] | [[http://apa.di.unipi.it/pds/video/20170927.flv|20170927.flv]] | Ruggieri | |8.| 28.9 11:00-13:00 | M-Lab | Iterations and their use. | [**P**: 7] | [[http://apa.di.unipi.it/pds/esercizi/Esercizi2.pdf|Esercizi2.pdf]] | Prencipe | |9.| 2.10 11:00-13:00 | C1 | Exercises on predicate logic and sets. | | [[http://apa.di.unipi.it/pds/video/20171002.flv|20171002.flv]] | Ruggieri | |10.| 3.10 9:00-11:00 | C1 | Functions, sequences, cardinality, matrices. | [**T**: 2.3-2.6] | [[http://apa.di.unipi.it/pds/video/20171003.flv|20171003.flv]] | Ruggieri | |11.| 4.10 16:00-18:00 | M-Lab | Functions and recursion. | [**P**: 8-9] | [[http://apa.di.unipi.it/pds/video/20171005.mp4|20171005.mp4]] | Prencipe | |12.| 5.10 11:00-13:00 | M-Lab | Functions and recursion. | [**P**: 8-9] | [[http://apa.di.unipi.it/pds/esercizi/Esercizi3.pdf|Esercizi3.pdf]] | Prencipe | |13.| 9.10 11:00-13:00 | C1 | Exercises. Divisibility. | [**T**: 4.1] | [[http://apa.di.unipi.it/pds/video/20171009.flv|20171009.flv]] | Ruggieri | |14.| 10.10 9:00-11:00 | C1 | Primes. Integer representation. | [**T**: 4.2, 4.3, 4.5] | [[http://apa.di.unipi.it/pds/video/20171010.flv|20171010.flv]] | Ruggieri | |15.| 11.10 16:00-18:00 | M-Lab | Strings, tuples, lists, dictionaries, sets. | [**P**: 10-14] | [[http://apa.di.unipi.it/pds/video/20171011.mp4|20171011.mp4]] | Prencipe | |16.| 12.10 11:00-13:00 | M-Lab | Exercises on strings, tuples, lists, dictionaries and sets. | [**P**: 10-14] | [[http://apa.di.unipi.it/pds/esercizi/Esercizi4.pdf|Esercizi4.pdf]] | Prencipe | |17.| 16.10 11:00-13:00 | C1 | Exercises on divisibility and integer representation. Induction. | [**T**: 5.1] | [[http://apa.di.unipi.it/pds/video/20171016.flv|20171016.flv]] | Ruggieri | |18.| 17.10 9:00-11:00 | C1 | Strong induction. Recursive definitions. Structural induction. | [**T**: 5.2-5.4] | [[http://apa.di.unipi.it/pds/video/20171017.flv|20171017.flv]] | Ruggieri | |19.| 18.10 16:00-18:00 | M-Lab | Selection sort and Mergesort, text and binary files, exceptions, bitwise operators. | [**P**: 15-19] | [[http://apa.di.unipi.it/pds/video/20171018.mp4|20171018.mp4]] | Prencipe | |20.| 19.10 11:00-13:00 | M-Lab | Debugging. Exercises on sorting, files, exceptions. | [**P**: 15-19] | [[http://apa.di.unipi.it/pds/esercizi/Debug.pdf|Debug.pdf]][[http://apa.di.unipi.it/pds/esercizi/Esercizi5.pdf|Esercizi5.pdf]] | Prencipe | |21.| 23.10 11:00-13:00 | C1 | Exercises on induction and recursive programming. Basic of counting. The Pigeonhole Principle. | [**T**: 6.1-6.2] | [[http://apa.di.unipi.it/pds/video/20171023.flv|20171023.flv]] | Ruggieri | |22.| 24.10 9:00-11:00 | C1 | Permutations and combinations. Binomial coefficient. Exercises on recursive programming. | [**T**: 6.3-6.4] | [[http://apa.di.unipi.it/pds/video/20171024.flv|20171024.flv]] | Ruggieri | |23.| 25.10 16:00-18:00 | M-Lab | Fake exam (in preparation of Mid-Term exam). | [**P**: 1-19] | [[http://apa.di.unipi.it/pds/esercizi/FakeMidTermExam.pdf|FakeMidTermExam.pdf]] | Prencipe | |24.| 26.10 11:00-13:00 | M-Lab | In preparation of Mid-Term exam. | [**P**: 1-19] | [[http://apa.di.unipi.it/pds/esercizi/FakeMidTermExam.py.zip|FakeMidTermExam.py.zip]] | Prencipe | |25.| 6.11 11:00-13:00 | C1 | Exercises on counting. Relations. | [**T**: 9.1] | [[http://apa.di.unipi.it/pds/video/20171106.flv|20171106.flv]] | Ruggieri | |26.| 7.11 9:00-11:00 | C1 | Relations, posets. | [**T**: 9.3, 9.4, 9.6] | [[http://apa.di.unipi.it/pds/video/20171107.flv|20171107.flv]] | Ruggieri | |27.| 8.11 16:00-18:00 | M-Lab | Classes, Object and Overloading. | [**P**: 20-21] | [[http://apa.di.unipi.it/pds/video/20171108.mp4|20171108.mp4]] | Prencipe | |28.| 9.11 11:00-13:00 | M-Lab | Exercises on classes, objects and overloading. | [**P**: 20-21] | [[http://apa.di.unipi.it/pds/esercizi/Esercizi6.pdf|Esercizi6.pdf]] | Prencipe | |--.| 13.11 11:00-13:00 | C1 | Lesson not held. | | | | |29.| 14.11 9:00-11:00 | C1 | Architectures and hardware design. | [**A**: 1] | [[http://apa.di.unipi.it/pds/video/20171113.pdf|20171113.pdf]][[http://apa.di.unipi.it/pds/video/20171114.mp4|20171114.mp4]] | Prencipe | |30.| 15.11 16:00-18:00 | M-Lab | Exercise: relational operators in Python. | | [[http://apa.di.unipi.it/pds/esercizi/ExRelationalOps.pdf|ExRelationalOps.pdf]] | Ruggieri | |31.| 16.11 11:00-13:00 | M-Lab | Exercise: relational operators in Python. | | [[http://apa.di.unipi.it/pds/esercizi/ExRelationalOps.py.zip|ExRelationalOps.py.zip]] | Ruggieri | |32.| 20.11 11:00-13:00 | C1 | Exercises on relations and posets. Inclusion-exclusion. | [**T**: 8.5,8.6] | [[http://apa.di.unipi.it/pds/video/20171120.flv|20171120.flv]] | Ruggieri | |33.| 21.11 9:00-11:00 | C1 | Equivalence relations. Discussion of relational operators in Python. | [**T**: 9.5] | [[http://apa.di.unipi.it/pds/video/20171121.flv|20171121.flv]] | Ruggieri | |34.| 22.11 16:00-18:00 | M-Lab | Inheritance, iterators and generators, command line processing. The Unix Shell. | [**P**: 22-24] | [[http://apa.di.unipi.it/pds/video/20171122.mp4|20171122.mp4]][[http://apa.di.unipi.it/pds/video/Lezione8_IntroUnix.pdf|IntroUnix.pdf]] | Prencipe | |35.| 23.11 11:00-13:00 | M-Lab | Introduction to C: pre-processor, compiler, linker. Structure of a C-program. Exercises on Inheritance and Unix Shell. | [**C**: 1-5] | [[http://apa.di.unipi.it/pds/esercizi/Esercizi7.pdf|Esercizi7.pdf]][[http://apa.di.unipi.it/pds/esercizi/Esercizi8_Shell.pdf|Esercizi8_Shell.pdf]][[http://apa.di.unipi.it/pds/video/20171123.mp4|20171123.mp4]] | Prencipe | |36.| 27.11 11:00-13:00 | C1 | Grammars. | [**T**: 13.1] | [[http://apa.di.unipi.it/pds/video/20171127.flv|20171127.flv]] | Ruggieri | |37.| 28.11 9:00-11:00 | C1 | Finite-state automata (only deterministic), regular expressions. | [**T**: 13.3,13.4] | [[http://apa.di.unipi.it/pds/video/20171128.flv|20171128.flv]] | Ruggieri | |38.| 29.11 16:00-18:00 | M-Lab | Introduction to C: types, if-for-while, arrays, functions, scope. | [**C**: 1-5] | [[http://apa.di.unipi.it/pds/video/20171129.mp4|20171129.mp4]] | Prencipe | |39.| 30.11 11:00-13:00 | M-Lab | Introduction to C: pointers and memory. Exercises on Python and C. | [**C**: 1-5] | [[http://apa.di.unipi.it/pds/video/20171130.mp4|20171130.mp4]][[http://apa.di.unipi.it/pds/esercizi/Esercizi9_introC.zip|Esercizi9_introC.zip]] | Prencipe | |40.| 4.12 11:00-13:00 | C1 | Regular expressions in Python. Syntax and semantics of C expressions. | [**P**: 25] | [[http://apa.di.unipi.it/pds/esercizi/rexpr.py.zip|rexpr.py.zip]],[[http://apa.di.unipi.it/pds/esercizi/parser12.py.zip|parser12.py.zip]],[[http://apa.di.unipi.it/pds/video/20171204.flv|20171204.flv]] | Ruggieri | |41.| 5.12 9:00-11:00 | C1 | A Python interpreter of C expressions. Type checking. | | [[http://apa.di.unipi.it/pds/esercizi/Expressions.pdf|Expressions.pdf]],[[http://apa.di.unipi.it/pds/esercizi/parser3.py.zip|parser3.py.zip]], [[http://apa.di.unipi.it/pds/esercizi/interpreter123.py.zip|interpreter123.py.zip]],[[http://apa.di.unipi.it/pds/video/20171205.flv|20171205.flv]] | Ruggieri | |42.| 6.12 16:00-18:00 | M-Lab | Introduction to C: struct, libraries, strings | [**C**: 1-5] | [[http://apa.di.unipi.it/pds/video/20171206.mp4|20171206.mp4]][[http://apa.di.unipi.it/pds/esercizi/Esercizi10_introC.zip|Esercizi10_introC.zip]] | Prencipe | |43.| 7.12 11:00-13:00 | M-Lab | Concepts of Operating Systems I. Exercises on Python and C. | [**C**: 1-5] | [[http://apa.di.unipi.it/pds/esercizi/Lezione9_IntroduzioneOS.pdf|Lezione9_IntroduzioneOS.pdf]][[http://apa.di.unipi.it/pds/esercizi/Lezione10_FileSystem.pdf|Lezione10_FileSystem.pdf]][[http://apa.di.unipi.it/pds/video/20171207.mp4|20171207.mp4]] | Prencipe | |--.| 11.12 11:00-13:00 | | Lesson not held due to adverse weather conditions. | | |44.| 12.12 9:00-11:00 | C1 | A Python interpreter of C commands. | | [[http://apa.di.unipi.it/pds/esercizi/parser4.py.zip|parser4.py.zip]],[[http://apa.di.unipi.it/pds/esercizi/Commands.pdf|Commands.pdf]],[[http://apa.di.unipi.it/pds/video/20171212.flv|20171212.flv]] | Ruggieri | |45.| 13.12 16:00-18:00 | M-Lab | Concept of Operating Systems II. | | [[http://apa.di.unipi.it/pds/video/Lezione11_Periferiche.pdf|Lezione11_Periferiche.pdf]][[http://apa.di.unipi.it/pds/video/20171213_1.mp4|20171213_1.mp4]] | Prencipe | |46.| 14.12 11:00-13:00 | M-Lab | Exercises. | | [[http://apa.di.unipi.it/pds/esercizi/Esercizi12.pdf|Esercizi12.pdf]][[http://apa.di.unipi.it/pds/video/20171213_2.mp4|20171213_2.mp4]] | Prencipe | |47.| 15.12 9:00-11:00 | M-Lab | A Python interpreter of C commands. Wrap-up on programming languages. | | [[http://apa.di.unipi.it/pds/esercizi/interpreter4.py.zip|interpreter4.py.zip]],[[http://apa.di.unipi.it/pds/video/20171215.flv|20171215.flv]] | Ruggieri |