NE111: Introduction to Programming for Engineers

1 Preamble

Figure 1.1: If you don’t already know Python, today is your lucky day!

1.1 Learning Outcomes for the Course

Here is the official course description:

NE 111: Introduction to Programming for Engineers (LEC,TST 0.25)

Introduction to programming and numerical computing using a high-level interpreted programming language. Programming fundamentals, computer architecture, design and use of functions, strings and text input/output, relational operators, conditionals, lists, loops, designing algorithms, numerical computing, plotting, and file input/output.

Let’s translate these buzz words into plain English:

  • Introduction to programming\(\rightarrow\) We will assume you have zero knowledge of programming
  • numerical computing\(\rightarrow\) We will use computers as super powerful calculators
  • using a high-level interpreted programming language\(\rightarrow\) We will use Python because it’s way easier than C/C++
  • Programming fundamentals\(\rightarrow\) We will cover Python but the building blocks are common to all computer languages
  • computer architecture\(\rightarrow\) We need an appreciation of this so we can get the most from the computer in terms of speed
  • design and use of functions\(\rightarrow\) We will use functions to hide complicated logic
  • strings and text input/output\(\rightarrow\) We sometimes need to read and write text to and from the computer
  • relational operators\(\rightarrow\) We often need to decide if something is less than, greater than, equal to, something else
  • conditionals\(\rightarrow\) We can tell the computer to do A if B is True, otherwise do C
  • lists\(\rightarrow\) We can store multiple pieces of data in a sequence for later use
  • loops\(\rightarrow\) We can scan through our lists of data to do calculations
  • designing algorithms\(\rightarrow\) We will develop logical steps to obtain a numerical answer
  • numerical computing\(\rightarrow\) We will use some special tools to make this happen
  • plotting\(\rightarrow\) We will plot our results for easy visualization
  • file input/output\(\rightarrow\) We will save our results to a file for later use

Given the above list, we can formulate a set of learning outcomes for the overall course:

Learning Outcomes for the Course

Upon completion of this course you should:

  • …know the syntax and features of Python quite well
  • …appreciate the role of the underlying computer hardware on the performance of a computer program
  • …use functions to create “code” that is concise, organized and readable
  • …control the order of execution of a program using relational operators and conditional statements
  • …store and retrieve data from Python’s various data containers such as lists
  • …use for-loops to scan data stored in various containers and perform calculations as needed
  • …develop multistep numerical calculations to compute results, such as scientific calculations
  • …use state-of-the-art libraries to extend Python’s capabilities to scientific calculations
  • …visualize data using a variety of graph styles
  • …read and write data from memory

1.2 Learning Approach

1.2.1 Learn by Doing, then Redoing

“To begin, begin”

- William Wordsworth

This course is designed to deliver the material “iteratively”. This means that we will cover the topics several times:

  • The first time we see a concept, we will skip over many of the details. Instead we will focus on the rough outlines with just enough detail to do something useful.
  • On subsequent passes over a concept we will fill in the gaps by focusing on more features and gaining an understanding for what is actually happening and why.
  • This also means that the first way I show you how to do a task might not be the best way.

1.2.2 Outline

The course is broken up into 2 sections: “Before Midterm” (BMT) and “After Midterm” (AMT). Midterms occur in Week 7 (Oct 14-18) but Week 6 is a reading week. This means that we have 5 weeks of BMT, and 6 weeks of AMT.

Week Description
Week 1 Introduction to Python: Installing Python; learning syntax; mathematical expressions; variable assignment; using, importing, and writing functions.
Week 2 Data Types and Collections: Understand data types; working with collections; iterating through collections.
Week 3 Logic and Flow Control: Introduction to Boolean logic; use of relational operators; applying logic to collections; controlling execution.
Week 4 Working with Text: Deep dive into strings; converting and formatting strings; performing operations on strings.
Week 5 Files and IO: Introduction to the file system; reading and writing files; installing external libraries; introduction to version control.
Week 6 Reading Week
Week 7 Midterm Week
Week 8 Writing Pythonic Code Crafting advanced functions; documenting functions; dealing with error conditions; using collections fully; mastering comprehensions; mastering for-loops.
Week 8b Creating Data Dashboards: Using Streamlit to create graphical user interfaces. (During the make-up lecture on Nov 1)
Week 9 Numerical Computing with Numpy Part 1: Overview of computer architecture; compiled vs interpreted languages; introduction to the Numpy library; overview of related libraries.
Week 10 Numerical Computing with Numpy Part 2: Multidimensional arrays; fancy indexing; applications in linear algebra.
Week 11 Data Management and Visualization: Reading and writing numerical data; introduction to Pandas; plotting with matplotlib and other available libraries; working with images.
Week 12 Introduction to Object Oriented Programming: An introduction to OOP principles; classes; inheritance; data encapsulation.

1.2.3 The Forgetting Curve

The Forgetting Curve shown in Figure 1.2 is one of my favorite mental models of learning. The point is that we don’t learn something by looking at it once. We need to revisit the material periodically before it become a permanent part of our personal knowledge base.

In the context of this course, this means two things:

  1. You should not expect yourself to remember every single detail of Python after the first introduction. So don’t be mad at yourself for forgetting bits and pieces. It’s normal to look-up how certain things work and it’s why good documentation is hugely important.
  2. The notes have been written like a manual that can be read later (i.e. 1st review, 2nd review, etc). You should come back to these notes on your own time and re-read them. The downside of this approach is that lectures will include us reading over the notes together which may seem a bit tedious.
Figure 1.2: The Forgetting Curve and the Remembering Curve. (Protip: You want to be on the Remembering Curve!)