NPRG030 Programming 1 (winter 2022-3)

Instructors:

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 12, 2023 at the end of the exam period:

  1. Complete a number of programming exercises through the semester. The tutorial teachers 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 test score when you take the test.

  2. Pass a written test 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 your tutorial teacher a 1-2 paragraph project proposal by Sunday, December 4. A first working version of your project is due by Sunday, January 22 and a final version by Sunday, January 29.

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

Textbooks

Resources

Syllabus

This is a rough map of the ground we plan to cover in this class. (It will probably evolve as the semester goes on.)

October 3 (notes) (exercises)
Introduction. Operating systems. The command line. Using an IDE. Running Python programs. Built-in types: integers, booleans, floats, strings. Numeric operators. Boolean operators. Variables. Assignment operators. The 'input' and 'print' functions. Conditional statements: if and else. Elif. Comments. Loops: while, for. Ranges.
October 10 (notes) (exercises)
Break and continue. ASCII and Unicode. chr() and ord(). Type conversions. Math functions. Random numbers. String formatting. Reading lines of standard input. Redirecting input and output.
October 17 (notes) (exercises)
String indexing and slicing. Functions vs. methods. String methods. Lists. List indexing and slicing. Mutating lists. More list operations. Structural and reference equality.
October 24 (notes) (exercises)
Splitting and joining strings. Tuples. None. Function definitions. Passing by value and reference. Local and global variables.
October 31 (notes) (exercises)
Conditional expressions. 'else' clauses with 'while' and 'for'. Lists of lists. Recursion. Turtle graphics.
November 7 (notes) (exercises)
Default parameter values. Keyword arguments. Variable numbers of arguments. Objects and classes. Writing initializers with __init__. Writing methods. __repr__. Assertions.
November 14 (notes) (exercises)
Class objects. Testing an object's type. Sets. Dictionaries. Iterables and sequences. Magic methods for operator overloading.
November 21 (notes) (exercises)
List comprehensions. Set and dictionary comprehensions. Command-line arguments. File input/output. Debugging. Using a debugger.
November 28 (notes) (exercises)
Iterating with enumerate() and zip(). Functions as values. map and filter. Lambda expressions. Nested functions. Functions as return values.
December 5 (notes) (exercises)
Class attributes. Inheritance. Raising and catching exceptions. The 'with' statement. Magic methods for equality.
December 12 (notes) (exercises)
Graphics. User interfaces with Tkinter. Widgets. Grid-based layout. Event handling. Labels, buttons, text boxes. The Canvas widget. Fonts. Colors.
December 19 (notes) (exercises)
Model-view architecture. Modules and packages. Installing packages. Audio in Python.
December 26
No lecture (winter vacation)
January 2 (notes) (exercises)
Writing good code. Software testing. Unit, regression and integration tests.