The computer workstations in our lab can run both Windows and Linux operating systems. We will use the Linux operating system in this course.
Note: Outside of lab, you may access your Linux account from any computer connected to the Internet, provided you have the right access software, e.g., a secure shell client program. Some work for this course you can do from any computer, but most work you will have to do directly on the Linux machines.
After the lab, you should know how to
If you can do all those things, you are all set for the course!
For this part of the lab, work through this document and do the exercises. Hand in the worksheet before you leave lab.
Note: If you took CS101 and logged into the system before you can continue using the same password for the system. Login and then skip to step 3.
example.css
, example.html
, and
example.gif
files from
/home/courses/cs111/handouts/lab0
into your public_html directory.
(Recall: what is the special name for the current directory?)
http://www.cs.wlu.edu/~yourusername/example.html
You
should see the example web page. If you get an error message in the
browser window, ask for help.
http://www.cs.wlu.edu/~yourusername/
example.html
into a file named
index.html
. Now, point your browser to the location:
http://www.cs.wlu.edu/~yourusername/
(We can talk about what's going on here more later in the course, but for now, just realize that index.html hides the contents of your web directory.)
jedit index.html &
The "&" (called the "ampersand") is a special command to let the terminal know that you want the program to open in a new window and let you keep using the terminal window too. I will also refer to the ampersand as saying that you want the command to "run in the background".
jEdit is a "text editor", i.e., a program that helps you create files. jEdit looks similar to a Word Processor. Look through some of the menus and you'll notice a lot of functionality that you'd see in a typical Word Processor, such as save, open, copy, and paste.
Note that the page has several links to other online documents in it. The HTML Help link is useful if you want to develop more web pages after this brief introduction.
Note the pattern of the links in the HTML file. How would you create a link to CNN? (You will perform similar activities throughout the course. You'll look at example code that does something similar to what you want to do, copy the code, and modify the code to do what you want.)
img
) tag in your web page to display this image.
Note that you didn't need any fancy software to be able to create a nice web page. I create my web pages for the course in a similar manner.
labs/lab0
.)
In general, on our system, you have two options for writing Python programs:
You might want to try them both to see which way you prefer.
Either way, you'll use IDLE to demonstrate your program working.
For this part of the exercise, use IDLE.
idle &
Recall: what does the & allow you to do?
You can use the shell to tryout expressions before putting them into a script. To get the shell in the terminal, simply type "python". In IDLE, the main window is the Python shell.
shell_practice.out
Make sure that this file is
saved in the appropriate directory (labs/lab0
).
hello.py
, which you copied
earlier. What should the code do? Execute the script by
hitting F5 to verify your expectations.
practice.py and execute the program.
- Save the output from the shell in a file called
practice.out
. Make sure that this file is
saved in the appropriate directory (labs/lab0
).
Your programs will be graded on both correctness and style. Style will become more important as the semester continues.
Note that the convention is that the names of Python scripts end in ".py".
practice.py
into a file called practice2.py
.
Modify the program in two ways:
Modify the comments at the top of the program appropriately.
After you are sure that your program works and you have saved your
program, start a new IDLE shell by closing the shell and starting a
new one. Execute your program to demonstrate that your program
works. Save the output from the shell in a file called
practice2.out
.
info.py
that prints out
information about yourself. The info printed should list your name,
favorite sports team (could be professional, college, or other), favorite
color, and favorite dwarf (Sleepy, Sneezy, Happy, Grumpy, Dopey, Bashful,
or Doc). Don't forget to document your program appropriately!
You will use four separate print statements on four separate lines to print this information.
The output should looks something like:
Example Output:
Name: Sara Sprenkle Favorite team: Duke Favorite color: purple Favorite dwarf: Doc |
After you are sure that your program works and you have saved your
program, start (or restart) the IDLE shell. Save the output from the
shell in a file called info.out
.
turnin
directory.
(Review the UNIX handout if you don't remember how to
do that.)
printLab.sh <labdirpath>
lab0
directory, it's easiest to "go up a
level" to the parent directory and use the script.
The script printLab.sh
creates a condensed version of your lab in a postscript file called
lab0.ps
. To save paper, the script puts two pages on a piece
of paper. The script also highlights the Python code appropriately.
gv
lab0.ps
gv
is short for "ghostview"
and allows you to view postscript files, which are suitable
for printing. Your file should not be more than a few pages.
Otherwise, you're printing too much. See the instructor or
student assistant if you're having trouble.
lpr
-P<printername> lab0.ps
cslab
when you're in P405 or advlab
if you're in P413.
lpr
means to print the file. The option 'P' says
which printer to use (one of the CS lab printers), and the argument says which file
to print--in this case lab0.ps
.
Turn in your printed lab assignment.
Labs are due at the beginning of Friday's class. You should hand
in the printed copy at the beginning of class, and the electronic
version should be in the turnin
directory before 1:20
p.m. on Friday.
Ask well before the deadline if you need help turning in your assignment!