NPRG030 Programming 1 (winter 2020-21)

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

For at least the month of October, all lectures and tutorials will take place on Zoom.

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 26, 2021 at 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 6. A first working version of your project is due by Sunday, January 31, and a final version by Sunday, February 7.

  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.

October 1 (lecture video) (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. Elif. Boolean operators.
October 8 (lecture video) (notes) (exercises)
Comments. Operator precedence. Loops: while, for. Ranges. Break. Nested loops. Math functions. A number-guessing game. Standard input.
October 15 (lecture video) (notes) (exercises)
Debugging. Multiple assignment. The continue statement. Else clauses with while and for. ASCII and Unicode. chr() and ord(). String indexing and slicing. Functions vs. methods. String methods.
October 22 (lecture video) (notes) (exercises)
Numeric literals. String formatting. None. Lists. List indexing and slicing. Mutating lists. More list operations. Structural and reference equality. Splitting and joining strings. Function definitions. Passing by value and reference. Local and global variables.
October 29 (lecture video) (notes) (exercises)
Conditional expressions. Tuples. Lists of lists. List comprehensions. Recursion.
November 5 (lecture video) (notes) (exercises)
Sets. Dictionaries. Objects and classes. Writing initializers. Writing methods.
November 12 (review session video)
No lecture (Dean's Sports Day)
November 19 (lecture video) (notes) (exercises)
Default argument values. Keyword arguments. Variable numbers of arguments. __repr__ and other "magic" methods. File input/output. The 'with' statement. Command-line arguments.
November 26 (lecture video) (notes) (exercises)
Inheritance. Class objects. Testing an object's type. Raising and catching exceptions. Iterating with zip(). Iterables and sequences.
December 3 (lecture video) (notes) (exercises)
Functions as values. Higher-order functions. Lambda expressions. Nested functions. Functions as return values. __eq__ and __hash__.
December 10 (lecture video) (notes) (exercises)
File path operations. Directories. Modules and packages. Installing packages. Drawing graphics. Event-driven programs. Keyboard and mouse input.
December 17 (lecture video) (notes) (exercises)
Solving combinatorial problems with recursion. Top-down and bottom-up solutions.
December 24, 31
No lecture (winter vacation)
January 7, 2021 (lecture video) (notes) (exercises)
More combinatorial problems. Software engineering. Writing good code.