Lab - Command Line Game
Putting It All Together
Think about all the basic programming knowledge we’ve built upon this week (data types, variables, functions, data structures, etc.) We are laying the foundation for our futures as Python developers. Let’s challenge that knowledge with a review project.
The Task
You will build a command line game that uses raw_input. If you’re not feeling creative - you can make a basic trivia game. Otherwise there are other ideas below.
Trivia Game
answer1 = raw_input ("What is the capital of Illinois?: ")
if answer1 == "Springfield":
print "You are so smart!"
Feature 1: print an answer if the user is incorrect Feature 2: use string methods to ensure that “SPRINGFIELD”, “springfield”, “ sprIngfield” are all correct Feature 3: use a loop to have the user guess an answer until they are correct Feature 4: ask more than one question, tally the number of correct responses and the number of total answers Feature 5 STRETCH: use a dictionary of questions and a dictionary of answers
Other Ideas
- FORTUNE TELLER - have users enter their name and give them a fortune based on some characteristic in their name (number of letters, number of vowels, location of first vowel, first letter etc)
- MASH - Update the classic paper and pencil game. Users enter a number and find out their future job, dwelling, future partner and a shocking life event. You will need arrays for this game
- MADLIBS - Users are prompted to enter adjectives, nouns, adverbs etc to build a fun story
- BATTLESHIP - Tricky! Users enters a location and you tell them if they’ve hit or sunk a battleship
The Instructions
1 Spend the first 5 minutes as a group with laptops down mapping out the features you want to build and how you want a user to use your calculator.
2 Keep in mind MVP (Minimum Viable Product). Remember, MVP is the smallest program you can build that offers value to the user. That is, make an app that has the minimum amount of features while offering a usable product.
3 Every design decision has a tradeoff. Focusing on one thing means you won’t have time to focus on another.
4 You have ~45 mins to build your game.
Presentations
Be prepared to share your game with another group that answers the following questions
- What is your big idea?
- What tools does your code use (loops, conditional statements, user_input(), arrays, dictionaries)
- What was your one takeaway?
- If you had more time, what would be your next step?