National University of Singapore · FACULTY OF COMPUTER SCIENCE

CS1010E Programming Methodology

- one subject, every graph, every model, every mark
6 Chapters29-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
The Complete Exam Bible · Sem 1 AY26/27

CS1010E Overview

Programming Methodology
— Read the program the way Python runs it: one expression, one statement, one state change at a time.
  • National University of Singapore
  • Semester 1, AY2026/27
  • Level 1
  • Python at the command line
  • Closed-book Midterm and exams

What this course teaches

The course materials present CS1010E as the leading introductory course in computing, and it teaches problem solving by computing through the Python programming language.

  • Exams carry most of the grade The Final Exam is 40%, and the Midterm and Practical Exam are 20% each.
  • Every assessment is closed book The Midterm, Practical Exam and Final Exam all forbid notes, so tracing must be automatic.
  • Trace before you type Write each variable's value after every statement; most lost marks come from a state you assumed rather than traced.
  • Assignments count best five Six assignments share 10%, and only the best five of the six count.
CS1010E · National University of Singapore
An independent, AskSia-authored study guide. AskSia is not affiliated with, endorsed by, or sponsored by National University of Singapore; the course code and name are used for identification only.
Assessment

How CS1010E is assessed

ComponentWeightFormat
Assignments (6)10%Best 5 of 6 count.
Tutorial Attendance4%Part of the tutorial strand; tutorials start in Week 3.
ET Exercises5%Tutorial strand; the course notes a graded practical exercise completed during tutorial sessions.
Mock Midterm1%Part of the tutorial strand.
Midterm20%Closed book. Saturday 3 October, 5.00pm to 6.30pm. Topics up to and including Lecture 5.
Practical Exam20%Closed book, in the programming labs. Saturday 24 October, multiple sessions within 12nn to 6pm. Topics up to and including Lecture 8.
Final Exam40%Closed book. Thursday 26 November, 5pm to 7pm.

The published weights total 100%: 10% for assignments, 10% across the three tutorial components, 20% for the Midterm, 20% for the Practical Exam and 40% for the Final Exam. The course states that all three timed assessments are closed book. The assessment table gives no coverage line for the Final Exam, and the course pages reviewed here state no hurdle, minimum mark or pass condition for any component, so none is claimed in either direction; confirm the current position on Canvas. Times are marked tentative in the table and the lesson plan is subject to change over the semester.

40%Final Exam20%Midterm20%Practical Exam10%Assignments10%Tutorialclosed-book assessments together: 80%continuous work: 20%
Current dates · verify in LMS

Current CS1010E dates

DateItemControl
3 October 2026MidtermSaturday, 5.00pm to 6.30pm. Topics up to and including Lecture 5.
24 October 2026Practical ExamSaturday, multiple sessions within 12nn to 6pm in the programming labs. Topics up to and including Lecture 8.
26 November 2026Final ExamThursday, 5pm to 7pm.

Dates are as published in the assessment table and lesson plan published for this offering. Confirm exact deadlines and submission settings in the live LMS.

Contents · every chapter, one map

What CS1010E covers

Six chapters follow the first six lectures in order, from turning a problem into an algorithm, through expressions, sequences, statements and recursion, to objects whose state can change under a second name.

01

Problem Solving with Programming

Turn a specification into an algorithm, then into a tested Python program run from the command line

Where programming actually begins

Programming in CS1010E is framed as problem solving first and typing second.

  • Definition of an algorithm as input to output
  • Exactness, effectiveness, generality and termination
  • Declarative style with map, filter and reduce
  • Imperative style with variables and loops
  • Abstraction through small helper functions
  • Edit, run, compare and debug cycle
02

Numerical Expressions and Functions

Operators, precedence, int and float values, and defining functions that compute and return results

What an expression is in CS1010E

Every program in this course is built from expressions, and an expression is simply a piece of Python that produces a value of one definite type. The early types are int, float and bool.

  • The int, float and bool values and the type function
  • Arithmetic operators including /, //, % and **
  • Operator precedence and associativity with expression trees
  • Defining functions with def, parameters and return
  • Function abstraction and local scope
  • Finite series written as recurrence relations
03

Sequences and Iterables

Strings, tuples, lists and ranges: indexing, slicing, iteration and the operations sequences share

From single values to collections

The first weeks of CS1010E work with singleton values such as integers, floats and booleans. This chapter introduces values that contain other values.

  • Tuples as immutable ordered sequences
  • Forward and backward indexing
  • Slicing with start, stop and step
  • Joining and repeating sequences with + and *
  • Strings, ASCII order and lexicographic comparison
  • Ranges and lazy iterables
04

Manipulating Program State with Statements

Assignment, conditional statements and loops, traced one state change at a time

From describing values to describing steps

This chapter of CS1010E moves from the declarative style, where a solution is an expression whose value Python evaluates, to the imperative style, where a solution is a list of instructions that alter variables.

  • Program state and the imperative style
  • Assignment and compound assignment statements
  • Reading input with input and writing output with print
  • Function definitions, return statements and None
  • Selection with if, elif and else, including nesting
  • Count-controlled for loops and condition-controlled while loops
05

Recursion

Base cases, recursive cases and call traces for functions that solve a problem through smaller copies of itself

What recursion means in Python

Recursion solves a problem by expressing it through a smaller instance of the same problem.

  • Recursive problems defined by smaller problems of the same kind
  • Base case and recursive case in a Python function
  • Translating factorial and Fibonacci recurrences into code
  • Winding and unwinding phases of a recursive call
  • Function activation stack and call frames
  • Recursive call trees and repeated subproblems
06

Objects and Mutable Sequences

Object identity, aliasing and in-place list changes, and when a name is rebound instead

Names refer to objects

This chapter changes how you read an assignment statement. In Python every value, from the integer 1 to a long list, is an object created in memory, and a variable is only a name that refers to such an object.

  • Every value in Python is an object
  • Identity with is versus equality with ==
  • Immutable types: int, float, bool, str, tuple
  • Lists as mutable sequences: index and slice assignment
  • Aliasing and side effects between shared names
  • Pass by object reference into functions

The learning outcomes are practical: analyse the specification of a problem and design an algorithm for it, implement that algorithm with real software tools, trace and test a program until you can show it is correct, and write it in a clean, modular style.

Programs are written from the command line with IPython and a terminal editor rather than inside an integrated development environment, which means you will read error messages and run code yourself from the first week.

How the first six lectures build

Lecture 1 frames programming as turning input into output through an algorithm.

Lecture 2 introduces values, types, operators and the functions that package a calculation. Lecture 3 moves from single values to sequences: strings, tuples, lists and ranges, and the indexing and slicing they share. Lecture 4 is about state, the assignment, conditional and loop statements that change what a name refers to.

Lecture 5 solves a problem by calling a smaller version of the same function, and Lecture 6 shows what happens when two names refer to the same mutable list. The Midterm covers topics up to and including Lecture 5, so the first five chapters of this guide are the Midterm syllabus.

How the grade is built

The Final Exam carries 40% and the Midterm and the Practical Exam carry 20% each.

Six assignments together carry 10%, counting the best five. The tutorial strand carries the remaining 10%: 4% for attendance, 5% for the exercises completed in class and 1% for a mock midterm.

All three timed assessments are closed book, and the Practical Exam is taken at a lab machine, so writing working code under time pressure is itself a skill to rehearse.

What this edition covers

This guide follows Lectures 1 to 6 with the matching tutorials and the first three assignments.

The later lectures in the lesson plan, on list processing, dictionaries, multi-dimensional arrays, searching and sorting, object-oriented programming and algorithm performance, are not yet covered here; use the lesson plan on Canvas to plan revision for them.

Worked example · free

Splitting a duration with integer division and remainder

Q [5 marks]. A timer reports 7384 seconds. Write one Python expression for each of the hours, minutes and seconds it represents, and give the value of each. The step weighting shown here is an AskSia study allocation and is not a University marking scheme.
Figure 6.3.Figure 6.3. During the call, both frames hold a reference to the same heap object. Every indexed write through xs lands in the list that daily still names. stack heap running_total frame xs shell frame daily [3, 8, 10, 16] one list, two names
Figure 6.3. During the call, both frames hold a reference to the same heap object. Every indexed write through xs lands in the list that daily still names.
  • 1Take whole hours with integer division by 3600.
  • 1Keep the leftover seconds with the remainder operator.
  • 2Split the leftover into minutes and seconds the same way.
  • 1Check the parts add back to the total.
Hours are 7384 // 3600, which is 2, because 3600 fits into 7384 twice. The seconds left over are 7384 % 3600, which is 184. Minutes are 184 // 60, which is 3, and the final seconds are 184 % 60, which is 4. Both operators bind as tightly as multiplication and work left to right, so (7384 % 3600) // 60 can also be written 7384 % 3600 // 60 and still gives 3. The check is 2 * 3600 + 3 * 60 + 4, which is 7200 + 180 + 4 = 7384, the original total, so the answer is 2 hours, 3 minutes and 4 seconds.
Sia tip — Use // for the whole part and % for the leftover, then add the parts back to the original total before you move on.
Glossary

Key terms

Algorithm
A finite sequence of well-defined steps that takes input and produces the required output.
Expression
A combination of values, names and operators that Python evaluates to a single value.
Operator Precedence
The rule deciding which operator is applied first when an expression contains several.
Integer Division
The // operator, which divides and keeps only the whole-number part of the quotient.
Slice
A new sequence taken from positions start up to, but not including, end.
Iterable
Any object a for loop can step through one element at a time, such as a string, list or range.
Program State
The values every name refers to at a given moment, changed by each assignment.
Base Case
The input a recursive function answers directly, without calling itself again.
Mutable Object
An object, such as a list, whose contents can be changed in place after it is created.
Aliasing
Two or more names referring to the same object, so a change made through one is seen through all.
FAQ

CS1010E FAQ

How is the course graded and what does each part carry?

The Final Exam carries 40%, the Midterm 20% and the Practical Exam 20%. Six assignments share 10% with the best five counting, and the tutorial strand adds 4% for attendance, 5% for in-class exercises and 1% for a mock midterm, which brings the total to 100%.

Can I bring notes into the Midterm or the Practical Exam?

No. The course states that the Midterm, the Practical Exam and the Final Exam are all closed book. Revise by writing code and traces from memory, since every timed assessment depends on recall and on fluency at the keyboard rather than on looking things up.

Which topics does the Midterm cover and when is it?

The assessment table sets the Midterm on topics up to and including Lecture 5, which are the first five chapters of this guide: problem solving, expressions and functions, sequences, statements and recursion. It is listed for Saturday 3 October from 5.00pm to 6.30pm, carries 20% and is closed book.

Why does a slice stop one position before the end index?

A slice s[a:b] takes positions a, a + 1 and so on up to b minus one. The length of the result is b minus a, which is why s[0:3] holds three characters and why two slices that share a boundary, s[:k] and s[k:], join back into the whole sequence.

How should I trace a loop on paper?

Make one column per variable and one row per pass, and write values only after the statement that changes them has run. Stop when the loop condition becomes false and read the answer from the last row; never predict a final value without the rows.

How do I know a recursive function will stop?

Check two things. A base case must return without calling the function again, and every recursive call must receive an argument that moves strictly closer to that base case. If either fails, Python keeps adding calls until it raises a recursion error.

Why did changing one list also change another list?

Assigning one name to another does not copy a list; both names then refer to one object. An in-place change such as append through either name is visible through both. Make a real copy with slicing or list() when the two must be independent.

Chapter questions

Questions students ask in each CS1010E chapter

Is an algorithm the same thing as a program?
No. An algorithm is the designed procedure, and a program is its translation into a language a machine can execute. One algorithm can be written as several different Python programs, declarative or imperative, and each translation still has to be tested separately. Chapter 01 · Problem Solving with Programming
Why does 0.1 + 0.2 == 0.3 return False in Python?
Floats are stored in binary, and 0.1 and 0.2 have no exact binary form, so their sum is stored as 0.30000000000000004. Compare floats by checking that the absolute difference is below a small tolerance such as 1e-9 or 1e-15. Chapter 02 · Numerical Expressions and Functions
Why does (5) not create a tuple in Python?
Round brackets on their own only group an expression, so (5) evaluates to the integer 5 and (5) * 2 gives 10. The comma is what makes a tuple: (5,) * 2 gives (5, 5). For an empty tuple, tuple() reads more clearly than a bare pair of brackets. Chapter 03 · Sequences and Iterables
Why does Python give a TypeError when I add a number to what input returned?
Whatever the user types arrives as a string, even if it looks like 12. Adding 3 to the string raises a TypeError, and adding the string '3' joins text to make '123'. Wrap the call as int(input(...)) or float(input(...)) to get 15 instead. Chapter 04 · Manipulating Program State with Statements
What happens if a recursive function has no reachable base case?
Python keeps opening new frames until it hits its recursion depth limit, then stops the program with a RecursionError. The usual causes are a missing base case, an argument that does not shrink, or an argument that jumps over the value the base case tests for, such as decreasing by 2 while checking only for 0. Chapter 05 · Recursion
Why does changing one list change another list in Python?
Both variables almost certainly refer to the same list object, usually because of an assignment like b = a or because the list was passed into a function. An indexed or slice assignment edits that single object, so every name pointing at it shows the change. Check with the is operator. Chapter 06 · Objects and Mutable Sequences
Study strategy

How to study for the exam

Type every example from a lecture into IPython before the next lecture and predict its output on paper first. Where your prediction and Python disagree, write a one-line note on why. Those notes, kept per chapter, become the closed-book revision list for the Midterm and the Final Exam.

Study CS1010E with AI

Your AI Computer Science tutor for CS1010E

Stuck on a hard CS1010E question? Sia is AskSia’s AI Computer Science tutor — ask any CS1010E Programming Methodology question and get a clear, step-by-step explanation grounded in how the course is actually taught and assessed. Read this whole study guide free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 21 of your National University of Singapore subjects - and 1,000+ Bibles across every Australian university.
Sia - your CS1010E tutor, unlimited, worked the way the exam marks it
The full 29-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works