NPRG030 Programming 1 (winter 2024-5)

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 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, 2025 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 90% (up to a maximum of 10%) 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 8. A first working version of your project is due by Sunday, January 19 and a final version by Sunday, January 26.

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

You may not use ChatGPT, Copilot or other AI tools to generate any code that you submit in any homework assignment or semester project in this course. Any use of such tools is considered cheating and may disqualify you from passing the 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.)

September 30 (notes) (exercises)
Introduction. Operating systems. The command line. Built-in types: integers, booleans, floats, strings. Numeric operators. Comparison operators. Type conversions. Using an IDE. Variables. The input() and print() functions. Conditional statements: if and else. Elif. Comments. While loops. For loops. Ranges. The 'break' statement.
October 7 (notes) (exercises)
More about IDEs. Boolean operators. Chained comparisons. More about ranges. The 'continue' statement. Math functions. Random numbers. ASCII and Unicode. chr() and ord(). String functions/operators. String indexing and slicing.
October 14 (notes) (exercises)
Functions vs. methods. String methods. Reading lines from standard input. Redirecting input and output. Processing newline characters. String formatting. Lists. List indexing and slicing. List operations. Splitting and joining strings. Structural and reference equality. Nested lists.
October 21 (notes) (exercises)
Running time of list operations. Tuples. Multiple assignment. Lists of tuples. None. Function definitions. Local and global variables. Variable numbers of arguments. Default parameter values. Keyword arguments.
October 28
No lecture (Independent Czechoslovak State Day)
November 4 (notes) (exercises)
Conditional expressions. File input/output. The 'with' statement. Command-line arguments. Sets. Dictionaries. Recursion.
November 11 (notes) (exercises)
Debugging. Objects and classes. Writing initializers with __init__. Writing methods. __repr__.
November 18 (notes) (exercises)
More on 'import'. Installing packages. Magic methods for operator overloading. Iterables and sequences. List comprehensions. Set and dictionary comprehensions.
November 25
Functions as values. map and filter. Lambda expressions. Nested functions. The 'nonlocal' keyword. Iterating with enumerate() and zip(). Dictionaries with defaults.
December 2
Raising and catching exceptions. Inheritance. Class objects. Class attributes, class methods.
December 9
Magic methods for equality. Inheritance versus composition. Testing an object's type. The 'match' statement.
December 16
User interfaces with Tkinter. The Canvas widget. Event handling. Model-view architecture. Introduction to pygame.
December 23
No lecture (winter vacation)
December 30
No lecture (winter vacation)
January 6
Type checking. Type hints. Dataclasses. Comma-separated values. Writing good code. Software testing. Unit, regression and integration tests.