NPRG030 Programming 1 (winter 2019-20)

Instructor: Adam Dingle

This course is a fast-paced introduction to programming and basic data structures, with a strong emphasis on learning to write working code. It assumes no previous programming experience. The course uses the Python 3 programming language.

Throughout the course students will complete many programming exercises in Python, solving a wide variety of programming problems.

Lectures and other meetings

Requirements

This is a pass/fail course: you will not receive a numeric grade.

To pass this class, you must fulfill the following requirements by Friday, February 14, 2020 (the end of the exam period):

  1. Complete a number of programming exercises through the semester. I will assign these exercises weekly, and you can submit your solutions to the ReCodEx automated grading system. To pass, you will need to earn at least 70% of the total possible points. Any points that you earn over 85% (up to a maximum of 15%) will be applied as bonus points to your exam score when you take the exam.

  2. Pass a written exam at the end of the semester.

  1. Write a program in Python as a semester project. Your program should accomplish something that is interesting, cool, or fun and can be 100-300 lines long, or longer if you like. Here are some project ideas. Please send me a one-paragraph project proposal by Sunday, December 8th. A first working version of your project is due by Sunday, January 26th. A final version is due by Sunday, February 2nd.

  2. Regularly attend the lectures and tutorials and participate in class.

Extra help

Two teachers (Martin Koutecký and Vašek Končický) will lead mentoring sessions in computer science and math on Thursdays from 15:40 - 18:50 in room S510 on the fifth floor.

Feel free to stop by my office hours (Fridays from 13:00 - 14:30 in room 405).

Textbooks

Resources

Syllabus

This is a rough map of the ground we plan to cover in this class:

October 3 (notes) (exercises)
Course overview. Introduction to Python. Installing and running Python. Built-in types: integers, booleans, floats, strings. Numeric operators. Variables. Assignment operators. Type conversions. Programs. The 'input' and 'print' functions. Conditional statements: if and else. Boolean operators.
October 7 (notes) (exercises)
Comments. Operator precedence. Elif. Loops: while, for. Ranges. Break. Nested loops. Math functions. A number-guessing game. Standard input.
October 14 (notes) (exercises)
Multiple assignment. The continue statement. Else clauses with while and for. chr() and ord(). String quoting. Escape characters. String indexing and slicing. Lists. List indexing and slicing. Mutating lists. Debugging.
October 21 (notes) (exercises)
None. Structural and reference equality. Functions and methods. String methods. More list operations. Function definitions. Local and global variables.
October 28 (exercises)
No lecture (Czechoslovak Independence Day)
November 4 (notes) (exercises)
String formatting. The import statement. Passing by value and reference. Keyword arguments. Default argument values. Lists of lists. Tuples. Returning multiple values. Sets. Dictionaries.
November 11 (notes) (exercises)
Assertions. Conditional expressions. Objects and classes. Private attributes. Inheritance.
November 18 (notes) (exercises)
Class objects. Testing an object's type. Class attributes. Static methods. __eq__ and other "magic" methods. Duck typing. List, set, and dictionary comprehensions.
November 25 (notes) (exercises)
Variable numbers of arguments. Iterating with zip(). Generator comprehensions. File input/output. Directories. The 'with' statement. Using a debugger.
December 2 (notes) (exercises)
Programming style. Iterables and sequences. Raising and catching exceptions. First-class functions. Lambda expressions.
December 9 (notes) (exercises)
Modules and packages. Drawing graphics using pygame. Event-driven programs. Keyboard and mouse input.
December 16
No lecture (cancelled due to illness)
December 23, 30
No lecture (winter vacation)
January 6 (notes) (exercises)
Generator functions. Object-oriented design. Testing.