NPRG030 Programming 1 (winter 2021-2)

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 13, 2022 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 5. A first working version of your project is due by Sunday, January 23 and a final version by Sunday, January 30.

  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.

To access any of the videos below, use our Zoom meeting ID and passcode (not your CAS login) as the username/password.

September 29 (Wed tutorial video) (notes)
Operating systems. Running programs from the command line. Files and directories. Filenames. Standard input and output. Redirecting input and output. Using an IDE. Visual Studio Code. Running a trivial Python program. ReCodEx.
October 4 (lecture video) (Wed tutorial video) (notes) (exercises)
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. Loops: while, for. Ranges. Break. Comments.
October 11 (lecture video) (Wed tutorial video) (notes) (exercises)
Operator precedence. Type conversions. Math functions. Random numbers. ASCII and Unicode. chr() and ord(). Reading lines of standard input. Nested loops. The continue statement. String indexing and slicing. Functions vs. methods. String methods.
October 18 (lecture video) (Wed tutorial video) (Thurs tutorial video) (notes) (exercises)
String formatting. Lists. List indexing and slicing. Mutating lists. More list operations. Structural and reference equality. Splitting and joining strings.
October 25 (lecture video) (notes) (exercises)
None. Tuples. Lists of lists. Function definitions. Passing by value and reference. Local and global variables. 'else' clauses with 'while' and 'for'.
November 1 (lecture video) (Wed tutorial video) (Thurs tutorial video) (notes) (exercises)
Conditional expressions. Pattern matching in assignments. List comprehensions. Recursion.
November 8 (lecture video) (Wed tutorial video) (Thurs tutorial video) (notes) (exercises)
Default parameter values. Keyword arguments. Variable numbers of arguments. Sets. Dictionaries. Set comprehensions. Iterables and sequences.
November 15 (lecture video) (Thurs tutorial video) (notes) (exercises)
Assertions. Command-line arguments. File input/output. The 'with' statement. Objects and classes. Writing initializers with __init__. Writing methods. __repr__.
November 22 (lecture video) (Wed tutorial video) (Thurs tutorial video) (notes) (exercises)
Magic methods for operator overloading. Class objects. Testing an object's type. Class attributes. Inheritance. Iterating with zip().
November 29 (lecture video) (Wed tutorial video) (Thurs tutorial video) (notes) (exercises)
Functions as values. Lambda expressions. Drawing graphics. Event-driven programs. Keyboard and mouse input.
December 6 (lecture video) (Wed tutorial video) (Thurs tutorial video) (notes) (exercises)
Raising and catching exceptions. Nested functions. Functions as return values. Model-view architecture. Timers and animation in Tkinter.
December 13 (lecture video) (Wed tutorial video) (Thurs tutorial video) (notes) (exercises)
Modules and packages. Installing packages. Debugging. Using a debugger. File path operations. Directories. Menus. Writing good code.
December 20 (lecture video) (Wed tutorial video) (notes) (exercises)
Software testing. Unit, regression and integration tests. Solving combinatorial problems with recursion. Top-down and bottom-up solutions.
December 27
No lecture (winter vacation)
January 3 (lecture video) (Thurs tutorial video) (notes) (exercises)
Generators. Making classes iterable. Generator comprehensions. More combinatorial problems.
January 28 (video)
Review session for Progamming 1 and Introduction to Algorithms.