python 3
Question #1 - Pig Latin
Pig Latin is a made up language where you take the first letter of a word and move it to the end of the word and add an “ay” to the end
Input for the program will be a sentance entered from the keyboard (all on one line) and write the output to a file. Set the file output to append.
Question #2 - Pennies
You want to determine how many pennies can fit in a circle. The circle is drawn on the cartesian grid, with its center at the origin. A penny is placed on every integer coordinate that lies within or on the circle. Write a program that can determine how many pennies will fit in a circle of Radius R.
For Example: When R = 4, you can fit 49 pennies in the circle
Data input will come from a file. All R values will be stored one per line on the file. It should handle as many values of R as I feel like putting in the file
Question #3 - Find that mine
Have you ever played Minesweeper? Well, the goal of the game is to find where all the mines are within a m x n field. To help you, the game shows a number in a square which tells you how many mines there are adjacent to that square. For instance, suppose the following 4 x 4 field with 2 mines (which are represented by an * character)
If we would represent the same field showing the hint numbers described above, we would end up with:
Given a mine field like in the first picture, your job is to find the number of mines that are adjacent to a specific square and produce the second picture on the screen (Each square can have at most 8 adjacent squares).
Input for the program will be from a file
The first line of the file will be the size of the mine field
· It will be in the format m n
· m is the number of rows and n is the number of columns (Separated by a space)
The remaining lines represent the m x n mine field.
· Mines are represented by * sybmols
· Empty spaces are represented by . symbols
· There are is a single space between the grid positions in the file
Output for the program can be a nicely formatted grid to the screen
Question #4 - Necklace Problem
The "Necklace Problem". The necklace problem begins with two single digit numbers. The next number is obtained by adding the first two numbers together and saving only the onesdigit. This process is repeated until the "necklace" closes by returning to the original two numbers. For example, if the starting numbers are 1 and 8, twelve steps are required to close the "necklace".
Example input of 1 and 8 will take 14 steps to produce this necklace: 1 8 9 7 6 3 9 2 1 3 4 7 1 8
Write a modular program (using functions) that can display the Necklaces and the number of steps taken. The data for your program will be from a file that has 10 sets of inputs. The file consists of 10 lines, each with 2 numbers on the same line representing the starting point of the Necklace.
Question #5 - Simulation
You are going to simulate the Game of NIM
· This is a human vs computer game in which each player takes turn picking stones from a pile
· The game starts with 3 piles of stones with a random # of stones in each pile(>3 and <20)
· The player has the choice of taking any number of stones from ONE pile
· Each player must take at least one stone on each turn
· The player taking the last stone wins
· The computer needs to have some intelligence to how it picks values
You must make your program as modular as possible using functions
Question #6 - Dice Game
You are making a 4 player dice game. Each of the four players starts the game by rolling one 5 sided dice and one 8 sided dice. The total is recorded.
· If the player rolls a total that is an even number, they become an "EVEN" player.
· If they roll an odd total, then the player becomes an "ODD" player.
Now that the players have determined their type, they begin to play the game. Each player rolls the two dice again and the total is recorded
· If the Player is an "EVEN" Player, then he wins the total if that total is a 3 or 9 or 11
· If the Player is an "ODD" Player, then he wins the total if that total is a 5 or 7 or 12
The players play a total of 20 rounds. Each new round total is added to the previous round total and the winner is the player with the most points at the end
You are going to write an object oriented program to simulate this game
Class Design
You are going to use two objects to complete this task. A Dice object and a Player object
Dice Object
Attributes: What data needs to be stored?
· The number of sides of the dice
Constructor: What should happen when the object first gets created?
· Accept the number of sides as a parameter and set the attribute
Behaviours: What should the object be able to do?
· Roll Function:
·
· Accept no parameter
· Return random value between 1 and the number of sides on the dice
Player Object
Attributes: What data needs to be stored?
· The name of the player
· The total points accumulated
· The type of the player "EVEN" or "ODD"
Constructor: What should happen when the object first gets created?
· Accept name of the player as the parameter
· Set the points accumulated to 0
Behaviours: What should the object be able to do?
· Set Type Function:
·
· Accept a string either "EVEN" or "ODD"
· Set the player type attribute
· Roll Function:
·
· Accept two dice objects as parameters
· Return the sum of two dice rolls
· Set Points Function:
·
· Accept a value representing the sum of two dice
· Return the number of points the player should earn based on that sum
Output
Your program should look something like this. Make sure to display the winner at the end
Question #2 - Fractions
You are designing a quiz game to help elementry school students with fraction calculations
Your games should have a set of 25 addition, subtraction, multiplication, division questions located in a file. Each question should be formatted to look like:
· 3/4+4/5
· 5/8*9/4
The questions should be displayed to the player 1 question at a time and reward the player points for gettting the answer to that question correct.
· Question was correct the first time (4 Points in Lowest Terms, 3 Points not in lowest terms)
· Question was incorrect the first time but correct on second guess (2 Points in Lowest Terms, 1 Point not in lowest terms)
· Question incorrect after second guess (0 Points)
Your program should always display the correct answer in lowest terms if the player didn't answer in lowest terms correctly
Your program should append the players name and score to a file when complete.