CompSciWeek1

From Predictive Chemistry
Revision as of 16:27, 5 September 2014 by David M. Rogers (talk | contribs) (Homework I)

Jump to: navigation, search

Required reading for this week is Beginning Python, chapters 1-4. Be sure to try out the examples in python, not just read.

Class 1

  1. Pretest
  2. Basic Shell Usage
    • pwd, ls, directory structure
  3. Access to Resources
    • Logging into the lab computers
      • Explanation of dual boot, OS evolution
    • opening terminals, and terminals through terminals
    • Logging into circe.rc.usf.edu
    • Moving files
    • Running python on your own machine
      • Windows: Python Idle + easy_install ()
      • alt: Cygwin
      • OSX / Linux: Package managers (OSX: fink, Debian (deb): apt-get, RH (RPM): yum)
  4. First-order data types:
    • int(1.1), float(-3), string(4) [essentially all languages]
    • (and 2nd order) tuple([5]), list((6,)), dict([(6,7)]) [python-specific]

Class 2

  1. What is a Turing machine?
  2. The infinite loop and other control structures.
  3. First algorithms (Horner, Euclid, Babylonian)
  4. Code walk-through for a poorly designed Euclids algo.
  5. The KISS, DRY, and incremental principles
  6. Higher-order constructs:
    • functions
    • functional code

Homework I

This assignment will be due in 2 weeks, on Monday, Sept. 8.

  1. Create a program that reads in strings with raw_input() until a string containing a single '.' is sent. After that, the program should print out the strings it has read in reverse order (hint: use list.pop()).
  2. Implement the Babylonian/Heros method to approximate the square root of 2 using 10 iterations. Plot the error in the approximation against iteration number. Is there a good way to automatically guess when to stop iterating?
    • Edit 9/5/14 A printed list of the error at each iteration can be included in place of a plot.
  3. Imagine Bassetts Ice Cream has a data set of daily ice cream sales for 3 different flavors stretching back to 1893. Write pseudocode for an algorithm that finds the largest and smallest sales over daily, weekly, monthly, and yearly time-scales. Use steps like `add together 7 days sales` and `get the smallest number in the list`. If each test or addition step for each number takes 0.1 microseconds (10^-7 seconds), estimate how many microfortnights (1 microfortnight = 1.2096 s) the code will take to run?
    • Edit 9/5/14 One final result should be output for each timescale. For the monthly timescale, for example, the result would be the (flavor, month number) pair with the highest and lowest numbers. -- Congrats to Christine McNiff for forcing a formal specification of the result. Ambiguities like this are a common source of conflict in programming vs. specifications...
  4. Obfuscation challenge: Write (in the most complicated unreadable way you can stand) a code that prints out the first 20 or so prime numbers. The code is limited to 100 lines, cannot use external packages, and must always finish running in less than 1 minute.