Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please write this in python def simple_board (size): Given a size, produce a squ

ID: 3722960 • Letter: P

Question

please write this in python

def simple_board (size): Given a size, produce a square "ASCII art grid representing a game board (like for checkers or chess). The game board will use dashes (-) for the horizontal lines, bars() for the vertical lines, and plus signs (+) for the intersections. size indicates the number of play spaces wide the board is. For example Size 1 Board Size 2 Board Size 3 Board Size 4 Board Return value a string of the game board » Assumptions o size will be a positive integer » Notes: o Hint 1: Modulus is your friend for this function! o Hint 2: You must use at least one loop, but you are not limited to one loop o Make sure to return a string, notprint a string What is "ASCII art"? It is basically "art made with computer text" and creating it is a (popular?) pastime for some people. Google it for more examples, but here's an example of a mouse

Explanation / Answer

def simple_board(size):

s = ""

#calculating number columns and rows

len = 2*size+1

#for rows

for i in range(0,len):

#for columns

for j in range(0, len):

#check whether even row or not

if i%2==0:

#check whether even column or not

if j%2==0:

#appending character into string s

s += str("+")

else:

s +=str("-")

else:

if j%2==0:

s += str("|")

else:

s += str(" ")

#appending new line at every row

s += str(" ")

return s

#take input from user

inp = input("Enter size of board: ")

if inp>0:

#print board

print "Size",inp, "Board"

print simple_board(inp)

else:

#print error message

print "Invalid input"