Difference between revisions of "CompSciWeek1"
From Predictive Chemistry
(Created page with "== Class 1 == # Pretest # Basic Shell Usage #* pwd, ls, directory structure # Access to Resources #* Logging into the lab computers #** Explanation of dual boot, OS evolution #…") |
(→Homework I) |
||
Line 34: | Line 34: | ||
# Implement the Babylonian/Hero''s 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? |
# Implement the Babylonian/Hero''s 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? |
||
# 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? |
# 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? |
||
− | # Obfuscation challenge: |
||
+ | # 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. |
||
− | 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. |
Revision as of 09:50, 21 August 2014
Class 1
- Pretest
- Basic Shell Usage
- pwd, ls, directory structure
- 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)
- Logging into the lab computers
- 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
- What is a Turing machine?
- The infinite loop and other control structures.
- First algorithms (Horner, Euclid, Babylonian)
- Code walk-through for a poorly designed Euclids algo.
- The KISS, DRY, and incremental principles
- Higher-order constructs:
- functions
- functional code
Homework I
- 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()).
- 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?
- 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?
- 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.