Lab 4 - Data Types

September 15, 2016

Activity 1: Login and Record Attendance

We will be taking roll in lab each week! Please come to your assigned lab to be counted present!

If you are in an Olsson lab, click "Lab Attendance" on the left-hand menu in Collab to register your attendance and keep up with your lab grade.
YOU MUST CLICK THE LARGE GREEN OR YELLOW BUTTON FOR YOUR ATTENDANCE TO COUNT!!

You must do this from a machine in Olsson 001 and not your laptop. If you have trouble, talk to your lab TA. Students in Lab 109 will do attendance via direction from the TA.

Activity 2: Take Quiz 1

While you are waiting for lab to start, click on Tests & Quizzes in Collab from either the desktop or laptop and take Quiz 1 - a very short review quiz on the material we have covered thus far. If you do not complete it today, you have until Sunday to do so.

Activity 3: Recitation

The TAs will do a quick review lesson on data types before moving on to the in-lab activity.

Activity 4: Building a Magic 8 Ball

Your goal in this lab is to work with a partner write a program called magic_8_ball.py. The program will prompt the user to ask a question of the magic 8 ball. Your program should respond with a randomly-chosen answer from a list of answers that you create.

For example, a run of your program could look like this:

What question do you wish to ask the 8 ball?: Will I get a good grade in CS 1110?
You asked the 8 ball: Will I get a good grade in CS 1110?
The 8 ball says: "All signs point to yes!"

For this assignment, we are not auto-grading your results. So feel free to be creative with the prompts and responses! (Within reason, of course...)

We will, however, look at how you wrote the code. Specifically, how you solved the problem. How did you read in the question? How did you setup your list of responses? How easy would it be to add another response? Is it truly random?

Submission: Each partner should submit one .py file named magic_8_ball.py to Archimedes (the submission system): https://archimedes.cs.virginia.edu/cs1110/. Please put both partners' names and id's in two comments at the top of the file.

more ...

Lab 3 - Turtle Art Contest

September 8, 2016

Activity 1: Login and Record Attendance

We will be taking roll in lab each week! Please come to your assigned lab to be counted present!

If you are in an Olsson lab, click "Lab Attendance" on the left-hand menu in Collab to register your attendance and keep up with your lab grade.
YOU MUST CLICK THE LARGE GREEN OR YELLOW BUTTON FOR YOUR ATTENDANCE TO COUNT!!

You must do this from a machine in Olsson 001 and not your laptop. If you have trouble, talk to your lab TA.

Activity 2: Pairing

For this and all subsequent labs, you will work in pairs.

We will use a model called "pair programming" in this class. There are a few things to know about successful pairing under this model:

  • 2 minds, 1 focus. If at any point the two of you are doing distinct things, such as each typing on your own computer or each looking at your own piece of paper, then you are not pairing properly.
  • Driver and Navigator. At any given point in time, one partner will be the "driver", controlling the keyboard, pencil, or other tool currently being used. The other will be the "navigator," observing and commenting on the driver's actions
  • Equality and Communication. Driver and navigator are equal partners; the ideas of both are equally important, and both should talk, both should listen when the other speaks, and both should treat the other's ideas with respect.
  • Switch Roles. Which partner is driving should change at least every 15-20 minutes, if not more often.

Pairing in this model has many advantages both from a productivity and learning standpoint. One of these is generally an increase the intensity of focus, which can get tiring. Feel free to take breaks every now and then, but try not to distract other pairs during your breaks.

For more hints on successful pairing, you might want to watch this 10-minute video on your own time: http://youtu.be/rG_U12uqRhE

Activity 3: Art Contest

Your goal with this lab is to make the neatest picture you can using the turtle and any example code we have provided. You can use any of the code posted on the lecture notes as a starting point, or you can use your own.

Make sure to look at the Turtle API https://docs.python.org/3/library/turtle.html. (Remember: the API is the "list of things that you can do")

Submission

Save a picture of your image by taking a screenshot and then cropping down to just your image.

Submit a .png file to the Turtle Art Gallery on Dropbox: https://www.dropbox.com/request/VF7Ah4m3PFeGmdLocTFe. Make sure to title your file like this:

930-OLS-mss2x-tbh3f.png

Use 930, 1100, 1230, 200, 330, 500, 630, or 800 along with either OLS or RICE for your lab location so we can keep all the labs together and we know who you are!

Then put in BOTH of your computing IDs, separated by dashes.

The staff will pick our favorite images, with prizes awarded next lab!

more ...

Lab 2 - Counting Squares

September 1, 2016

Activity 1: Test your logins!

If you are in a lab in Olsson 001, try out your Olsson 001 login. If you have trouble, talk to your lab TA.

Activity 2: Pairing

For this and all subsequent labs, you will work in pairs.

We will use a model called "pair programming" in this class. There are a few things to know about successful pairing under this model:

  • 2 minds, 1 focus. If at any point the two of you are doing distinct things, such as each typing on your own computer or each looking at your own piece of paper, then you are not pairing properly.
  • Driver and Navigator. At any given point in time, one partner will be the "driver", controlling the keyboard, pencil, or other tool currently being used. The other will be the "navigator," observing and commenting on the driver's actions
  • Equality and Communication. Driver and navigator are equal partners; the ideas of both are equally important, and both should talk, both should listen when the other speaks, and both should treat the other's ideas with respect.
  • Switch Roles. Which partner is driving should change at least every 15-20 minutes, if not more often.

Pairing in this model has many advantages both from a productivity and learning standpoint. One of these is generally an increase the intensity of focus, which can get tiring. Feel free to take breaks every now and then, but try not to distract other pairs during your breaks.

For more hints on successful pairing, you might want to watch this 10-minute video on your own time: http://youtu.be/rG_U12uqRhE

Activity 3: Grid of doors

Picture of door space

For this lab we will be programming a robot that has been dropped into a grid of square rooms. Each wall of each room has been painted a different color: the __N__orth wall is __N__eon, the __E__ast wall is __E__ggplant, the __S__outh wall is __S__andy, and the __W__est wall is __W__allnut. Walls between rooms have doors in them, but walls on the edge do not. All of the doors are closed initially.

The robot knows how to

  • Check N (or Check E, or S, or W) to see if there is a door on that wall of its current room;
  • Go N (or E or S or W) to move one room over; and
  • Do basic math and remember numbers

If you ask it to Go through a wall that does not have a door, it isn't smart enough to know it can't so it will walk into the wall and damage itself.

We won't be super formal in this lab. If we can tell what you are asking the robot to do, that's good enough for us.

Activity 3.1: Simple Square

Suppose the robot is dropped into a square grid of rooms and starts in the north-west corner of the grid. Come up with an algorithm that the robot can use to figure out how many rooms are in the grid.

Is there any size grid for which your algorithm does not work? How about on a 1-by-1, or a 1000-by-1000?

In a 3-by-3 grid, how many times will the robot have to move through a door to run your algorithm? How about a 4-by-4? An n-by-n?

Assume that we want to save on robot fuel. Can you make an algorithm that uses fewer moves for the same size grid?

Once you have an algorithm you think is general (works for all size squares) and efficient (uses few moves), type it up and save it in a text file. You'll submit all your algorithms at the end. Include a simple statement about how many moves it takes, on an n-by-n grid the robot moves through 2n+5 doors or something like that.

Activity 3.2: Simple Rectangular

Suppose the robot is dropped into a rectangular (not necessarily square) grid of rooms and starts in the north-west corner of the grid. Come up with an algorithm that the robot can use to figure out how many rooms are in the grid.

Type it up and save it on the same text file as before, including a description of the number of moves needed for an n-by-m grid. If your 3.1 algorithm still works, you are welcome to submit it again for 3.2.

Activity 3.3: Rectangular

Suppose the robot is dropped into a rectangular (not necessarily square) grid of rooms and might start in any arbitrary room in the grid. Come up with an algorithm that the robot can use to figure out how many rooms are in the grid.

Type it up and save it in the same text file as before, including a description of the number of number of moves your robot will make for an n-by-m grid. Since this will probably depend on the starting location of the robot, just tell us the biggest number you could see (assuming the robot started in the worst possible room).

If one of your previous two algorithms still works, you are welcome to submit it again for 3.3.

Activity 3.4: Stranger Grids

See how general you can make your algorithm. Can you get it to work on diamond-shaped grids of rooms? Grids with more complicated outlines? Grids where some rooms are missing in the middle? Grids where some walls between two rooms that do exist don't have doors? Arbitrary mazes of rooms?

Type it up and save it in the same text file as before. At the beginning of the submission, include a description of the kinds of grids you think it can handle.

We are not looking for any particular functionality in activity 3.4; if you can't get any more than 3.3 done, submit 3.3 and tell us it's as much as you could do in the time we gave you.

Once you have all 4 algorithms done, submit them all in this Google Form: https://docs.google.com/forms/d/1UnzkMjT9T2NSxttwMDav4pVde4hrvyqbuakXXJ2nKfI/viewform. Only one partner needs to submit!

more ...

Lab 1 - Installing Python

August 25, 2016

Lab this week is optional in that we will not be taking roll. However, this is an opportunity to come to ensure that you have Python and PyCharm installed and working properly on your laptops. If you do not come to lab, we will assume you have taken care of this yourself and you are ready to go when we start coding in lecture next week. So, if you have any doubts, come on down to lab, meet some of the TAs, and make sure you're laptop is setup and ready to go!

Windows

  1. Download the Python installer at https://www.python.org/ftp/python/3.5.2/python-3.5.2.exe and then double-click the download to start the installation.
  2. Choose "Custom Installation" and click Next. Make sure "Add Python to environment variables" is checked. Then click Install.
  3. Download the PyCharm Community Edition installer at https://www.jetbrains.com/pycharm/download/. Double-click the download to start the installation.
  4. At the Installation Options screen, make sure to check "Create associations" - ".py".

Mac

  1. Download the Python installer at https://www.python.org/ftp/python/3.5.2/python-3.5.2-macosx10.6.pkg and then double-click the download to start the installation.
  2. Download the PyCharm Community Edition installer at https://www.jetbrains.com/pycharm/download/. Double-click the download to mount the image. Drag the icon to the Applications folder.
more ...