Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
New York University School of Continuing and Professional Studies Division of Programs in Information Technology Introduction to Python Setting Up Your Lab Computer We will do exercises together during class, so let's set up our lab computers to make it easy to get started running scripts each week. We only need to set up our lab computers once this semester. Please make note of the location of our working folder on your lab computer so you can get set up to run programs in class at the start of each session. You can also feel free to use your own laptop, which should be set up similarly. 1. Verify that Python is available on your system a. open a Terminal or Command Prompt window. Mac: click on magnifying glass, type 'Terminal' Windows: Click on Start > Run... and type 'cmd' b. at the prompt, type python -V. you should see Python 3.x where x is a number (4 or higher) If you get an error or see another version of Python let me know immediately. 2. Establish a working folder for in-class work a. Locate your computer's Save Folder. We will identify this folder in class. b. I will create a folder labeled Python_Sp17 in the Save Folder c. Inside the Python_Sp17 folder, create a firstname_lastname folder (using your names). This will be known as your "personal folder". d. Keep in mind that the computers periodically wipe saved files from the system except for the working folders we are creating. So if you'd like to save files for later retrieval, save them in your personal folder. 3. Create a "Hello World" app and save it in your personal folder a. Open the Atom text editor (or another if you prefer) b. Write your app: print("Hello, World!") c. Save in your personal folder as hello.py 4. Going back to Terminal or Command Prompt, cd into your personal folder and run the script. You should see the greeting Hello, World! printed to the screen. python hello.py 5. Take a look at the python_data folder in Python_Sp17 a. Inside the Python_Sp17 folder you will see other students' folders, as well as a folder named python_data. We will use this folder to hold our source data. b. Make sure that your folder structure is arranged this way: "Save Folder" |_Python_Sp17 |_firstname_lastname (based on your name of course) |_python_data 6. Write a script that accesses the python data Go back to your hello world app and add the following code so the script looks like this: aa = '../python_data/student_db.txt' bb = open(aa).read() print bb You should see 3 lines with comma-separated values printed out: jw234,Joe,Wilson,Smithtown,NJ,2015585894 ms15,Mary,Smith,Wilsontown,NY,5185853892 pk669,Pete,Krank,Darkling,NJ,8044894893