Lecture 1 Workbook
Today's agenda
This first lecture has three parts:
- Course overview: what the course is, who teaches it, how it is marked, and where to get help.
- The big picture: what a computer is, from silicon to software, and where programming languages fit.
- Problem solving: the framework that Lecture 2 works through in detail, and what to do before next class.
No prior programming experience is assumed. If you have programmed before, you are welcome; the discussion stays at a beginner's level so that everyone starts together.
The Course
What the course is, who teaches it, when and where it meets, and what it covers.
Course description
COMP 1001 is an introduction to problem solving and programming in Python. It is the first programming course for all Computer Science majors and minors, and it is required for entry into both programs. The course introduces fundamental programming techniques, data types and data structures. Problem-solving techniques are learned and applied through the design and implementation of simple algorithms.
| Prerequisites | None. |
| Credit restriction | Credit-restricted with the former COMP 1710. |
| Textbook | Recommended, not required: C. Horstmann and R. Necaise, Python for Everyone, 3rd edition, Wiley, 2020. ISBN 978-1-119-73995-1. An e-book version is also available. |
| Everything else | Slides, workbooks, lab material and announcements are on Brightspace. |
The lectures and labs define what is examinable. The textbook supports the course; it does not replace attending.
People and contact
| Role | Who | Office | |
|---|---|---|---|
| Instructor | Pranjal Patra | EN-2008 | pranjal.patra@mun.ca |
| Lab instructor | Cindy Milley | EN-1064 | cindy@mun.ca |
| Lab instructor | Stephen Anthony | EN-1062 | stephen@mun.ca |
| Lab instructor | Frankie Tu | EN-1063 | frankiet@mun.ca |
Office hours: Fridays, 12:00 to 2:00 p.m., by appointment only. Book a slot at the Google Calendar link (also on Brightspace); please take the next available slot if possible.
- Use email, not Brightspace messages.
- Put
COMP1001in the subject line. - Check Brightspace first; the answer may already be posted.
- Replies are usually sent within 24 hours.
Lectures and labs
| Lectures | Monday, Wednesday and Friday, 10:00 to 10:50 a.m., EN-2043. |
| Labs | Tuesday. One section meets 9:00 to 11:50 a.m.; the other meets 2:00 to 4:50 p.m. Labs use CS-1019, with CS-1009 as overflow. |
| Term | September 9 to December 7, 2026. |
Attend the lab section in which you are registered. The lab quizzes are written in the lab and are worth 30% of the course, so the lab is not optional.
Course topics
The schedule is tentative; any change is announced in class and posted on Brightspace. Each block assumes the material before it, so keeping up matters.
| Unit | Lectures | Topics |
|---|---|---|
| 1 | 1–3 | Problem solving, algorithms, pseudocode, a first program |
| 2 | 4–7 | Variables, types, arithmetic, input and output, strings |
| 3 | 8–11 | Decisions: if, comparisons, nested branches, Boolean logic |
| 4 | 12–16 | Loops: while, for, nested loops, loop algorithms |
| 5 | 17–20 | Functions: parameters, return values, scope, stepwise refinement |
| 6 | 21–23 | Recursion |
| 7 | 24–28 | Lists, searching and sorting |
| 8 | 29–33 | Exceptions and files |
| 9 | 34–36 | Sets and dictionaries, a first look at objects, course review |
Marks and Dates
How the course grade is built, what happens when you miss a lab or a test, and the dates to put in your calendar now.
Evaluation
| Component | Weight | Details |
|---|---|---|
| Lab quizzes | 30% (best 6 of 8, 5% each) | Written during the assigned lab period; you must be present to write it. |
| Term Test 1 | 20% | Thursday, October 15, in the assigned lab slot. Lectures 1–12. |
| Term Test 2 | 20% | Tuesday, November 10, in the assigned lab slot. Lectures 1–23, weighted toward the later material. |
| Final examination | 30% | Registrar-scheduled, December 10–18. Lectures 1–36, weighted toward Units 4–8. |
| Attendance bonus | +1 mark | For attending Labs 1–8 and both term tests. The course grade is still capped at 100%. |
| Total | 100% |
Lab quizzes and both term tests are written in Brightspace using the Quiz tool, on the lab computers. Both sections write on the same date, at their own section times.
Labs and lab quizzes
There are eight lab quizzes and the best six count. That already allows for two missed labs, for any reason, without notice or documentation.
| Situation | What happens |
|---|---|
| Missed 1st or 2nd lab, any reason (including medical or family bereavement) | No notice or documentation needed. Already built into best 6 of 8. |
| Missed 3rd or later lab, with a Student Health Certificate | Email Cindy, Stephen or Frankie with the lab number and the certificate. That lab's weight moves to the final examination. |
| Missed 3rd or later lab, no certificate | Scored 0. |
Term tests and the final
- Term Test 1 covers Lectures 1–12.
- Term Test 2 covers Lectures 1–23, weighted toward the later material.
- The final covers Lectures 1–36, weighted toward the later units.
Email the instructor within 48 hours of the test's start time, with a Student Health Certificate. The weight of the missed test moves to the final examination. If the university is closed on the day of a term test, the test is written in the next scheduled lab period.
Important dates
| Date | What |
|---|---|
| Wed. Sept. 9 | First lecture |
| Wed. Sept. 30 | National Day for Truth and Reconciliation; no class |
| Mon. Oct. 12 | Thanksgiving and midterm break; no class |
| Thu. Oct. 15 | Term Test 1, in your lab slot |
| Wed. Nov. 4 | Last day to drop without academic prejudice |
| Tue. Nov. 10 | Term Test 2, in your lab slot |
| Wed. Nov. 11 | Remembrance Day; no class |
| Mon. Dec. 7 | Last lecture |
| Dec. 10–18 | Final examination period |
- Thursday, October 15 follows the Tuesday schedule. There is no COMP 1001 lecture that day, but Term Test 1 runs in each student's assigned Tuesday lab slot.
- Friday, November 13 follows the Wednesday schedule. COMP 1001 meets normally, and Lecture 26 runs that day.
Policies and Help
The rules that apply to your work in this course, and where to go when you are stuck.
Course policies
| Policy | What it means for you |
|---|---|
| Academic integrity | All submitted work must be original and independent. Copying, including from another student or an online source, and allowing your own work to be copied: 0% on the work concerned, and a failing grade for the course on a second instance. See Academic Misconduct, Section 6.12 of the University Calendar. |
| AI tools | Using an AI tool to help understand course material and concepts is encouraged, and can be a great help. Submitting AI-generated work as your own, on any graded lab, quiz, term test or exam, is not permitted and is treated as a violation of academic integrity. |
| Recording and reposting | All lecture materials, and any recording of them, are copyrighted by the instructor. Recording, copying or reposting course content, including on sites such as Chegg or to chatbots, is prohibited without written permission. |
| If we fall behind | There are no buffer lectures. If lecture time is lost to weather or another cause, the schedule is compressed from the end: Lecture 36 is removed first, then Lecture 35, and so on. |
| Dropping the course | The last day to drop without academic prejudice is Wednesday, November 4. No permission is needed before that date; drop through Memorial Self-Service. At least 20% of the final grade, from labs and Term Test 1, is returned before then. |
Where to get help
- Your lab instructor, during the lab. Lab instructors and instructional assistants are there to help.
- Office hours, Fridays 12:00 to 2:00 p.m. by appointment.
- CS Student Help Centre, EN-2026. It helps with first- and second-year Computer Science lab courses; its schedule is linked from Brightspace.
- Peer Assisted Learning (PAL), led by Arash Arasteh, aarasteh@mun.ca. A PAL leader visits the class on September 9 to introduce the program and to collect an availability survey; the session schedule is set from that survey and posted on Brightspace. See the Peer Assisted Learning page.
- Brightspace, for announcements, materials and posted answers to common questions.
Study advice
- Practise coding. Programming is learned by doing. Type the examples, change them, and see what happens.
- Attend lectures and labs. The material builds on itself week by week.
- Keep up with the early material. Every later unit assumes the ones before it.
- Ask early. A question in week 2 is cheap; the same question in week 10 is expensive.
- Expect errors. Every programmer's code fails at first. Lecture 3 covers how to read and fix errors.
Hardware
The big picture starts at the bottom: what a computer is physically, and how it represents everything as switches.
What a computer is
Strip away the screen, the keyboard and the case, and a computer is a very large arrangement of switches made of silicon. Each switch is either on or off. Everything the machine does, from adding two numbers to drawing this page, comes from turning enormous numbers of those switches on and off very quickly.
That is a long way from the problems you actually care about. The rest of this lecture is about the layers that close the gap between silicon and the person using the machine.
From sand to chips
Silicon is a semiconductor: it can be made to conduct or not, depending on a tiny control signal. Sand is purified into a single crystal, sliced into thin wafers, and patterned with layers of material so fine that a modern chip carries tens of billions of switches in a piece smaller than a fingernail.
Transistors, gates and processors
A single switch is a transistor. A few transistors wired together make a logic gate that computes AND, OR or NOT of its inputs. Gates combine into circuits that add, compare and store values, and those circuits combine into a processor. At no point does anything new appear: it is switches all the way down.
Binary representation
A switch has two states, so the machine stores everything as patterns of 0s and 1s (bits). The pattern means nothing by itself; people agree on a convention for reading it.
the number 5 00000101
the letter 'A' 01000001 (that is 65, by agreement)
one red pixel 11111111 00000000 00000000
The same eight bits can be a small number, a letter, or part of a colour. What makes 01000001 mean 'A' is an agreed convention, not anything inside the chip. Keep that in mind: it is why a program has to tell Python whether a value is a number or text.
The von Neumann architecture
Almost every computer you will meet follows a design described by John von Neumann in 1945.
The CPU repeats one loop endlessly: fetch the next instruction from memory, decode what it asks for, execute it, and move on. The control unit runs the loop; the arithmetic unit does the calculating.
The program lives in the same memory as the data it works on. A program is just another pattern of bits, so the same machine can run a spreadsheet, a game, or the Python program you write next week. Nothing needs to be rewired.
The Layers
A computer system is built as a stack of layers. Knowing the stack tells you where Python, and this course, sit.
Layers of a computer system
Between the physics of silicon and the application on your screen sit several layers. Each one hides the details of the layer below it and offers something simpler to the layer above.
This course lives in the top two layers: you will write applications, and you will use libraries (Python's modules) that other people wrote. The layers below are what make that possible.
Layers and courses
Each layer is a field of study in its own right. Later courses in the degree pick them up one by one.
| Layer | Where you study it |
|---|---|
| Transistors and silicon | Electrical engineering, physics |
| Digital logic | Digital logic and circuits |
| Architecture | Computer organisation |
| Operating system | Operating systems, concurrency |
| Compilers and interpreters | Compilers, programming languages, theory of computation |
| Libraries and algorithms | Data structures, algorithms, databases, networks |
| Applications | Software engineering, human–computer interaction, graphics, artificial intelligence |
The operating system
The operating system is the layer every program talks to. It shares the processor and memory among running programs, manages files, and talks to the keyboard, screen and network so that each program does not have to.
Whether you run Windows, macOS or Linux in the lab, Python sits on top of the operating system in exactly the same way. That is one reason a Python program written on one machine runs unchanged on another.
Languages
A processor understands only bits. Programming languages exist to let people write for the machine without thinking in bits.
Machine code
The processor understands only one language: patterns of bits called machine code. Here are three real instructions for a common processor, written in hexadecimal to save space, with what each one means.
48 83 C0 05 add 5 to a register
48 01 D8 add one register to another
C3 return
In binary the first instruction is 01001000 10000011 11000000 00000101. People wrote programs like this in the 1940s. It is exact, and it is unreadable.
Assembly
Assembly language gives each instruction a short name and lets you label positions in the program. An assembler translates it, one line to one instruction, into machine code.
add_five:
add rax, 5 ; 48 83 C0 05
add rax, rbx ; 48 01 D8
ret ; C3
Better, but you are still thinking in terms of the processor's registers rather than your problem.
C and compilation
A language such as C lets you describe the calculation itself. A compiler translates the whole program into machine code once, ahead of time, and the result is a file the CPU can run directly.
int add_five(int x) {
return x + 5;
}
The translation happens once. Running the program afterwards costs nothing extra, which is why compiled languages are used where speed matters most.
Python and interpretation
Python, the language of this course, takes a different route. Python code is translated into an intermediate form called bytecode, and a program called the Python virtual machine carries out that bytecode. The translation happens every time you run the program.
Translating on every run costs speed. What it buys is convenience: no separate compile step, the same code on every operating system, and the ability to try one line at a time and see what happens. For learning to solve problems, that is the right trade.
A short history
Each step in the history of programming languages hides a little more of the machine.
- 1945 Machine code
- 1949 Assembly
- 1957 Fortran, the first widely used high-level language
- 1959 COBOL
- 1972 C
- 1985 C++
- 1991 Python
- 1995 Java, JavaScript
- 2010s Go, Rust, Swift
Low-level and high-level languages
- Fast and small
- Full control of the hardware
- Slow to write and easy to get wrong
- Tied to one kind of processor
- Quick to write and to read
- Runs anywhere the interpreter runs
- Whole categories of mistake become impossible
- Slower to run
This course uses Python because its subject is problem solving, not the processor. Python lets you spend your attention on the problem.
Programming
Where a programmer fits in the picture, how big the field is, and what this course gives you.
Where programming fits
Programming is the point where a person's intention becomes something the machine can carry out. You describe what you want precisely enough that the layers below can do it, and what comes back is a result you can actually use.
The software industry
A few rounded, mid-2020s figures give a sense of scale:
- Worldwide spending on information technology is roughly $5 trillion a year, of which about $1 trillion is software.
- Several software companies are each worth more than a trillion dollars.
- There are tens of millions of professional software developers in the world.
Whatever field you end up in, someone there is writing programs.
What you will be able to do
- An entry point. This course is the first step into computer science and into programming in general.
- Portable skills. Problem solving, reading code and finding errors carry over to every other language.
- Useful immediately. By the end of term you can automate tedious tasks, process data and check your own calculations.
- A prerequisite. COMP 1001 is required for the Computer Science major and minor and for the courses that follow.
The course begins with problem solving before it begins with Python. A program is only ever as good as the thinking behind it.
Problem Solving
The rest of the course is about solving problems. Here is the framework, and what to do before Lecture 2.
The framework
Every problem in this course, and most problems outside it, can be approached with the same six activities.
- Understand the problem: what is given, what is wanted, and what the rules are.
- Decompose it into smaller parts.
- Recognise patterns: parts you have solved before, or that look like each other.
- Design and evaluate a method, and test it on normal and awkward cases.
- Implement the method.
- Reflect on what worked and what to do differently next time.
Step 5 is the only one where you type code. The other five happen on paper and in your head, and they are where most of the work is. Lecture 2 works through them with two examples before we write any Python.
Before next class
- Log in to Brightspace and find the COMP 1001 page.
- Confirm which lab section you are registered in (Tuesday morning or afternoon).
- Put October 15, November 4 and November 10 in your calendar.
- Fill in the PAL availability survey.
- Lecture 2 is problem solving on paper: no computer needed, but bring something to write with.
Welcome to COMP 1001.