CS 111 - Introduction to Computing, Fall 2016

Lab 1

For this assignment, we will write a simple Python program in the JES environment. You should look at the example program Lect0825a.py that was written in lecture on 8/25. This program shows the basics of output and calculations which you will need to do for this program.

The JES Environment

The JES Development environment can be download from the main CS 111 Web Page.

Running JES on SOME machines in the ACCC Labs

JES can be found on SOME OF the machines in the ACCC Labs. Not all of the ACCC Labs have this software installed.

  1. clicking on the Start button (lower left corner of the display)
  2. clicking on the Programming folder
  3. clicking on the JES RXXXX application (where XXXX is the release number of the software)

Python Programming

When doing Python Programming, it is very important to follow a basic Java Template. Below is a file called template.py

# This is a comment to describe the below program
# This program is being written for CS 111 for Assignment X
# Author: Your name here
# Date: Today's Date

def functionName ():
<nbsp> # place code here
<nbsp> # pay attention to indention! VERY IMPORTANT IN PYTHON!!!

<nbsp> # create and intialize variables first

<nbsp> # do any needed calculations

<nbsp> # print results

Output in Python

To output to the screen, we use the print function. Between the parenthesis, we place the information that we wish to display. To display a string of values (i.e. words), we place the words in double quotes. Such as:

     print ("Hello.  Hope you have a good day.")

To print out a number or the value of a variable, we place that information between the parenethesis. For example:

     print (57)
     print (number)

We can print both some text and a value by placing both of these in between the parenthesis and separating them with a + sign, such as:

     System.out.println ("The result of the operation is " + number);  

Note, there also exists a method System.out.print(). This method will have the next printed item begin on the same line as this one ends. The System.out.println() always has the next printed item begin at the beginning of the next line.

Also note that to print a blank line in the output (i.e. to skip a line), use System.out.println() with nothing between the parathesis. In the program Template.java, this same thing was done by printing an empty string:


Both produce the same result. You will notice that often the same result can be produced via different approaches.

Lab Assignment 1

Due: Wednesday 8/31/2016 by 11:59 pm (i.e. midnight)

Write a Python Program that will contain a function called lab1( ). This function is to do the following:

  1. Print out your name
  2. Print out your net-id
  3. Print out CS 111
  4. Print out your lab time
  5. Print out the additional information as described below:

As I Was Going to St. Ives

"As I was going to St Ives" is a traditional English language nursery rhyme which is generally thought to be a riddle.

The most common modern version is:

As I was going to St. Ives,
I met a man with seven wives,
Every wife had seven sacks,
Every sack had seven cats,
Every cat had seven kits,
Kits, cats, sacks, wives,
How many were going to St. Ives?


The answer to the riddle is commonly thought to be 1, the narrator of the rhyme. The man, wives, cats and kits are thought to be going the other way (i.e. coming from St. Ives). You can check out the Wikipedia page on this for more information than you would ever need to know.

For the final output of the lab, print out the information about who the narrator "met" while going to St. Ives. That is, print out:

  • The number of wives
  • The number of sacks
  • The number of cats
  • The number of kits (note: "kits" is short for "kittens")
  • and, the total number of living things met
    i.e. totaling the man, the wives, the cats and the kits (the sacks are not living things)

You are required to use variables, multiplication and addition operations to calculate and determine the answers. For example:

#declaring variables  
numMan = 1             # determining the number of men 
numWives = numMan * 7    # determining the number of wives 

Just storing the value of 7 into the variable numWives is NOT enough for full credit for the assignment.

You are also required display the values in the variables when showing the information about who the narrator met. When doing this you must also display some text describing any values prior to displaying the values. For example:

print  "The number of wives are: " +  repr(numWives)

Submission of the Lab

The lab must be submitted electronically to the Assignment Link for Lab 1 inside of Blackboard. You will only need to submit the python source code file (this is the ".py" file).

You are to name your program file (and the class) using both your NET-ID and the Lab Number. Thus for Lab 1, if you NET-ID was ptroy4, your program should be named: ptroy4Lab1.py

-- troy - 2016-08-26


Topic attachments
I Attachment Action Size Date Who Comment
Texttxt template.py.txt manage 0.5 K 2016-08-28 - 18:17 UnknownUser  
Edit | Attach | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r2 - 2016-08-28 - 18:17:32 - Main.troy
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
Helping Women Faculty Advance
Funded by NSF