Homework Assignment Number 2

  1. Read chapter 2 in Donaldson book
  2. Open an Idle shell and do exercises listed below
  3. There are 2 types of information requested:
  4. When you are done, save the contents of the IDLE window (see File menu).
  5. Name this file: Homework2-your-name.txt
  6. Submit the resulting file using Blackboard.
  7. Important: this is the First and Last time that we will be handing in Idle Output (saved as a .txt file) In the future, we will start writing program files (scripts) and saving them as .py files.
Exercises:
  1. Use the print function to print the following strings, including the embedded quotes and blank lines:
    1. The newscaster said, “And Now for Something Completely 
                    Different!”
    1. One quote: ', Two quotes “, Red Quotes,
                    Blue Quotes
  1. Evaluate the following expressions and explain (as comments) why they yield different answers:
    1. '5' + '4'
    2.  5 + 4
  2. Incorporate type conversion into a statement so that you combine '5' and '4' to get '9'
  3. Evaluate each of the following expressions. Then make a new
    version of each expression incorporating parentheses that
    make the order of operations explicit. Evaluate this second
    expression (you should get the same result).
    – Example: 1*1**1+1 and (1*(1**1))+1 both evaluate as 2
    1. 5*5/5–5
    2. 5-5**5*5
    3. 60-40*1.5+5**2-25
  4. Evaluate the following expressions:
    1. 3%3, 4%3, 7%3, 25%3, 98%3, 137%3, 1997%3, 1313%3
      and 10011%3
    2. Make lists (as a comment) of 3 sets: the set of numbers
      such that X%3 = 0, the set where X%3 = 1 and the set
      where X%3 = 2