11: Objects and Classes

Introduction Objects can be one of the most difficult programming concepts to understand. Once it clicks, however, it really clicks. I recommend you read and pay close attention to the textbook, and utilize your resources until you understand objects and classes, as your upcoming evaluation will rely heavily on your understanding of these concepts. Before you begin, please read the Python documentation 9.2. Python Scopes and Namespaces. This stuff messes a lot of people »

10: The While Loop

Introduction This will be a short tutorial, as while loops are pretty easy. You MUST understand conditionals to continue. While loops rely on an expression to operate. As long as the expression is True, the loop will run. When the expression stops being True (ie. it is False), so does the loop. WHILE loop structure The basic structure of a while loop is as follows: while (expression): # Do something This will execute the code inside »

08: Functions

Introduction We’ve used Python for an array of applications so far. You should by now be familiar with loops, lists, strings, mathematical operations, and how they all work together. We’ve also used a lot of Python’s built in functions to help us get the job done! Here’s a few examples: import math myRange = range(0, 10) mySqr = math.sqrt(2) newList = myList.append(newElement) It’s clear to see how these »

Midterm Preparation

Hey everyone, sorry this is late. I did intend for this to be available closer to the midterm date, but here it goes! Things to Remember 1. Read the Question! No matter how many times I remind students to read the whole problem before answering (see: every lab so far), many people attempt to solve the problem before reading the whole question. You can’t answer a question you don’t understand. Take a breath, »

07: Strings

A lot of students struggle with the String type. Your understanding of this type is extremely important, and failure to understand will seriously impact your performance in labs. Therefore, I’ve decided to dedicate a post entirely to the use and manipulation of Strings. What is a String? In programming, a letter, symbol, space, new line, or tab is usually referenced by a numerical value (encoded by ASCII or Unicode). This is called a character, »