ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 10 Weeks Ago, 5 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 09 May 2017 My Price 9.00

Write a Python program to play a simplified version of the Nim game

Python 3

Write a Python program to play a simplified version of the Nim game. Generate a pile of between 15 and 21 inclusive matchsticks using the random number generator. Allow the human player to go first and remove from 1 to 3 sticks. Then allow the computer to generate a random number between 1 and 3 inclusive and remove that many matchsticks(exception example: if the number is 3 and there are only 2 matchsticks left, then only remove 1 matchstick). Playalternates until 1 matchstick is left and the losing player removes it. Declare the winner and ask if the user would like to play another game.

Validate the input and write the following functions:

-computer_play(pile) –figures out how many sticks the computer will remove and returns the number of sticks to remove

-player_play(pile) –solicits input from the user as to how many sticks to remove, validates the input, and returns the number of sticks the player wants to remove

-print_gameboard(pile) –prints a vertical bar for each matchstick on one line with one space between each matchstick.

-main () –main function which allows the user to play the game as many times as desired; validates all input

Please go to the web site, http://www.archimedes-lab.org/game_nim/play_nim_game.html, and play the game to learn it’s rules.

Answers

(11)
Status NEW Posted 09 May 2017 02:05 AM My Price 9.00

-----------

Attachments

file 1494298025-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)