This assignment gets you started with the basic tools you will need to complete all of your homework projects in Python.
You are a student who needs to install all the tools necessary to get started in CS4641.
cs4641
. Note: avoid putting spaces in file and directory names, since doing so complicates the use of some command line tools.hw0
subdirectory of your CS 4641 coursework directory for your HW0 solution.On Unix/BASH you can create both of these directories at once with
$ mkdir -p cs4641/hw0
Windows uses the same commands for directory navigation and creation, cd
and mkdir
, but Windows’s mkdir
command doesn’t have the -p
option.
Note: the $
is the command prompt on most Unix shells and Windows 10’s Ubuntu BASH shell (would be something like C:\>
in Windows cmd
), the text after it is what you enter.
hw0
directory you just created and enter these commands:$ python --version > hw0-output.txt
>
redirects the output of a program, in this case to the hw0-output.txt
file. Important note: if the line above doesn’t write your Python version to the hw0-output.txt
file then replace the >
with 2>
and try again. Some versions of Python, such as the one installed by Anaconda and miniconda, write the Python version to stderr
instead of stdout
. >
redirects stdout
and 2>
redirects stderr
. For more informaiton, this blog post has a nice discussion of the file descriptors stdin
, stdout
and stderr
.
hw0
directory named myscipy.py
and save the following Python program in the file:#/usr/bin/env python
import matplotlib as plt
import numpy as np
import pandas as pd
import scipy
import sklearn
print(f"Matplotlib version: {plt.__version__}")
print(f"Numpy version: {np.__version__}")
print(f"Pandas version: {pd.__version__}")
print(f"Scipy version: {scipy.__version__}")
print(f"Scikit-learn version: {sklearn.__version__}")
In your OS command shell, cd
to your hw0
directory and enter python myscipy.py
to run the program and see its output on the command line.
Add the output of your program to hw0-output.txt
by running
python myscipy.py >> hw0-output.txt`
Don’t forget the extra >
in >>
. >>
appends to an existing file, a single >
overwrites an existing file.
hw0-output.txt
FileAt this point your `hw0-output.txt file should contain
If your hw0-output.txt
file is missing any of those elements you should redo all the steps that add content to hw0-output.txt
in each of the previous sections.
Submit your hw0-output.txt
file on Canvas as an attachment. When you’re ready, double-check that you have submitted and not just saved a draft.
Practice safe submission! Verify that your HW files were truly submitted correctly, the upload was successful, and that your program runs with no syntax or runtime errors. It is solely your responsibility to turn in your homework and practice this safe submission safeguard.
This procedure helps guard against a few things.