Articles tagged with #computer-science

Intro to CS: Problem Set 2

I was able to complete this problem set in just under an hour. It was good practice. Will show my code then the result of running the unit tests. My solution: import random import string # ----------------------------------- # HELPER CODE # ----------------------------------- WORDLIST_FILENAME = "words.txt" VOWELS = 'aeiou' def load_words(): """ returns: list, a list of valid …



Systematic Program Design: Week 7b - Local

In this module we look at a new technique for improving the structure of code. Most of the problems in this module involve refactoring existing programs -- so there's relatively little new coding to do. But that doesn't mean you won't be designing programs! One of the things that separates good …



Systematic Program Design: Week 7a - Two One-of Types

Module Overview Two One-Of Types In this module we will learn to design functions consuming two arguments that have one-of types. In order to do this, we will develop a new model of our code, the cross product of the types comment table. The cross product of the types comment …



Math for CS: Induction

Induction is a powerful method for showing a property is true for all non-negative integers. Induction plays a central role in discrete mathematics and computer science. In fact, its use is a defining characteristic of discrete—as opposed to continuous—mathematics. This chapter introduces two versions of induction, Ordinary and …



Intro to CS: Lecture 10 - Lists, Mutability

Topics: List Operations, Mutability: mutation, aliasing, tricky examples with loops over L Lists are mutable. Strings are not. We covered the append function on lists. Convert string to list using list(s), and convert list to string using join. This is all review for me. Functions with side effects can …



Math for CS: Binary Relations

We start by going over Functions. Its definition, what domains, codomains and images are, examples, and function composition. I was surprised to see some of the creative ways we can define a function. For example let f(y) be the length of a left to right search of the bits …



Intro to CS: Lecture 9 - Lambda functions, Tuples, and Lists

Topics: Tuples and lists Lambda creates a procedure/function object, but does not bind a name to it. I’ve come across lambda functions throughout my experience so I am familiar with them. Another name for them is anonymous functions. Going over tuples, and variable number of arguments. Came across …



Intro to CS: Lecture 8 - Functions as Objects

Topics: Functions: environments, scope, functions as objects This is also review for me. Another thing I noticed about this course is that a lot of math examples are used. Math and CS/Programming go hand in hand so I’m not surprised by this. Also, this is MIT, so students …



Intro to CS: Lecture 7 - Decomposition, Abstraction, Functions

Topics: Functions: decomposition, abstraction, specifications Big idea: Apply abstraction (black box) and decomposition (split into self-contained parts) to programming. Already know about functions, decomposition, and abstraction, so this lecture is review to me. The instructor is now teaching how to come up with code for say a quiz. They say …



Intro to CS: Lecture 6 - Bisection search

Topics: Simple Algorithms: bisection search, Newton-Raphson This is basically binary search. Straightforward algorithm and review for me. I learned something new. Or something I probably learned before but forgot about. The square root of a number between 0 and 1 is going to be greater than itself. Compared different algorithms …