Python Basics 1*

Andrew Dalke / Dalke Scientific Software, LLC

Other Readings

Lecture Notes

  1. What is Python?
  2. Interactive mode
  3. Some simple Python scripts
  4. Mechanics of creating a Python script
  5. Statements
  6. Literals
  7. Operators
  8. Functions
  9. Variables
  10. Processing the Command Line
  11. Basic I/O

    Problems

    1. Create a program called "add" to sum two arguments:
      
      > add 2 3
      5.0
      >
      
    2. Modify this script so that it gives a helpful error message if both arguments are not present:
      
      > add 2
      Please provide two numeric arguments
      >
      
    3. Create a script called "now" to print the current time of day, in any format:
      
      > now
      It is now 2004-02-03 10:46:40.168285
      >
      
    4. Create a script called "reversec" to produce the reverse complement of a sequence (hint, use maketrans example)
      
      > reversec GAGAGAGAGAGTTTTTTTTT
      AAAAAAAAACTCTCTCTCTC
      
    *Modelled on Perl Basics 1 by Lincoln Stein et al.
    Andrew Dalke
    Last modified: Tue Feb 3 12:45:42 SAST 2004