CS303E Homework 0

Instructor: Dr. Bill Young
Due Date: no submission due

Copyright © William D. Young. All rights reserved.

Getting Familiar with the Tools

This first assignment is to get you started using the system. It will not be collected or graded. Don't submit it.

It is suggested that you become familiar with IDLE, VSCode, PyCharm or other IDE (interactive development environment); there are many of them out there suitable for Python development. IDEs provide many advantages including syntax checking, keyword completion, automatic indentation, etc.

However, one danger of using an IDE is that you become too dependent on it. It is strongly suggested that you be able to enter Python code in a text editor, save as a file, and run the file from your system's command line. That's how your instuctor develops programs.

IDLE is a IDE that is distributed with Python. It is almost certainly automatically installed on your machine if Python is there. You don't have to use IDLE in this class; you will never be tested on your knowledge of IDLE. In fact, a different IDE, VSCode, is used in CS313E, and several of the TAs think you'd be better off using that. However, be aware that your instructor and/or TA may not be familiar with the particulars of some random IDE that you've chosen to use.

If you decide to use a different IDE than IDLE, try to do the following steps in that IDE instead of in IDLE. The particulars of how to carry out the steps may be different. But you should be able to carry out all of them in any IDE for Python.

Take the following steps:

  1. Check that you have Python3 installed on the machine you plan to use to do your work this semester. When you start Python it will tell you what version you're using. Make sure it says Python 3.x.y (for any values of x and y). For example, the current version on my desktop machine Python 3.8.10.
  2. Check that you have IDLE installed on your machine. IDLE is a simple IDE (integrated development environment) for Python.
  3. If you know how, move to some directory where you'd like to work. If you don't know what that means, don't worry about this step.
  4. Start IDLE. It should open a new window. At the top it will say what version of Python is running; be sure it's Python 3 (i.e., shows Python 3.x.y for any values of x and y).
  5. From the File menu at the top select New File. A new window should open.
  6. In that window, type the following line at the left margin:
    print("Hey, I'm using IDLE!")
    
  7. From the File menu, select Save. It should bring up a dialog box. Save the file with name IdleTest That should create a file called IdleTest.py in the current directory.
  8. Close this window, by selecting Close in the File menu.
  9. Go back to your original IDLE window, and select Open under the File menu. Type IdleTest in the dialog box. This will bring up a new window with the text from your file IdleTest.py.
  10. Under the Run menu, select Run Module. This should print the line "Hey, I'm using IDLE!" (without the quotes) in your IDLE window.
  11. Congratulate yourself that you have executed your first Python program!
  12. You can now close your IDLE window, or play with it some more.

Python has a notion of a "module" which is just some code. There are also files. Typically, Python will consider that a file named SomeName.py contains a module named SomeName. (A module is a Python notion; a file is managed by your operating system, though Python has commands for reading and writing files.) Notice that the .py extension is on the file name, not on the module name. IDLE seems to put the extension on for you when you save a module into a file.

Notice that IDLE is a very simple IDE. There are more sophisticated ones available such as PyCharm. You are welcome to use those this semester, but it's helpful to be able to interact with IDLE at this simple level. So I suggest using it initially to get familiar with interacting with your computer. Many students stick with IDLE all semester and find it quite adequate.

Turning in the Assignment:

You are not submitting this assignment! However, subsequent assignments will be submitted on Canvas, so I'm going to tell you what I will tell you for them so you'll get used to it.

You are going to be submitting a file. So just running code under Idle or any other IDE won't be adequate. Your code must be in a file, so that your TA can run it and test it. The Save step above (step 7) would have saved the code you typed into the Idle window into a file named IdleTest.py, but you could have specified a different name. For each assignment, we'll give you a file name to use; you must use that name or we won't grade your assignment. For this assignment, if we had asked for a submission we'd have told you to name your file IdleTest.py. You would have submitted a file with that name to Canvas under assigment hw0 under the assignments section, by uploading your Python file.

However, if you submit multiple times to Canvas, it will rename your file name to something like IdleTest-1.py, then IdleTest-2.py, etc. Don't worry about that; we'll always grade the latest version.

You should always test your file before you submit. If it doesn't even run, you'll lose most of the credit. Your file must also contain a header with the following format. (Notice that this means that your code file contains these lines as comments at the top; it doesn't mean that your file prints this when it runs!) The date can be the date you submit.

# File: IdleTest.py
# Student: 
# UT EID:
# Course: CS303E
# 
# Date:
# Description of Program: 
You'll supply the missing information. The name of the file will change with every assignment. Make sure that you use the name specified. Finally, the Description of Program should be one or two sentences very briefly saying what the program does. Don't write a book!