COMP 1001: Introduction to Programming

Lecture 1 Workbook

Course Introduction, Computers and Software

Pranjal Patra
Department of Computer Science, Memorial University of Newfoundland

Memorial University of Newfoundland

Today's agenda

This first lecture has three parts:

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.

This workbook has no questions and awards no XP. It is the reference copy of the course introduction: keep it handy for dates, contacts and policies. The one code example on the page is live; press ▶ Run to execute it in your browser.


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.

PrerequisitesNone.
Credit restrictionCredit-restricted with the former COMP 1710.
TextbookRecommended, 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 elseSlides, workbooks, lab material and announcements are on Brightspace.
What is examinable

The lectures and labs define what is examinable. The textbook supports the course; it does not replace attending.

People and contact

RoleWhoOfficeEmail
InstructorPranjal PatraEN-2008pranjal.patra@mun.ca
Lab instructorCindy MilleyEN-1064cindy@mun.ca
Lab instructorStephen AnthonyEN-1062stephen@mun.ca
Lab instructorFrankie TuEN-1063frankiet@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.

How to get a quick reply

Lectures and labs

LecturesMonday, Wednesday and Friday, 10:00 to 10:50 a.m., EN-2043.
LabsTuesday. 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.
TermSeptember 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.

UnitLecturesTopics
11–3Problem solving, algorithms, pseudocode, a first program
24–7Variables, types, arithmetic, input and output, strings
38–11Decisions: if, comparisons, nested branches, Boolean logic
412–16Loops: while, for, nested loops, loop algorithms
517–20Functions: parameters, return values, scope, stepwise refinement
621–23Recursion
724–28Lists, searching and sorting
829–33Exceptions and files
934–36Sets 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

ComponentWeightDetails
Lab quizzes30% (best 6 of 8, 5% each)Written during the assigned lab period; you must be present to write it.
Term Test 120%Thursday, October 15, in the assigned lab slot. Lectures 1–12.
Term Test 220%Tuesday, November 10, in the assigned lab slot. Lectures 1–23, weighted toward the later material.
Final examination30%Registrar-scheduled, December 10–18. Lectures 1–36, weighted toward Units 4–8.
Attendance bonus+1 markFor attending Labs 1–8 and both term tests. The course grade is still capped at 100%.
Total100%

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.

SituationWhat 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 CertificateEmail 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 certificateScored 0.

Student Health Certificate form (PDF)

Term tests and the final

Missing a term test

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

DateWhat
Wed. Sept. 9First lecture
Wed. Sept. 30National Day for Truth and Reconciliation; no class
Mon. Oct. 12Thanksgiving and midterm break; no class
Thu. Oct. 15Term Test 1, in your lab slot
Wed. Nov. 4Last day to drop without academic prejudice
Tue. Nov. 10Term Test 2, in your lab slot
Wed. Nov. 11Remembrance Day; no class
Mon. Dec. 7Last lecture
Dec. 10–18Final examination period
Two calendar oddities

Policies and Help

The rules that apply to your work in this course, and where to go when you are stuck.

Course policies

PolicyWhat it means for you
Academic integrityAll 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 toolsUsing 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 repostingAll 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 behindThere 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 courseThe 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.

The full course outline on Brightspace lists the remaining university regulations: grading scheme, scheduling, deferred final examinations, accommodations and student supports.

Where to get help

Study advice

How to do well in this course

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

Sandsilicon dioxide→ Purified silicon ingot→ Sliced into wafers→ Patterns etched→ Chipbillions of switches

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

Transistorone switch→ Logic gateAND, OR, NOT→ Addergates that add bits→ Processorbillions of gates

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.

Input CPU Control unit Arithmetic unit Output Memory fetch store

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 key idea

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.

Applications Libraries Compilers and interpreters Operating system Architecture, instruction set Digital logic Physics and silicon your work system software the hardware closer to the person

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.

LayerWhere you study it
Transistors and siliconElectrical engineering, physics
Digital logicDigital logic and circuits
ArchitectureComputer organisation
Operating systemOperating systems, concurrency
Compilers and interpretersCompilers, programming languages, theory of computation
Libraries and algorithmsData structures, algorithms, databases, networks
ApplicationsSoftware 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.

Your Python program A browser A game Operating system Windows, macOS, Linux, Android, iOS Hardware

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;
}
C sourceadd.c→ Compiler→ Assembly→ Assembler and linker→ Machine codein a file→ CPU runs it

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.

Python sourceadd_five.py→ Bytecode→ Python virtual machine→ CPU runs the VM

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.

Low-level and high-level languages

Closer to the machine
  • Fast and small
  • Full control of the hardware
  • Slow to write and easy to get wrong
  • Tied to one kind of processor
Closer to the person
  • 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

You A program The machine a result you can actually use

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:

Whatever field you end up in, someone there is writing programs.

What you will be able to do

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.

  1. Understand the problem: what is given, what is wanted, and what the rules are.
  2. Decompose it into smaller parts.
  3. Recognise patterns: parts you have solved before, or that look like each other.
  4. Design and evaluate a method, and test it on normal and awkward cases.
  5. Implement the method.
  6. Reflect on what worked and what to do differently next time.
Only one step needs a computer

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

Welcome to COMP 1001.