Submitted questions on readings (CS 121B (CS1), Spring 2014)
>>    




Submitted questions on readings

CS 121B (CS1), Spring 2014

Submitted questions on reading 14 (20140409)

  • A docstring is a standard way to describe a function or class in Python3. It is a comment appears first in the definition, and is enclosed in tripled quotes (which allows it to extend beyond one line) instead of starting with #. Example:

        class Account:
    	"""Represents a bank account with basic balance information"""
    	# state variables: 
    	...
    

  • A constructor for a class defines how to initialize state variables for a new object in that class.

  • Objects are like packages containing data + functions on those data

  • Classes and objects are like "real life" because (1) we can create custom classes whose objects model the important properties of entities in real life, and (2) object-oriented programming is the basis of building large software systems we all use.

Submitted questions on reading wmr 2 (20140331)

  • Basic idea of map-reduce computing:

    1. Break data up into labelled pieces (mapper())

    2. Gather and combine pieces that have the same label (reducer())

  • Ways map-reduce (e.g., WMR/Hadoop) computing is different:

    • Map-reduce computational pattern (see above)

    • Framework computing: The mapper and reducer functions are only partial programs, which fit into a larger computation (inserted through the WMR New Job page).

    • Scalability: Map-reduce frameworks remain feasible for computation for data up to quadrillions of bytes, given a large enough cluster.

  • Uses of Hadoop and similar computations in the real world: big-data web services, e.g., analysis of text, finding relationships (e.g., in social media), reformatting and generating data (e.g., convert New York Times online to PDF), map services, ...

Submitted questions on reading wmr 1 (20140321)

  • (a) Conceptually, key-value pairs can be thought of as labelled pieces of information.

    (b) In implementation, each line of data for a WMR/Hadoop data set produces one key-value pair, strings that are separated by the first TAB character in that line.

  • Clusters (multiple networked computers for working together on a computation) are not the only type of parallel computing (multiple computer actions occurring at the same time).

    In particular, all present-day computers (and many cell phones) use multicore CPUs, which means there are multiple circuits for carrying out computer instructions. A multicore CPU can physically run more than one program at the same time.

  • Hadoop moves output data from mappers across a cluster's network to become input data for reducers, in an intermediate step called the shuffle stage.

    While shuffling, Hadoop orders the data according to key (but not necessarily according to value). This causes the output from reducers to be computed according to the ordering of the intermediate keys.

Submitted questions on reading 12 (20140314)

______

Submitted questions on reading 11 (20140310a)

______

Submitted questions on reading 10 (20140310)

  • Mutable (can assign to) vs immutable (may not be changed). int, strings, lists, tuples

  • State changes (or side effects): effects that a function may have other than return value. Examples: input; output; assignment/mutation

    "Pure" function: no state changes

  • Lists vs. strings in memory

  • Starting indices at 0, because of internal representation of integers in bits

        00000000  (0)
        00000001  (1)
        00000010  (2)
        00000011  (3)
        00000100  (4)
        ...
    

Submitted questions on reading 9 (20140303)

  • Specs for range()

    range   (builtin)

    One argument:
    A non-negative integer
    Return:
    An iterator that generates integers 0, 1, ..., arg1-1
    Example call:
        range(5)
    
    This returns an iterator that is comparable to the list [0, 1, 2, 3, 4]

    range   (builtin)

    2 or 3 arguments:
    Integers
    Return:
    An iterator; with two arguments, the iterator generates integers
         arg1, arg1+1, ..., arg2-1
    and with three arguments, the iterator generates integers
         arg1, arg1+arg3, arg1+2xarg3, ...
    that ends just before a step arg1+Nxarg3 reaches or passes arg2.
    Example calls:
        range(2, 5)
    
    This returns an iterator that is comparable to the list [2, 3, 4]
        range(2, 10, 3)
    
    This returns an iterator that is comparable to the list [2, 5, 8]
        range(2, 1)
    
    This returns an iterator that is comparable to the empty list [], because the starting point 2 is already greater than the ending point 1
        range(10, 2, -2)
    
    This returns an iterator that is comparable to the list [10, 8, 6, 4]
        range(2, 10, -2)
    
    This returns an iterator that is comparable to the empty list [], because the step size arg3 is negative, and the starting point 2 is already less than the ending point 10.

Submitted questions on reading 13 (20140226)

______

Submitted questions on reading 8 (20140224)

______

Submitted questions on reading 7 (20140219)

______

Submitted questions on reading 6 (20140217)

______

Submitted questions on reading 3,4,5 (20140214)

  • Flow of control means the order in which a CPU carries out (Python3) instructions. The default (usual) flow of control in Python3 is sequential, i.e., step-by-step in order. Python3 statements such as if and for can be used to specify different flows of control.

    Examples:

        print("Hi", "Joe", "Please come to my party on Saturday!")
        print("Hi", "Amy", "Please come to my party on Saturday!")
        print("Hi", "Brad", "Please come to my party on Saturday!")
        print("Hi", "Angelina", "Please come to my party on Saturday!")
        print("Hi", "Zuki", "Please come to my party on Saturday!")
    

        x = int(input("Enter an integer: ))
        if (x < 0):
    	print("negative")
        else:
    	print("non-negative")
    

        for name in ["Joe", "Amy", "Brad", "Angelina", "Zuki", "Thandi", "Paris"]:
    	print("Hi", name, "Please come to my party on Saturday!")
    
  • Googling for technical information; sys.float_info

Submitted questions on reading 1,2 (20140212)

  • Book exercises: Sometimes assigned for homework; use solutions however it will help you to learn best.

  • Carrying out instructions (execution)

  • Architecture (structural design) of a computer

  • The first computer programs

    • Originally, physically connecting wires...
    • Then, machine language, numerical codes for specifying what circuits should do, entered by physical switches
    • Then, assembly language, "more readable" code that could be translated by a program (assembler) to those numerical codes of machine language
    • First program to process a high-level language by Grace Murray Hopper, 1950s
    • First widely used high-level language: FORTRAN (formula translation), 1957
    • Python 1991 (version 3 in 2008)
  • An added question:

    The question is rather broad, but something that has been bothering me for a while. The readings never seemed to explain the steps before all of the processes discussed. As in, how does a computer know what to do with two numbers? How are they given any sort of meaning or value? And then how do they place a value on addition or multiplication? I guess I just don't get how a computer is programmed to do such things because they seem to be such abstracted concepts to me.

  • Another added question:

    I was confused about parsing a formal language such as Python3. If you aren't supposed to read it top to bottom, left to right, how are you supposed to interpret the structure in a way that you understand it? Isn't reading it that way one way you can identify the tokens and interpret the structure? How else would you do read the code?