2 OverviewHello, and welcome to CMSC 201. We will be covering the following topics in this week's lab:TA Introduction:My name.My address.My office location and office hours.The Linux/Unix Environment.Exercises:Unix Commands. Setup CMSC 201 directoriesLogging Out. How to logout/lock your workstation.
3 Switching to Python 3.0 You only need to do this once After you’ve logged into gl:Type “emacs .cshrc”This will open a file with roughly 30 lines of code, scroll to the bottom and ADD this line on the bottom of the file on it’s OWN separate line:source /afs/umbc.edu/common/etc/python33.cshrcSave and exitLog out of glLog back in and type “python --version”Your version should now be 3.3.2
4 Why Python? Very simple, but powerful high level programming language Great for beginnersWide variety of applications including ‘throw away’/ad- hoc programming, scripting, web scripting, XML processing, and many moreFar less code when compared to C, Java, etc.Very human readable code
5 OverviewIf you are on a lab computer, you should always be booted into Linux; otherwise, restart.You may bring your own laptop to complete your labs. However, it is your responsibility to be familiar with logging into GL and completing the lab.If you are using a Mac, simply open the Terminal: Launchpad Utilities
6 General Information What good is a TA in this course ? Contact Information - Now a Blackboard Tab on the LeftHow are the weekly labs graded ?Complete: Not Even Close: 1Incomplete: Absent: 0
7 Linux/UnixThere are several flavors of Unix : IRIX, Solaris, Linux, etc. For this class your programs must run on the gl.umbc.edu machines which run linux. If you are in the lab and are running linux, when you log into your account you will be running linux on your own local workstation. The version of linux running in the labs is exactly the same as the one running on the gl machines. If you are logging in from another computer that's running linux, like your laptop, when you ssh into gl.umbc.edu you will be logged onto one of three machineslinux1.gl.umbc.edu, linux2.gl.umbc.edu, or linux3.gl.umbc.edu depending on the load of each machine.Your directory, where all of your files are stored, can be accessed by all of the UMBC lab machines as well as by linux1, linux2 and linux3.All of the work for this class should be done within your UMBC account.
8 ResourcesBasic Unix Commands: nixcmds.htmlAlphabetical Listing of Linux Commands:(You would do well to memorize a few, it will make your life much easier for the duration of this course)
9 Unix/Linux CommandsAs described in the previous slide, you may run linux on your local workstation or log onto gl.umbc.edu. For today's lab we're going to login as you would from home.You'll have to use the ssh command to log into gl.umbc.edu.Right-click on the desktop background to open a terminal.At the linux shell, type ssh gl.umbc.edu.Then type your password to login.
10 Unix/Linux Commands ‘cd’ into your 201 directory Create a ‘Labs’ directory using ‘mkdir’ folder and ‘cd’ into itCreate directories for labs 3 through 14‘cd’ into your lab3 directory
11 lab3.pyToday, you will create a simple program that combines the use of integers, math operators, and input/output.Start by creating the lab by typing “emacs lab3.py” which will open up the text editor and a blank fileCopy the code on the next page, fill in the header with your name, section number, etc.Notice the comments found below main; use them to give you an idea of how to write your program!
12 lab3.py Copy the following code into your newly created file: # File: lab3.py# Written by: YOUR NAME HERE# Date: DATE HERE# Section: ?## Description: Lab 3, i/o and Math operatorsdef main():#Prompt for 3 input values#Casting each input values as integers#Perform mathematical operations#Print the totalsmain()
13 lab3.pyUse the EXACT header example you are given for this lab for all subsequent labs and homework!Your objective in this lab is to create a simple program that prompts the user for three separate values:Upon receiving those values, the values will be stored by default as strings; cast them into integersOn the first inputted value, take that value and square it (hint: use the ‘**’ operator)For the second and third values, simply store their sumsFinally, print out the values, accompanied by appropriate messages saying what operations were preformed on each value
15 To Receive a Full Lab Grade Say the name of your TA, his/her office hours, and where his/her office hours are located“Lab3.py” should output the first value entered by the user squared, and the sum of the second and third entered valuesDemonstrate that you are running the correct version of Python (3.3.2) via the command “python -- version”