Welcome to DS2000 CS practicum!
Today we'll make sure you have the software necessary to start learning Python and we'll write our first program in Python! If you're interested in the papers or code that I talked about in the intro, you can download the slides. Now, let's get started.
Installing Python 3.7
Go to https://www.anaconda.com/distribution/#download-section
Select your operating system.
- Download the 3.7 version of the 64-Bit graphical installer, and start it. Make sure you check "Add Python to $PATH" if asked. Do not install PyCharm if asked Check "Disable path limit" if asked
Installing Atom Editor
Go to https://atom.io and download Atom.
In Atom enable the following option:
Windows: File > Settings > Editor > Invisibles > Enable invisibles (or Show invisibles)
mac OS: Atom > Preferences > Editor > Invisibles > Enable invisibles (or Show invisibles)
scriptand install it.
Writing your first program
Make sure Atom is still running
Create a new scrpt (File > New File)
Save the file as
hello_world.py(do not save it directly in documents. Create a folder structure intead, for example
print('Hello world')in the script. Run the code by pressing
Ctrl+Shift+Bon Windows (or
⌘Ion a Mac). Do you see something like this?
If yes, congratulations, you ran your first program! If you get an error message, it's not a big deal! All programmers constantly get errors. Learning how to read and understand the error messages is an important part of programming. Please ask the professor or the teaching assistant for help. If you're on Windows and the error you get is along the lines of
python is not a recognized command, you will need to add python to your system path. To do it,
go to your command line (
cmdand press Enter.) type
setx path "%path%;C:\Users\YOUR_USERNAME\Anaconda3"but replace
YOUR_USERNAMEwith your actual username. if you don't see a message that mentions the path being truncated, try running your code in Atom, otherwise go to the next step. Open Registry Editor, and go to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment. Modify the
Pathvariable to add
C:\Users\YOUR_USERNAME\Anaconda3at the end of it. Confirm and restart your computer, try with Atom again.
Preparing your program for submission
The top lines of a python script can be used to leave comments about what this file is (for example, a submission to the first practicum). Longer comments start and end with three
'characters Inside the code you can also use single line comments by starting the line with a
#character for example to explain to yourself and others reading your code what the next line or section is supposed to do, see here:
Copy and paste the code below to a new .py file and save it as
hello_name.pyin the same folder as your
hello_world.pyfile. Modify the code to write a program that prints your name (you can also print your preferred pronoun):
''' DS2000 Fall 2019 PR01 - hello world, my name is... ''' # ENTER CODE BELOW THIS LINE (1-2 lines) # ENTER CODE ABOVE THIS LINEMake sure that the program runs with no errors and prints what you intended. Zip (compress) the folder that hass your
hello_name.pyfiles and submit your practicum code to Blackboard.
After you setup python and submitted to blackboard, please read this article https://www.fast.ai/2019/01/29/five-scary-things/. We will discuss it during the next class.