The Penny Pitch game is popular in amusement parks. Pennies are tossed onto a board that has certain areas marked with different prizes. For example: PUZZLE | | POSTER | | DOLL -- | -- | -- | -- | -- | POSTER | | DOLL | BALL | PUZZLE | GAME | | PUZZLE | BALL | | POSTER | GAME DOLL | GAME | | | BALL The prizes available on this board are puzzle, game, ball, poster, and doll. At the end of the game, if all of the squares that say BALL are covered by a penny, the player gets the ball. This is also true for the other prizes. The board is made up of 25 squares (5 x 5). Each prize appears on three randomly chosen squares so that 15 squares contain prizes. Create a PennyPitch application that displays a Penny Pitch board (use [ and ] to indicate squares) with prizes randomly placed and then simulates ten pennies being randomly pitched onto the board. After the pennies have been pitched, the application should display a message indicating which prizes have been won, if any.
Added by Richard J.
Close
Step 1
- Represent the 5x5 board as a list/array of 25 cells (index 0..24) or as a 5x5 2D array. Each cell will hold either a prize name or "EMPTY". Show more…
Show all steps
Your feedback will help us improve your experience
Avi Bukys and 78 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Akash M.
Write a code for a Python program which creates a number guessing game. At the start of the program, initialize a variable "secret_number" to be a random integer between 1 and 100. In a while loop, the program should: - Ask the user for an integer guess. - If the user guesses too high, print a message saying "too high". - If the guess is too low, print "it's too low". - If the user guesses the correct number, the program should exit the loop and print a congratulatory message. It should also print the number of times the user guessed. - If the number is incorrect, the program should keep looping and requesting new values until the user guesses correctly. Essentially, do the following: - Set "number" as a random number between 1 and 100. - Set "num_guesses" as 0. - Ask the user for a guess. - While the user's guess is too high, tell the user that the guess is too high. Otherwise, tell the user that the guess is too low. - Set "num_guesses" as "num_guesses + 1". - End the while loop. - Congratulate the user on guessing correctly. - Report to the user how many guesses it took.
Michael F.
You are to program a slot machine which has three "wheels", each wheel is a random integer. You bet 1 token and spin the wheels. You win 100 tokens when all three wheels are the same integer, otherwise spin again. Create a function spin() which returns a random integer between 1 and 9 inclusive. Create a function spin3 which spins each wheel and returns 3 random numbers. Use spin() in spin3. Create a function help() which prints out the instructions: Implement a menu as shown below: Enter s to spin, q to quit, h for help: Your main program should: - Keep track of the total number of tokens you have. Start at 1. - For every spin, print the spin number and each wheel value. - Print out when you have won and show the menu. Sample output: Enter s to spin, q to quit, h for help: h Welcome to your slot machine. You bet 1 token for each spin of the wheels. You win 100 tokens when all three wheels are the same. Good Luck Enter s to spin, q to quit, h for help: s Spin Number 1: 4 3 5 Spin Number 2: 8 8 7 Spin Number 3: 5 8 2S Spin Number 4: 4 4 4 Winner!! You won 100 tokens. After 4 spins, your total is 367 tokens. Enter s to spin, q to quit, h for help: q Thank you for playing.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD