This lab was created by R. Jordan Crouser, and updated by Alicia M. Grubb in Spring 2019/2020.


In this lab, we’ll bring together a bunch of things we’ve learned over the course of the semester to try to solve open-ended challenges. These exercises are intended to get you thinking about some of the “big ideas” in computer science: different ways to store information, how to move data between parts of your program, how to handle edge cases, and more.

Be creative! Use plenty of comments to document your thought process.

You must complete 3 out of 4 Steps. Bonus Challenges are optional. You can complete the steps in any order. Read through the entire lab first prior to selecting a step. Do the one you are most interested in first.

For each challenge create a new file/document in Thonny and save it locally with the file name lab10pX.py, where X is the step number (e.g., lab10p1.py for Step 1). Add the course header with the relavent information.



Step 1: Getting Warmed Up

Write a program that asks the user to enter an integer, and prints out its multiplication table for numbers up to 12.

Bonus Challenge: print a useful error message if the user enters something that can’t be converted to an int.



Step 2: Palindrome Test

A palindrome is a string that is spelled the same forward and backward (ignoring any spaces). Some examples:

  • MOM
  • LEVEL
  • RACECAR
  • A MAN A PLAN A CANAL PANAMA

Write a function that takes in a string, and returns True if the string is a palindrome and False otherwise.

Bonus Challenge: figure out how to do this without needing a loop?



Step 3: Staying Organized

Planning out when to take required courses for your major is a challenge for many Smithies. One aspect that makes this especially complicated is keeping track of prerequisites for each course that you want to take.

In this challenge, you’ll write a short program to make this a little easier for all CS students:

  • The file CScourses.txt contains information about the prerequisites for some of the courses offered by the CS department: the first course in each row requires all remaining courses in the row as prerequisites.
  • Write a program that takes in a course number (entered by the user), and prints the corresponding prerequisites.

Hint: think carefully about how you want to store this information so that it’s easy to look up what you want!

Bonus Challenge: print ALL courses that must be taken prior to the requested course (e.g. CSC262 can only be taken after CSC231, CSC212, and CSC111).



Step 4: Rock, Paper, Scissors

ROCK-PAPER-SCISSORS is a common game played by schoolchildren, often to try to decide which person gets to eat the last slice of pizza (or has to do some unpleasant chore). In this game:

  • ROCK beats SCISSORS
  • SCISSORS beat PAPER
  • PAPER beats ROCK

In this challenge, you will implement a virtual game of ROCK PAPER SCISSORS:

  1. Ask the user how many rounds they would like to play, store this as x.
  2. For each round:
    1. The user is asked to enter ROCK, PAPER, or SCISSORS.
    2. The program selects a random move.
    3. The winner of the round (COMPUTER or HUMAN) is announced, and the score is recorded.
  3. The final winner (best out of x) is announced.

Bonus Challenge: add an interesting user interface!



Lab Submission

  • Run your code one more time to make sure you don’t have any syntax errors.
  • For this lab you need to submit your programs via Moodle. Go to our Moodle Page and submit three out of the four following files: lab10p1.py, lab10p2.py, lab10p3.py, and lab10p4.py.