Bard College – Computer Science – Object-Oriented Programming
This lab explores string processing and file input. You can work alone or in pairs.
Part 1: Madlibs
Using the two files nouns.txt and adjectives.txt on Google Classroom, write a function randomPhrase() that constructs and returns a random sentence when called. For example, in class we thought about using alliteration to create names for bands(e.g., left-wing lampshades). But you could also do something like the love letter generator, or some other mad-libs style fill-in-the-blank sentences. Write a small creative setup/draw to exercise that function. Consider using the choice function from the random module(from random import choice). Explain your algorithm as a comment.
Part 2: Spelling Bee
Create a function spellingBee(centerLetter, otherLetters) that solves NYT’s Spelling Bee puzzles. For example, spellingBee('n', 'ceiprx') should solve the puzzle to the right. You can find the standard dictionary words.txt file on Google Classroom.
Your function should:
1. print out all of the solution words;
2. calculate and return the total score.
Write our your algorithm in English first before diving into the Python programming.
BONUS: Write a simple graphical interface for your spelling bee using Processing.
Learning Objectives
Process strings
Open files for reading
Procedurally generate text
Automate the solution of word games
Submission(due October 7th 14th, 2021)
Your program should start with a comment that includes your name(s), email(s), date, assignment description & collaboration statement.
Bring a hardcopy of your programs(the source code, not the graphics) to your next lab period.
Submit a zip file to Google Classroom(using the correct folder & file names).
Be prepared to run the Processing sketch and demonstrate your“Theory of the Program.”
Part 1: Madlibs
Part 2: Spelling Bee
Learning Objectives
Submission (due October
7th14th, 2021)