Today's lab will focus on using the Blackboard system and simple programs in python.
Software tools needed: web browser and python idle programming environment.

Using Blackboard

This course will use the on-line Blackboard system for submitting work electronically. Blackboard should be accessible through your CUNY portal account (http://portal.cuny.edu). If you have not used Blackboard in the past, information is available at the Computer Center (http://www.lehman.edu/itr/blackboard.php). They can set up your account and have information sheets about using the system.

We will be using Blackboard for in-class quizzes, submitting programs, and posting grades. Quizzes and submitting programs are done via the Content menu (left hand side of Home screen).

Timing Out: If the system times out and locks your attempt (happens rarely when the browser or PC crashes), send email to an instructor so they can clear the attempt so you can try again.

Using Python

We will be using the Idle programming environment for python. On the desktop, there is an Idle icon. Click the icon to launch idle. In the shell window that pops up, try typing some of the commands that we did in lecture (also from the textbook):

	print("Hello, world!")
	print()
	def greet(person):
	   print("Hello", person)
	greet("world")
(Indentation does matter, so, remember to indent the print line, using TABs, so that it is included in the greet() function.)

Next, let's write a program that will greet someone 5 times. Instead of using the shell window (which lets us try things immediately), let's use a text window, where we can save our program for later. The basic structure of the program will be:

#Define our function
	#Have a loop that repeats 5 times
	#Inside that loop, greet that person 
Copy the above lines into a new text window. Save, using the name, greetLoop.py to your USB drive. If you try to run your program, it will currently do nothing, since all the lines are proceeded by the `#' and treated as a comment.

Let's fill in a bit more of the program:

#Define our function
def greetLoop(person):
	#Have a loop that repeats 5 times
	#Inside that loop, greet that person 
	print("Hello", person)
Save your revised program and run it (using the "Run module" from the run menu or F5 key). At the shell, if you type:
greetLoop("World")
how many times does the message get printed? Why?

Let's add in the missing loop, to make it print out the multiple times:

#Define our function
def greetLoop(person):
	#Have a loop that repeats 5 times
	for i in range(5):
	#Inside that loop, greet that person 
	print("Hello", person)
Save your revised program and run it (using the "Run module" from the run menu or F5 key). At the shell, if you type:
greetLoop("World")
how many times does the message get printed? What went wrong? A loop only repeats statements indented below it. Since our print statement wasn't indented, it decided we had an `empty loop' followed by a simple print statement. To include the print statement in the loop, we add indentation:
#Define our function
def greetLoop(person):
	#Have a loop that repeats 5 times
	for i in range(5):
		#Inside that loop, greet that person 
		print("Hello", person)
Save your revised program and run it (using the "Run module" from the run menu or F5 key). At the shell, if you type:
greetLoop("World")
how many times does the message get printed?

Change your program so the message is printed 25 times.

A common thing to include in your python file is a call (or "invocation") to the function at the end of the file:

#Define our function
def greetLoop(person):
	#Have a loop that repeats 5 times
	for i in range(5):
		#Inside that loop, greet that person 
		print("Hello", person)

greetLoop("Herbert")		
When you run the program ("Run module" or F5), the program will be loaded and the function is called automatically. In this case, it will call the function, greetLoop with the parameter "Herbert". If you would like to call the function again, you type the name of the function with the desired parameters, at the shell prompt.

With the remaining time, start Problem 1.

Using Python on Your Computer

The python programming language and idle environment are freely available for many platforms from python.org. For this class, we are using python 3. Many features of the language (including the syntax of print statements) changed between the second and third version, so, you must use the python 3 for submitting programs.