Laboratory Exercise #0

Similar documents
Tabbing Between Fields and Control Elements

CSE 101 Introduction to Computers Development / Tutorial / Lab Environment Setup

How to make a Work Profile for Windows 10

1) Log on to the computer using your PU net ID and password.

How to set up an Amazon Work Profile for Windows 8

Writing and Running Programs

One of the hardest things you have to do is to keep track of three kinds of commands when writing and running computer programs. Those commands are:

Instructions PLEASE READ (notice bold and underlined phrases)

CS 1110, LAB 1: EXPRESSIONS AND ASSIGNMENTS First Name: Last Name: NetID:

Semester 2, 2018: Lab 1

Lesson 4: Who Goes There?

CS 209 Section 52 Lab 1-A: Getting Started with NetBeans Instructor: J.G. Neal Objectives: Lab Instructions: Log in Create folder CS209

Fundamentals: Expressions and Assignment

Getting Started with Python and the PyCharm IDE

My First iphone App (for Xcode version 6.4)

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Setting Up a Linux Operating System

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

A computer program is a set of instructions that causes a computer to perform some kind of action. It isn t the physical parts of a computer like the

AP Computer Science Principles Summer Assignment

Programming Project #1

The Command Shell. Fundamentals of Computer Science

Microsoft Office 365 includes the entire Office Suite (Word, Excel, PowerPoint, Access, Publisher, Lync, Outlook, etc ) and an OneDrive account.

Science One CS : Getting Started

PeopleSoft Financials for Macintosh

CMSC 201 Spring 2018 Lab 01 Hello World

CMSC 201 Spring 2017 Lab 01 Hello World

What you get When you install Python for your computer, you get a number of features:

My First iphone App. 1. Tutorial Overview

Installing VMware Player to Run Ubuntu Linux on a Windows Machine

CIS 231 Windows 7 Install Lab #2

A Quick-Reference Guide. To access reddot:

Installing Microsoft Desktop Connection for MAC YOU RE USING THE MOST RECENT COPY (SEE LINK) OF MICROSOFT

Lab: Supplying Inputs to Programs

Download Instructions

The QuickCalc BASIC User Interface

Chris Simpkins (Georgia Tech) CS 2316 Data Manipulation for Engineers Python Overview 1 / 9

Timmy is the name of a UNCW file server which provides students with 20MB of storage space. It is secure and backed-up nightly. It is available from

Programming Environments

Get comfortable using computers

Automation Engine. Working with Shuttle

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

Exploring Python Basics

CPSC 150 Laboratory Manual. Lab 1 Introduction to Program Creation

Getting Started with Python

Using IDLE for

Using the Dev C++ Compiler to Create a Program

Finalizing the Project

Café Soylent Green Chapter 12

Exploring Python Basics

Applied ICT Skills MS Windows

Introduction to Programming with Python 3, Ami Gates. Chapter 1: Creating a Programming Environment

Unit 10. Linux Operating System

AmeriCorps Member Online Time Sheet Instructions

CS106 Lab 1: Getting started with Python, Linux, and Canopy. A. Using the interpreter as a fancy calculator

CAL 9-2: Café Soylent Green Chapter 12

Not-So-Mini-Lecture 6. Modules & Scripts

CSI Lab 02. Tuesday, January 21st

Enter your account number here the first time you login.

Where Did I Save That File?

Getting Started with Command Prompts

2 Getting Started. Getting Started (v1.8.6) 3/5/2007

Querying with Transact-SQL


Microsoft Excel 2007

Lab 1: Setup 12:00 PM, Sep 10, 2017

Installing and getting started with Xcode for Mac OS.

CSCI 161: Introduction to Programming I Lab 1b: Hello, World (Eclipse, Java)

PART 7. Getting Started with Excel

Your desktop or laptop computer consists of several hardware components:

Programming Project #1

CMSC 201 Spring 2017 Homework 4 Lists (and Loops and Strings)

How to Use Your EV Connect Account

Lab 1 Introduction to UNIX and C

Episode 1 Using the Interpreter

Pulse Secure VPN Guide

Initial Login Screen:

Spreadsheet Functions

My First Cocoa Program

Hands on Assignment 1

1) Use either Chrome of Firefox to access the VMware vsphere web Client. FireFox

Class 1: Homework. Intro to Computer Science CSCI-UA.0101 New York University Courant Institute of Mathematical Sciences Fall 2017

Remote Access to Unix Machines

Discovering Computers & Microsoft Office Office 2010 and Windows 7: Essential Concepts and Skills

Handbook: Carbonite Safe

Unit 13. Linux Operating System Debugging Programs

In the first class, you'll learn how to create a simple single-view app, following a 3-step process:

Organizing Screens with Mission Control

FSDirect Requester Guide

Using the Computer for Essays

How to Rescue a Deleted File Using the Free Undelete 360 Program

Word for Research Writing I: Text and Structure

This document shows all steps for the installation of LinearLabTools for Matlab users, including the installation of PScope.

RESETTING MYSQL ROOT PASSWORDS

Opening and Saving Files using Minitab in Remote Applications using Macintosh

Installation Guide: VirtualBox, Windows 10, and Microsoft Visio (Mac OS)

CS1110 Lab 1 (Jan 27-28, 2015)

Week 2: Data and Output

Media Library Help Guide

CS 051 Homework Laboratory #2

Transcription:

Laboratory Exercise #0 This assignment focuses on the mechanics of installing and using Python. The deadline for Mimir submission is 11:59 PM on Monday, January 8. 1. Complete the steps given below to download and install Python. 2. Set up your EGR account. 3. Submit your completed Hello World program using Mimir. 1. Get Python Download and install Python 3.6 from https://www.continuum.io/downloads (do not get Python 2). 2. Getting started with Python Microsoft Windows To start the Python combination under Microsoft Windows, go to Start Menu ==> All Programs ==> Anaconda ==> Spyder.

Then wait because it takes minutes to load while you look at this. Mac (OS X) On a Mac (OS X), in your apps folder open Anaconda-Navigator and select spyder. Or, type command-space for the Mac Spotlight prompt and enter spyder. Or go to the Finder and Select Applications ==> Utilities ==> Terminal and at the prompt type spyder (some error messages may show as can be seen below, but that is fine.) Then wait it takes minutes to load while you look at this

3. Using Spyder There are three parts to the window: The left half is where you write your programs. The bottom right region is the Python shell where you can both enter code and where output from your program appears. The upper right region is where you can observe the values of variables that you create essentially the current namespace, a term you will learn about soon (you have to click on Variable Explorer). Finally, at the right end of the top bar is an important region where you can specify the folder/directory where your programs will be stored. An important capability of Spyder is that it has a built-in debugger something that means nothing to you now, but will be useful later. 4. Working with the shell The window in the lower right corner is the Python shell (the shell in Spyder is the IPython shell). The shell is interactive: you can type Python commands in the shell and Python will execute them, generating a result.

In the Python shell (lower right window pane) try typing: 1 + 1 <Enter Key> print( "Hi Mom" ) <Enter Key> What output do you get? It should look like this: In[1]: 1 + 1 Out[1]: 2 In[2]: print( "Hi Mom" ) Hi Mom In[3]: What you type shows up after the [1] prompt (the number between brackets increments each time). When you type something and hit the Enter key, the result shows up on the next line(s). Sometimes you can get some surprising results, and sometimes an error. For example, try entering: or perhaps 1 + 1.2 print( hello ) The results would look like the following: In[3]: 1 + 1.2 Out[3]: 2.2 In[4]: print( hello ) Traceback (most recent call last): File "<ipython-input-4-43a14fcd4265>", line 1, in <module> print( hello ) NameError: name 'hello' is not defined The last lines show that an error occurred. Since hello was neither a variable nor had quotes around it, the print operation failed (we ll learn more about this later). 5. Developing a program Typing into the shell is useful, but the commands that you write there are not saved as a file so they cannot be reused. We need to save our commands in a file so we can run the program again and again, and more importantly turn it in!

Before you create a file you need to select the folder/directory where you will be working, i.e. saving your program. In the top bar on the upper right is a one-line window indicating which folder/directory you will be working in. Here I have specified that I will be working in the folder/directory named Documents/cse231/FS14 (I m on a Mac, but Windows people will see something similar). The file folder allows you to browse for your desired folder/directory. To open a file, select File ==> New file (or figure out the shortcut). It is always a good idea to Save the file and name it hello.py (without quotes and all lowercase). You can do that by selecting File => Save or select the Disk-Save icon in the Spyder window. Always put a.py at the end of the filename and notice the dot (a.k.a. period) it is very important. (Actually, Spyder will use.py as the file extension automatically if you forget, but it is still a good habit to put it there.) Hint: always check the directory/folder that you are saving into is the one you want to use because your operating system settings may default to somewhere unexpected. The big window on the left is an editor window into which you can type your first program. There is a tradition in computer science: the first program you create is the HelloWorld program. This program does nothing but display Hello, World! on the screen. It is a useful tradition because it does very little except focus on the mechanics of writing your first program and running it. In Python, the HelloWorld program is easy. Type the following in the editing window (i.e. the big window on the left half of Spyder.) There may be some text already in the program (often in green) so you want to enter the following on the first blank line below that text: print( "Hello, World!" ) The phrase inside the parentheses should be in quotes (either single quotes or double quotes). Because your code will be checked for accuracy when you submit it remember to include the space after the comma and the exclamation point. Save the program (as above). You can then run your module to see what your program produces. To run the program, select Run ==> Run (or hit the big green arrow or hit the F5 function key on your keyboard). The first time you will get the following dialog box simply select the default choice: Run.

The result is new output displayed in your Python shell (bottom right window), as shown below. You can see Hello World printed near the bottom. Oops, I forgot the comma and the exclamation point! 6. Running an Existing Program Copy the following Python program to your computer:

http://www.cse.msu.edu/~cse231/labs/lab00/lab00.py Put it in the same folder/directory that your HelloWorld program is (so you can find it easily). In the Spyder window select menu File ==> Open. Find the program that you copied and open it. As before, when you open a program the code of the example appears in the editing window. You can look at that code, and when ready you can run the code by selecting the editing window menu Run ==> Run. Take a look at the output (in the Python shell) and compare output lines to lines in the program. After reading Chapter 1 you should be able to understand the program. Ask your TA or on Piazza about parts you don t understand. (Note that after you run a program that is big enough or complicated enough, a new file is created automatically. It will have the same name as your original file, but with the extension.pyc. For example, when you run numberinput.py, the file lab00.pyc is automatically created. It is a file that is the compiled version of your file. You can completely ignore that file we are pointing it out only because you may notice it.) 7. Setting Up Your EGR Account You should already have an EGR account and if it s the first time you are using it, you should activate it using the following: https://www.egr.msu.edu/decs/myaccount/?page=activate Important: Your initial password is your PID (including the capital A) followed by @, e.g. A12345678@. You must change it for a new, and better one. 9. Submit Your Assignment The final step is to submit your hello.py program using Mimir system. How do you find Mimir? There is a link from the D2L course page for CSE 231. (There is normally a $25 charge for Mimir, but the Dean found money to pay for it this semester so it is free.)