Assignment 1
Interactive Python and Scripting
Submit before 11:30 PM Friday September 15

Overview

You will continue to work with the Python interactive shell and the Integrated Development and Learning Environment (IDLE). As before, make sure you copy and paste your work in a text editor to ensure that your work is saved.

Interactive Python

Using the interactive Python shell, type in and evaluate Python expressions for each of the following. Use online resources if you are not sure of the needed Python operator for performing an operation.

  1. Try out the following expressions and statements:
    • 10 / 3
    • 10 // 3
    • 10 % 3
    • list1 = ["cat", "dog", "emu"]
    • list2 = ["asp", "bat", "owl"]
    • len(list1)
    • list1 + list2
    • list3 = [23, 45, 10]
    • sum(list3)
  2. Assign these hiking distances to a list: 12, 23, and 18 miles. Then, using your list, find the average distance.

Python Questions

  1. Explain the difference between these three operators: /, //, %.
  2. Assign 8 to the variable val. What happens if you type in "The answer is " + val? What do you need to do to avoid the error?
  3. What is the difference between int("10") and float("10")?

Python Scripts (little programs)

Write and test Python scripts (create a py file each) that do the following:

  1. Read in three integers (use input statements) and write out a summary message that includes the average of the three integers.
  2. Prompts and reads (use input statements) in three words or phrases (e.g. a color, an action, an animal) and then produces a short statement or story that includes the three words or phrases.

Deliverables

Create a text file called assn1.txt that contains the following:

  1. A statement (a paragraph or more) that summarizes your completion of the assignment. It should include who you collaborated with (if anyone) and any online resources that you used.
  2. The text of your interactive Python exercises
  3. The answers to the questions
  4. For each of your Python scripts:
    1. A listing of the script (copy the code in the py file and past it in the assn1.txt file)
    2. Running examples that demonstrate that your script works correctly (copy the text that shows your py file running and paste it in the assn1.txt file)

Submit your assn1.txt file to D2L.