Syllabus

What Is It?

This is a computer class. But it isn't a hardware class. It's a software class. We'll write programs. Hundreds. Our language is Python. (Do not fear. It's named for the British comedy troupe, not the snake.)

Here's a little program. It draws a star.

import euclid

from colors import *


euclid.createPage(tracer = 0)

logos = euclid.Pen(color = RED, delay = 12)

w, h = euclid.getScreenSize()

center = (w//2 - 100, h//2)


logos.up()

logos.goto(*center)  # goto expects two values; the star unpacks the center tuple

logos.down()

logos.beginRegion(YELLOW)  # make the fill color YELLOW

while True:

    logos.forward(200)

    logos.turn(170)

    if logos.distanceTo(*center) < 1:

        break

logos.endRegion()


euclid.finish()

euclid.wait()

Mystified? I promise that if you do what I ask, you'll be able to write code like this within a few months.

Grades

You'll have grades of four sorts: Programs/Functions, Quiz, Project, Final. Programs/Functions will count for 70% of your quarter grade. Quizzes will count for 15%. Projects will count for 15%. The Final is 20% of your semester grade. I expect that we'll have five or so quizzes each semester.

Structure

We'll do five chapters in semester one, and five in semester two. In each chapter, I'll teach you some new bit of Python. I'll also describe the functions I wish you to write. Pay close attention: I'll tell you the function name you must use, what parameters it should have and what output it should return. (More on all this later.)  If you do as I ask in the function descriptions, I can test your functions. I can call them with inputs of my choice and then tell you if their outputs are correct. This is called a unit test. Every set of functions descriptions is followed by a unit test, hand-crafted by Dr. M. Copy the unit test, paste it under your functions and run it. Once you do, you'll find a detailed report, and a final score, in a text file. I suggest that you grab the unit test before you begin to write your functions, and then run it whenever you get another function written.

You'll also be asked to do a number of projects. (Look for the link.) Here you'll have more freedom. I provide only a description of the tasks your code should carry out; I don't tell you how to break your code up into functions. Of course it will consist of functions. We're function writers. But what they will be and how they will be organized - that's for you to decide.

When an assignment is due, you'll fill out a Google form and there provide the link to your code. (We'll use replit.com, and there each project has its own unique URL.)

At the end of each chapter, you'll take a short quiz. They're already published. The quizzes will be paper and pencil.

The final will also be paper and pencil, and it too is already published (though I might supplement it a bit).

Materials

I’ve written a book. You're there right now.

I'll keep the schedule on Canvas, and I'll occasionally use Canvas to send an announcement to the class.

Code Submission

You'll write your code at replit.com. A wonderful feature of replit - indeed the best feature, I think - is that every replit project has its own URL. When time comes to submit, you'll that URL to me.

Plagiarism

Code is very easy to steal. A Python program is a text file, and so you can simply copy and paste any bit of code you want. Moreover, a simple Google search will lead you to mountains of code. But yet I say, "Do not steal code!" You will of course study code written by others. But all of your code must be written by you. Why? Only if you've written the code yourself will you know how it works; and only if you know how it works will you be able to write correct code of your own. I also say that you should not give code away. You might think you've done a friend a favor, but actually you've hurt them. They need to learn to write their own code.

How will I know that you've written the code you submit? No doubt in some cases I'll be unable to detect stolen code. But stolen code often has a certain odor to it. It's more sophisticated than the code that the typical student is able to write, or it solves a problem similar to but distinct from the problem given.

If I suspect you've stolen code or accepted code that isn't your own, I'll call you up and ask you to explain your code in plain English. If you can explain it, I'll assume that the code is yours. If you can't, I'll conclude that you've cheated. Please don't be offended if I call you up and ask you to explain your code. If my suspicions are unfounded, I'll apologize profusely.

AI

No doubt you're familiar with the apparent revolution in AI that began in 2022 with the public release of ChatGPT.

AI excels at some tasks. Code is one. I'm sure you'll feel a temptation to let AI write code for you. Resist the temptation. You're a beginner. You need to learn how to code, and if you let AI do your work for you, you won't learn. I do understand that the pros often use AI. My son says that it significantly speeds up his work. But you're not a pro. Not yet.

Moreover, you take a risk if you let AI write code for you. The AI is often right. But of course it's sometimes wrong, and if you haven't learned to write code yourself, you won't know when it's wrong. This is why it's (mostly) safe for the pros to use AI but not safe for you. The pros can check the output of the AI and verify that it's correct when it is, and fix it when it's not.  You're not at a point yet where you can do that.

A final point. If you let AI write your code for you, you'll rob yourself of the thrill you'll experience when you finally, after much time and frustration, solve that hard problem. Young coders who relies too much on AI impoverish themselves.

Phones and Passes

Keep them away unless you've asked permission.

We'll use SmartPass. In most cases, you'll create the pass.

Our IDE

We need a tool to write code, debug code (which means to fix the mistakes) and run code. Such a tool is called an "Integrated Development Environment" or "IDE" for short. We have Chromebooks, and no Chrome IDE exists for Python. Fortunately a few good in-browser IDE's exist. We'll use replit.com. You'll need to sign up if you haven't already. See the "Sign up" button top right. Use your school Google account.

Once you've created an account and signed in, you'll create a Python repl. (It's easy. Just follow the on-screen prompts.) You'll then find yourself in repl's Python IDE. On the left is all files for that repl, in the middle is the code editor and on the right is the Python console. I'll teach you about all that in the first few weeks.

Topics

Chapter 0: Introduction

The core concept of the class is the concept of a function. In Chapter 0, I explain why that is so.

Chapter 1:  Expressions, Names, Types, Bugs

Before we begin to write functions, we must know a little Python. We must in particular know to how to evaluate an expression, and how to assign a value to a variable and later retrieve that value.

Chapter 2: The Way of the Function

Now that we understand expression value and variable assignment, we can write out first functions. In this course we are always function writers, and  the solutions to our problems will be either one function or the composition of many.

Chapter 3: Iteration

Here we begin our study of the core logical tools provided by Python. In iteration (of the definite variety), we make a block of code execute a given number of times; and as we do, the value of a variable (or variables) evolves towards its final state.

Chapter 4: Selection

We can make a block of code to execute repeatedly; that's iteration. In selection, we choose which (if any) of a set of blocks of code will execute. This is the second of our logical tools.

Chapter 5: Strings and Files

In Chapter 5 we turn now from logic to data. The first of of the data types that we'll study in depth is the string. Files are simply strings stored externally.

Chapter 6: Lists and Tuples

Chapter 6 is the second of our data chapters. Python's most versatile data type is the list. Here we must grapple with the concept of mutation. Lists are mutable. Strings are not. 

Chapter 7: Dictionaries and Sets

The last of the data types that we'll study are dictionaries and sets. Both are intrinsically unordered. With lists, indices are integers; but with dictionaries, indices (called now "keys") are objects of our choice. So a dictionary consists of a set of unordered key/value pairs.

Chapter 8: Recursion

In Chapter 8 we turn back to logic. In recursion, we find that if done properly a function can call itself. How do we escape the infinite loop this seems to create? We hit the base case!

Chapter 9: Higher Order Functions

A higher-order function is a function that either takes a function as input, returns a function as output, or both. Functions are thus a kind of data/logic hybrid.

Chapter 10: Classes

With classes, we begin our study of the so-called "Object-Oriented Paradigm".  We will learn here how to create new data types, and to specify the rules that govern them. This will culminate in the fraction and complex number projects; for them, you'll teach Python two new numeric types!

Projects

We'll also do a number of projects in each of the two semesters. For these, you'll have to decide for yourself what functions to write. This is a core skill. You'll have to decide to break the task described in the project into a number of sub-tasks. You'll then wrap each of these up into a function, and you'll construct a master function that calls the others as needed.

Schedule for Semester Two

We'll do chapters 5 through 10. Each chapter will have a quiz and a project. So we should have a total of 15 grades for quarters 3 and 4. And then the final exam, for a total of 16.