Fill in the python code

Assignment Help Python Programming
Reference no: EM13161265

Fill in the Python code to play Tic Tac Toe. I won't award points unless it runs succesfully. # Tic-Tac-Toe Game def drawBoard(board): # Draws the board using the list of numbers print(" ") print(" ",board[0]," | ",board[1]," | ", board[2]) print("----------------") print(" ",board[3]," | ",board[4]," | ", board[5]) print("----------------") print(" ", board[6]," | ",board[7]," | ", board[8]) print(" ") return def nextMove(turn,bd): # Asks the player whose turn it is to choose a spot on the board # The turn parameter represents the player ("O" or "X") # Replace the spot on the board with the right symbol # Return the board return bd def isWinner(bd): # Determines if there is a winner # If X is the winner, return "X" # If O is the winner, return "O" # If there is no winner, return "none" return "X" def moreMoves(bd): # Determines if there are any moves left # if any spaces are left to play # return 1 if there are any moves left # return 0 if there are no moves left return 0 def nextTurn(turn): # Determines whose turn it is based on whose turn # just finished return turn # Main code # # Initialize the board with position numbers # Start out with X going first # Set the winner to 'none' to start # As long as there is no winner and there are still moves to make, loop through the game # Each time through the loop # Draw the board # Make the next move # Determine if there is a winner # Set the turn to the next player # # Once the loop is complete, display the board one more time and print the winner def main(): bd = [0,1,2,3,4,5,6,7,8] turn = 'X' winner = 'none' while winner == 'none' and moreMoves(bd)==1: drawBoard(bd) bd = nextMove(turn,bd) winner = isWinner(bd) turn = nextTurn(turn) drawBoard(bd) print("Player ",winner," is the winner")

Reference no: EM13161265

Questions Cloud

An iterative algorithm to traverse an arbitrary number : An iterative algorithm to traverse an arbitrary number of nested subdirectories in a file system.
Creating a hashing function : Suppose you are creating a hashing function to use for storing string data in hashtable. One Candidate hasing function would be to sum the ASCII or Unicode values for each character, and that result as the hashcode.
A calculator application that allows prefix, infix and postf : A calculator application that allows prefix, infix, and postfix expressions to be evaluated (i.e., allows all 3 types of expressions
Professional full-time employees and volunteers : How can you as a manager suppress the natural tensions that exist between professional full-time employees and volunteers?
Fill in the python code : Fill in the Python code to play Tic Tac Toe. I won't award points unless it runs succesfully. # Tic-Tac-Toe Game def drawBoard(board): # Draws the board using the list of numbers print(" ") print(" ",board[0]," | ",board[1]," | ", board[2]) print("--..
Difference between the two following statements : What exactly is the difference between the two following statements and which is preferred, please provide details: 1) frame.setSize(400, 300); // Set JFrame Size
A deck of playing cards in a card game : A deck of playing cards in a card game where cards may be drawn from, or discarded to, either the top or the bottom of the deck, but no access to cards in the middle of the deck is permitted.
Health care firms merge : Health care firms merge together to gain power and lessen competition, yet they do not realize that competition will still exist regardless of them merging? 20-50 words please.
Quality of health care : Based on your research and experience regarding mergers, do you feel they contribute to improved quality of health care? If so why? If not, why? 20-50 words please.

Reviews

Write a Review

Python Programming Questions & Answers

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd