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.
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
.
A palindrome is a string that is spelled the same forward and backward (ignoring any spaces). Some examples:
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?
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:
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).
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:
In this challenge, you will implement a virtual game of ROCK PAPER SCISSORS:
x
.x
) is announced.Bonus Challenge: add an interesting user interface!
lab10p1.py
, lab10p2.py
, lab10p3.py
, and lab10p4.py
.