In Class: Week 2 (strings, string functions, string operators)


If you have not already copied over the week 2 in-class files, then create a week02 subdirectory in your cs21/class directory, and copy over some python files from my public directory into it:

    % cd 
    % cd cs21/class
    % pwd
      /home/your_user_name/cs21/class

    % mkdir week02        
    % cd week02
    % pwd
      /home/your_user_name/cs21/class/week02

    % cp ~newhall/public/cs21/week02/* .
    % ls
	

We are going to do some of the following:
  1. String operators: open test_string.py in vim. We will try out some of the string functions (len, ord, chr) and some of the string operators (+ (concatenation), * (repetition), : (slice)

  2. Pattern of stars problems: open test_stars.py. We are going to write programs to print out the following patterns of stars. Let's start with the first one.
      (1)   when num is 4:             when num is 5:
             * * * *                   * * * * *
             * * * *                   * * * * *
             * * * *                   * * * * *
             * * * *                   * * * * *
                                       * * * * *
      (2)    - - - - * * * *
             - - - - * * * *
             - - - - * * * *
             - - - - * * * *
                             
      (3)    *
             * * 
             * * * 
             * * * *