Question
#Create a loop, preferably while, that visits every #tile on a grid with a pre-stored width and height, and #returns the tiles that are inside
#Create a loop, preferably while, that visits every #tile on a grid with a pre-stored width and height, and #returns the tiles that are inside of a specific column #entered by the user, in order, separated by spaces. #Columns start at column 0.
import subprocess
def template(w,h,c):
width = w height = h column = c result = "1" return result #END OF YOUR CODE
test1 = template(4,3,0) test2 = template(4,3,3) test3 = template(4,3,1)
failed = False
if (test1 == "1 5 9" or test1 == "1 5 9 "): print "for a 4x3 board with column 0, you got it RIGHT!" else: print "for a 4x3 board, we expected '1 5 9' , you got: " + str(test1) failed = True if (test2 == "4 8 12" or test2 == "4 8 12 "): print "for a 4x3 board with column 3, you got it RIGHT!" else: print "for a 4x3 board with column 3, we expected '4 8 12' , you got: " + str(test2) failed = True if (test3 == "2 6 10" or test3 == "2 6 10 "): print "for a 4x3 board with column 1, you got it RIGHT!" else: print "for a 4x3 board with column 1, we expected '2 6 10' , you got: " + str(test3) failed = True
if failed == False: print "Your code is CORRECT!" result = subprocess.check_output else: print "Please check your code, at least one test case did not pass." result = subprocess.check_output
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started