Presentation on theme: "Lab III – Linux at UMBC. Overview Hello, and welcome to CMSC 201. We will be covering the following topics in this week's lab: TA Introduction: My name."— Presentation transcript:
Overview Hello, and welcome to CMSC 201. We will be covering the following topics in this week's lab: TA Introduction: My name. My email address. My office location and office hours. The Linux/Unix Environment. Exercises: Unix Commands. Setup CMSC 201 directories Logging Out. How to logout/lock your workstation.
Switching to Python 3.0 You only need to do this once After youve 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 its OWN separate line: source /afs/umbc.edu/common/etc/python33.cshrc Save and exit Log out of gl Log back in and type python --version Your version should now be 3.3.2
Why Python? Very simple, but powerful high level programming language Great for beginners Wide variety of applications including throw away/ad- hoc programming, scripting, web scripting, XML processing, and many more Far less code when compared to C, Java, etc. Very human readable code
Overview If 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
General Information What good is a TA in this course ? Contact Information - Now a Blackboard Tab on the Left How are the weekly labs graded ? Complete: 3 Not Even Close: 1 Incomplete: 2 Absent: 0
Linux/Unix There 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 machines linux1.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.
Resources Basic Unix Commands: http://www.csee.umbc.edu/courses/201/spring12/labs/u nixcmds.html http://www.csee.umbc.edu/courses/201/spring12/labs/u nixcmds.html Alphabetical Listing of Linux Commands: http://www.oreillynet.com/linux/cmd/ http://www.oreillynet.com/linux/cmd/ (You would do well to memorize a few, it will make your life much easier for the duration of this course)
Unix/Linux Commands As 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.
Unix/Linux Commands cd into your 201 directory Create a Labs directory using mkdir folder and cd into it Create directories for labs 3 through 14 cd into your lab3 directory
lab3.py Today, 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 file Copy 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!
lab3.py Copy the following code into your newly created file: # File: lab3.py # Written by: YOUR NAME HERE # Date: DATE HERE # Section: ? # Email: ?@umbc.edu # Description: Lab 3, i/o and Math operators def main(): #Prompt for 3 input values #Casting each input values as integers #Perform mathematical operations #Print the totals main()
lab3.py Use 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 integers On the first inputted value, take that value and square it (hint: use the ** operator) For the second and third values, simply store their sums Finally, print out the values, accompanied by appropriate messages saying what operations were preformed on each value
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 values Demonstrate that you are running the correct version of Python (3.3.2) via the command python -- version