CMSI 3801
Exam 1 Preparation

When

October 3-7, 2022.

Scope

Programming Languages as a Field of Study, JavaScript, Python.

Ground Rules

You will take the exam on BrightSpace; it will be multiple choice with a 90 minute time limit. You MAY use books, notes, and web searches to look things up. You will not be spied on: there is no browser lock down and hence no need to hide a mobile device in a bag of potato chips. However, you MAY NOT solicit answers in any way. There is to be no asking for help, no posting on forums, no communication with other humans or intelligent bots in any way; you can only “look things up.” You also MAY NOT post answers or help any other test taker either. You are bound by an honor code to follow these rules.

The exam becomes available at 6pm America/Los Angeles time on October 3 and becomes inaccessible at 10pm on October 7. You may complete the exam within any 90 minute period in that window.

Review of the Course Learning Objectives

Step one of your preparation is to remember the learning objectives from the syllabus. Please review them now.

To meet these objectives throughout the course you must gain an understanding of both big picture and low-level questions about programming language pragmatics. You should be able to answer, for particular languages (and for the exam, JavaScript and Python):

This is just a tiny number of the questions we can ask.

What We Have Learned So Far

We began the course with a look into how one studies programming languages, including how languages are classified and to what extent they support or do not support various programming paradigms.

Then we began our tour of programming language concepts with deep dives into JavaScript and Python. In addition to language history we uncovered and practiced many technical linguistic aspects. Here is a small subset of things we learned:

 JavaScriptPython
First Appeared19951991
DesignerBrendan EichGuido von Rossum
VersionsES2015 and later is “modern” JS; we use ES2022 in this class.Python 2 is no longer supported! We use Python 3.10.
Recognized ForFirst-class functions, prototypesWonderful expressiveness
Notable UsesWebapp clients, asynchronous serversWeb servers, scripting, data science
Six words or lessThe assembly language of the webEasy to learn and extremely productive
REPLnodepython
Runs command line scriptsYesYes
Can be hosted?Yes (in browser, usually)Not designed to be
Typing SystemsDynamic and WeakDynamic and Strong
Dynamic TypesTechnically only 8, cannot create more, but “faked” with constructorsDozens built-in, user can create infinite number of new types
Static TypingNot exactly, as TypeScript is considered a different languageYes, but type hints are ignored at run time
Distinguishes primitive and reference Types?YesNo, everything is an object (BEAUTIFUL)
Getting the type of an expressiontypeof (operator, funky) or .constructortype
Types are....just kind of there, they surface as strings with typeofreally objects!
What’s falsy?undefined, null, false, 0, NaN, empty stringNone, False, numeric 0, empty sequences, empty mappings, instances of classes where __nonzero__ or __len__ return 0 or False.
Objects vs. DictionariesKind of conflated, but there is a built-in MapVery different. Dictionaries have type dict, objects are instances of a class
Objects haveproperties, keyed by strings or symbols or numbersattributes
Object philosophyPrototypesClasses
Gettersget@property
Can properties / attributes be added to existing objects?YesYes
Syntax GroupingCurly bracesIndentation
Statement separator; but language uses weird algorithm to add them if you forget them; if multiple statements on same line, otherwise newline unless inside of delimiters or triple-quoted string literals.
Local variable declarationsDeclare with let or const (legacy var also supported)Just assign to a variable in function; it will be be local unless a nonlocal or global declaration for the identifier preceded it.
Parallel assignment?Through array pattern matchYes (no delimiters needed)
General destructuringYesOnly in match statement
Increment and decrement operators?YesNo!
Multiline stringsDelimited with backticksDelimited with triple quotes
Package Ecosystemnpmpip
Common unit testing frameworkmochapytest

Interested in more comparisons? Check out the the first two columns of this page. Woah, how useful was THAT?! (Very useful, but be careful because in some areas it might be out of date.)

What other similarities and differences can you think of?

Format of the Exam

An ideal assessment of your understanding of programming language concepts would examine (1) your ability to articulate these concepts as expressed in the design of JavaScript and Python, and (2) your ability to articulate the similarities and differences between JavaScript and Python in their implementation of these concepts, through an oral exam. However, given the the number of students, this assessment will be on your recognition and evaluation of concept expression in the form of multiple choice and similar questions.

At some point during the exam window, find the quiz on BrightSpace and take it. You will have 90 minutes to complete it. Upon submission you should receive feedback and your score will be recorded in the gradebook.

How to Study

Review your answers and my answers to the first two homework assignments.

Do the reinforcement problems relevant to the material within the scope of the exam.

Do the reinforcement problems

Keep in mind that our (world’s) knowledge culture is far more literary than oral, so read, or reread:

You have to put in the time for effortful self-study. Although the exam is open resources, you will not have time to look everything up. Those who come in with a strong comfort level with the material will finish on time. I am assessing your fluency and your proficiency with the material, not your Google-Fu.

Sample Problems

What does the following JavaScript function return when called (assuming url is actually a real url that actually returns real data)?

function mystery() {
    return fetch(url).then(r => "woohoo").catch(e => "aw snap")
}
  1. A string
  2. A promise
  3. Nothing, it throws an error
  4. undefined

What is the proper Python list comprehension that replaces the code fragment below?

a = []
for x in first_range:
    for y in second_range:
        if x >= y:
            a.append(y // x)
  1. [y // x for x in first_range for y in second_range if x >= y]
  2. [y // x if x >= y for x in first_range for y in second_range]
  3. [y // x for x in second_range for y in first_range if x >= y]
  4. [y // x for x in first_range if x >= y for y in second_range]