CSSE 120 — Introduction to Software Development, Robotics

Homework 1

Reminder: for each class session and associated homework:

  • You generally have reading to do.
  • You do all other work in Eclipse in the project that you checked out for that session.
  • You turn in your Eclipse work by committing that project:
    • Right-click on the project name in the Pydev Package Explorer view.
    • Select Team → Commit
    • In the message box that appears, put a message to yourself if you wish (eventually, these messages will be for your teammates) and press OK.
    It is a GOOD idea to COMMIT OFTEN, not just when you finish the homework. Doing so provides easy backups of your work.

Questions? Email csse120-staff@rose-hulman.edu.

Best place and time to do the homework: CSSE lab (Moench Hall, room F-217), 7 p.m. to 9 p.m., Sunday — Thursday.

Today's project: Session01_IntroductionToPython

Main learning objectives for this homework:

  • Starting to get familiar with Eclipse (your IDE — Integrated Development Environment)
  • The basic structure of a Python program in our style: main.
  • The input/compute/output pattern:
    • Prompting for and getting input from the user
    • Using variables to store values
    • Printing strings and the values of variables
  • An introduction to:
    • Defining functions without parameters.
    • Calling functions without parameters.

Additional learning objectives for this homework:

  • A brief introduction to counting loops (FOR statements with RANGE expressions)
  • An introduction to:
    • Defining functions with parameters.
    • Calling functions with parameters.

Do the following exercises. For problems 2 and 3, use today's project: Session01_IntroductionToPython

  1. Complete the assigned reading for the next session, Zelle, §1.3, 1.5–2.4.
  2. Do the TODO's in the m2_my_first_program.py module of the Session01_IntroductionToPython project that you checked out today.
  3. Study the code in the m1_chaos.py module of the Session01_IntroductionToPython project that you checked out today. Make sure you understand it. (Send questions to csse120-staff@rose-hulman.edu.) Then:
    1. In that same module, add another function called more_chaos that is exactly like the existing chaos function except:
      • more_chaos also asks the user for a second number, and stores that number in a variable.
      • more_chaos uses that second number instead of 3.9 as the constant in the chaos formula. That is, the variable that you use to store that second input from the user replaces the 3.9 in the line of code:
            x = 3.9 * x * (1 - x)
        
    2. Test your more_chaos function by calling it from main.
    3. When you run the program, try several different constants. Include 2.0 as one of your choices. What do you notice about the sequence of numbers printed? Does the constant affect the degree to which the sequence is chaotic?

      Include a brief answer to these questions as a comment above the code for your more_chaos function.

  4. Double-check your installation of Python, Eclipse and SVN by following these brief instructions.
  5. There is a large on-line community of Python users. Take a look at python.org to see some of what is available. (Nothing to turn in for this problem.)